Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
41 total  XML / RSS feed 

HTML stripper

// description of your code here

str = <<HTML_TEXT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
  <h1>Application error</h1>
  <p>Change this error message for exceptions thrown outside of an action (like 
in Dispatcher setups or broken Ruby code) in public/500.html</p>
</body>
</html>
HTML_TEXT

puts str.gsub(/<\/?[^>]*>/, "")

snippet

Download code snippets (http://textsnippets.com) from the command line and convert them to text files using man textutil (on Mac OS X 10.4).

Usage:
snippet 345
snippet 1268
snippet 1281



# $ cat $HOME/.bash_login

function snippet() {
   mkdir -p $HOME/Desktop/Snippets
   OPWD="$PWD"
   cd $HOME/Desktop/Snippets
   curl -L -O -s --max-time 25 http://textsnippets.com/posts/show/"$1" || exit 1
   file="$HOME/Desktop/Snippets/$(basename $_)"
   textutil -convert txt "$file"
   rm "$file"
   new_file="$file.txt"
   sed -i "" -e '1,5d' -e 's/.See related posts.//' "$new_file"  # delete first 5 lines of file
   sed -i "" -e :a -e '1,6!{P;N;D;};N;ba' "$new_file"            # delete last 6 lines of file
   cd "$OPWD"
   return 0
}


JavaScript Roll Overs

// JavaScript roll overs

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
 var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
 if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
 d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

// html code
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image1','','2.png',1)"><img src="1.png" name="Image1" width="155" height="71" border="0" id="Image1" /></a>

MailMan listserve signup template

Simple template for adding a MailMan mailing list subscribe form to a page. Found on a mailing list somewhere a long time ago and cleaned up dramatically.

Note: I almost always just include the email and digest options, but I've included the whole spiel for completeness.


<h2>Join the XYZ list</h2>

<form method="post" action="SERVER/mailman/subscribe/LISTNAME">

  <p>
    Your E-mail address: <input type="text" name="email" size="30" value=""><br />
    Your Name (optional): <input type="text" name="fullname" size="30" value=""><br />
  </p>

  <p>You may enter a privacy password below. This provides only mild security, but should<br />
  prevent others from messing with your subscription. <b>Do not use a valuable password</b> as it<br />
  will occasionally be emailed back to you in cleartext.</p>

  <p>If you choose not to enter a password, one will be automatically generated for you, and it will<br />
  be sent to you once you've confirmed your subscription. You can always request a mail-back<br />
  of your password when you edit your personal options.</p>

  <p>
    Password choice: <input type="password" name="pw" size="15"><br />
    Confirm Password: <input type="password" name="pw-conf" size="15">
  </p>

  <p>
    Would you like to receive list mail batched in a daily digest? (You may choose NoMail after you join.)<br />
    <input type="radio" name="digest" value="0" checked> No 
    <input type="radio" name="digest" value="1"> Yes <br />
  </p>
  
  <p><input type="submit" name="email-button" value="Subscribe"></p>

</form>


HTML link regex

// use url group and ignore case (because of something like HREF)
// based on http://regexlib.com/REDetails.aspx?regexp_id=1048
href="(?<url>(((ht|f)tp(s?))\://)?((([a-zA-Z0-9_\-]{2,}\.)+[a-zA-Z]{2,})|((?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(\.?\d)\.)){4}))(:[a-zA-Z0-9]+)?(/[a-zA-Z0-9\-\._\?\,\'/\\\+&amp;%\$#\=~]*)?)"

Standard CSS helpers

Some really common layout classes I use in almost every CSS file.

/********* helpers *********/
.floatRight { float: right; }
.floatLeft  { float: left; }
.right  { text-align: right; }
.left   { text-align: left; }
.center { text-align: center; }
.clear, .clearer { clear: both; }
.block  { display: block; }

PHP State-Array Generator

Simple array for HTML mockups.

function state_selection() {
        echo '<select name="state">';
                $states = array(
                        'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
                );
                foreach ($states as $state_name) {
                        echo '<option value="'.$state_name.'">'.$state_name.'</option>';
                }
        echo '</select>';
}
state_selection();

US States Pop-up

Simply a pop-up form element of all 50 US States. Save you creating your own.

            <select name="state">
              <option value="" selected="selected">Select a state...</option>
              <option value="AL">Alabama</option>
              <option value="AK">Alaska</option>
              <option value="AZ">Arizona</option>
              <option value="AR">Arkansas</option>
              <option value="CA">California</option>
              <option value="CO">Colorado</option>
              <option value="CT">Connecticut</option>
              <option value="DC">District of Columbia</option>
              <option value="DE">Delaware</option>
              <option value="FL">Florida</option>
              <option value="GA">Georgia</option>
              <option value="HI">Hawaii</option>
              <option value="ID">Idaho</option>
              <option value="IL">Illinois</option>
              <option value="IN">Indiana</option>
              <option value="IA">Iowa</option>
              <option value="KS">Kansas</option>
              <option value="KY">Kentucky</option>
              <option value="LA">Louisiana</option>
              <option value="ME">Maine</option>
              <option value="MD">Maryland</option>
              <option value="MA">Massachusetts</option>
              <option value="MI">Michigan</option>
              <option value="MN">Minnesota</option>
              <option value="MS">Mississippi</option>
              <option value="MO">Missouri</option>
              <option value="MT">Montana</option>
              <option value="NE">Nebraska</option>
              <option value="NV">Nevada</option>
              <option value="NH">New Hampshire</option>
              <option value="NJ">New Jersey</option>
              <option value="NM">New Mexico</option>
              <option value="NY">New York</option>
              <option value="NC">North Carolina</option>
              <option value="ND">North Dakota</option>
              <option value="OH">Ohio</option>
              <option value="OK">Oklahoma</option>
              <option value="OR">Oregon</option>
              <option value="PA">Pennsylvania</option>
              <option value="RI">Rhode Island</option>
              <option value="SC">South Carolina</option>
              <option value="SD">South Dakota</option>
              <option value="TN">Tennessee</option>
              <option value="TX">Texas</option>
              <option value="UT">Utah</option>
              <option value="VT">Vermont</option>
              <option value="VA">Virginia</option>
              <option value="WA">Washington</option>
              <option value="WV">West Virginia</option>
              <option value="WI">Wisconsin</option>
              <option value="WY">Wyoming</option>
            </select>

Load javascript function from returned ajax HTML

Problem - calling a function in <script> tags from dynamic ajax results does not get executed by the browser

Resolution - make a pixel image and call the function with the onload event in the image

<img src="some_image.jpg" onload="someFunction();">

IE Fix for max-width CSS property

AGAIN another IE fix. IE of course does not recognize the max-width CSS property. This piece of code will fix it for IE6 and IE7. This code snip will make the maximum width for the html object 900 pixels.

.cssClass
{
width:expression(document.body.clientWidth > 900? "900px": "auto" );
}

Close dangling HTML tags

Close open HTML tags, e.g. if you allow HTML in your comments. Not quite as robust as running it through tidy, but tidy is not always available.

function close_dangling_tags($html){
  #put all opened tags into an array
  preg_match_all("#<([a-z]+)( .*)?(?!/)>#iU",$html,$result);
  $openedtags=$result[1];

  #put all closed tags into an array
  preg_match_all("#</([a-z]+)>#iU",$html,$result);
  $closedtags=$result[1];
  $len_opened = count($openedtags);
  # all tags are closed
  if(count($closedtags) == $len_opened){
    return $html;
  }

  $openedtags = array_reverse($openedtags);
  # close tags
  for($i=0;$i < $len_opened;$i++) {
    if (!in_array($openedtags[$i],$closedtags)){
      $html .= '</'.$openedtags[$i].'>';
    } else {
      unset($closedtags[array_search($openedtags[$i],$closedtags)]);
    }
  }
  return $html;
}

HTML Form Values - Select U.S. State or Canadian Province with ISO code

// description of your code here

<select id="state" name="state">
<option value="">Select One</option>
<optgroup label="Canadian Provinces">
<option value="AB">Alberta</option>
<option value="BC">British Columbia</option>
<option value="MB">Manitoba</option>
<option value="NB">New Brunswick</option>
<option value="NF">Newfoundland</option>
<option value="NT">Northwest Territories</option>
<option value="NS">Nova Scotia</option>
<option value="NU">Nunavut</option>
<option value="ON">Ontario</option>
<option value="PE">Prince Edward Island</option>
<option value="QC">Quebec</option>
<option value="SK">Saskatchewan</option>
<option value="YT">Yukon Territory</option>
</optgroup>
                        
<optgroup label="U.S. States">
<option value="AK">Alaska</option>
<option value="AL">Alabama</option>
<option value="AR">Arkansas</option>
<option value="AZ">Arizona</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DC">District of Columbia</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="IA">Iowa</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="MA">Massachusetts</option>
<option value="MD">Maryland</option>
<option value="ME">Maine</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MO">Missouri</option>
<option value="MS">Mississippi</option>
<option value="MT">Montana</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="NE">Nebraska</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NV">Nevada</option>
<option value="NY">New York</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="PR">Puerto Rico</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VA">Virginia</option>
<option value="VT">Vermont</option>
<option value="WA">Washington</option>
<option value="WI">Wisconsin</option>
<option value="WV">West Virginia</option>
<option value="WY">Wyoming</option>
</optgroup>
</select>

HTML Form Values - Select Country 2-letter ISO Code

// An HTML form select box containing country names with the values set to their 2-letter ISO codes.

<select size="1" id="country" name="country">
<option value="">Select One</option>
<option value="US">United States</option>
<option value="CA">Canada</option>
<option value="">----------</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaidjan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia-Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="CS">Former Czechoslovakia</option>
<option value="SU">Former USSR</option>
<option value="FR">France</option>
<option value="FX">France (European Territory)</option>
<option value="GF">French Guyana</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GB">Great Britain</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe (French)</option>
<option value="GU">Guam (USA)</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard and McDonald Islands</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="INT">International</option>
<option value="IR">Iran</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="CI">Ivory Coast (Cote D&#39;Ivoire)</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Laos</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique (French)</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia</option>
<option value="MD">Moldavia</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NT">Neutral Zone</option>
<option value="NC">New Caledonia (French)</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="KP">North Korea</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn Island</option>
<option value="PL">Poland</option>
<option value="PF">Polynesia (French)</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion (French)</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="GS">S. Georgia & S. Sandwich Isls.</option>
<option value="SH">Saint Helena</option>
<option value="KN">Saint Kitts & Nevis Anguilla</option>
<option value="LC">Saint Lucia</option>
<option value="PM">Saint Pierre and Miquelon</option>
<option value="ST">Saint Tome (Sao Tome) and Principe</option>
<option value="VC">Saint Vincent & Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovak Republic</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="KR">South Korea</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SJ">Svalbard and Jan Mayen Islands</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syria</option>
<option value="TJ">Tadjikistan</option>
<option value="TW">Taiwan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="UY">Uruguay</option>
<option value="MIL">USA Military</option>
<option value="UM">USA Minor Outlying Islands</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VA">Vatican City State</option>
<option value="VE">Venezuela</option>
<option value="VN">Vietnam</option>
<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (USA)</option>
<option value="WF">Wallis and Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="YU">Yugoslavia</option>
<option value="ZR">Zaire</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option>
</select>

Post link to POOKMARK with Textpattern

Simple link to post each individual article to Japanese social bookmark "POOKMARK".

POOKMARK Airlines
http://pookmark.jp/

<a href="http://pookmark.jp/post?url=<txp:permlink />&title=<txp:title />" title="">POOKMARK THIS</a>

tank_base_theme.css

// base

@charset "iso-8859-1";

/*******************************************************************************
*  tank_base_theme.css : 2005.09.01
* -----------------------------------------------------------------------------
*  Base Tank! theme. Applied to the layout by default. Theme modifications
*  applied via a style-switcher or external stylesheet should build upon what
*  is here. 
*******************************************************************************/

@import "http://webhost.bridgew.edu/etribou/layouts/utility_css/visual_consistencies.css";

p
{
        line-height: 140%;
}
body
{
        background-color: #fec;
        color: #000;
        background-image: url("../images/ruthsarian.png");
        background-repeat: no-repeat;
        background-position: 30px 100%;
        background-attachment: fixed;
}
#topMenu ul
{
        width: 12em;    /* make the pop menus a little wider */
}
#pageWrapper, #innerColumnContainer, #masthead, #footer, #topMenu, #topMenu ul, #topMenu a
{
        border-color: #c93;
}
div.twoColumns div.leftColumn, div.twoColumns div.rightColumn
{
        border-color: #ddd;
}
#pageWrapper
{
        background-color: #f9f9f2;
        color: #665;
        font-family: arial, helvetica, sans-serif;
        font-size: 80%;
        background-image: url("../images/ruthsarian.png");
        background-repeat: no-repeat;
        background-position: -110px 100%;
}
#masthead
{
        background-color: #dc8;
        background-image: url("../images/tank.png");
        background-position: 100% 100%;
        background-repeat: no-repeat;
        padding: 10px;
        color: #000;
}
#masthead h1
{
        font-size: 150%;
}
#masthead h2
{
        font-size: 260%;
        color: #862;
}
#outerColumnContainer
{
        background-color: #fff;
        color: #223;
        border-right-color: #fff; /* right column background color */
}

#contentColumn, #rightColumn, #masthead, #footer
{
        padding-top: 10px;
        padding-bottom: 10px;
}
#contentColumn
{
        padding-top: 0;
}
#topMenu
{
        border: solid 0 #c93;
        border-width: 4px 0 0 0;
        padding-right: 40px;
}
#topMenu li a, #topMenu li a:link, #topMenu li a:visited, #topMenu li a:active
{
        background-color: #ffe;
}
#topMenu li a:hover
{
        color: #fff;
        background-color: #c93;       /* keep the same color as the borders */
}
#rightColumn ul.rMenu
{
        margin: 0 5px 10px 5px;
}
#rightColumn ul.rMenu, #rightColumn ul.rMenu li a,  #rightColumn ul.rMenu li ul
{
        border-color: #ed9;
}
#rightColumn ul.rMenu a:link, #rightColumn ul.rMenu a:visited, #rightColumn ul.rMenu a:active
{
        background-color: #ffe;
        color: #336;
}
#rightColumn ul.rMenu a:hover
{
        background-color: #c93;
        color: #fff;
}
#rightColumn h3
{
        margin-bottom: 0;
        padding-bottom: 0;
        color: #b83;
        z-index: 999;
        line-height: 0.75em;
        font-size: 140%;
        /* \*/ position: relative;        /* With this here, IE/Mac will put this on 
                                           top of every other element in the page. so
                                           drop-down menus appear under. ick. so hide
                                           it with this hack. */
}

Ruthsarian Layouts - Tank!

// http://webhost.bridgew.edu/etribou/layouts/Tank!/index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                <style type="text/css" media="screen">
                <!--
                        @import "css/tank.css";
                        @import "css/tank_base_theme.css";
                -->
                </style>
                <link rel="alternate stylesheet" title="blue : color" href="css/theme/blue.css" media="screen">
                <link rel="alternate stylesheet" title="green : color" href="css/theme/green.css" media="screen">
                <link rel="alternate stylesheet" title="camille : color" href="css/theme/camille.css" media="screen">
                <link rel="alternate stylesheet" title="gray : color" href="css/theme/gray.css" media="screen">
                <link rel="alternate stylesheet" title="black : color" href="css/theme/black.css" media="screen">
                <script type="text/javascript" src="http://webhost.bridgew.edu/etribou/layouts/javascript/ruthsarian_utilities.js"></script>
                <script type="text/javascript">
                <!--
                        var font_sizes = new Array( 100, 86, 124 );
                        var current_font_size = 0;
                        var browser = new browser_detect();
                        if ( ( typeof( NN_reloadPage ) ).toLowerCase() != 'undefined' ) { NN_reloadPage( true ); }
                        if ( ( typeof( set_min_width ) ).toLowerCase() != 'undefined' ) { set_min_width( 'pageWrapper' , 760 ); }
                        if ( ( typeof( sfHover       ) ).toLowerCase() != 'undefined' ) { event_attach( 'onload' , function () { sfHover( 'topMenu' ); sfHover( 'rightMenu' ); } );  }
                        if ( ( typeof( loadFontSize  ) ).toLowerCase() != 'undefined' ) { event_attach( 'onload' , loadFontSize ); }
                        if ( ( typeof( setActiveStyleSheet ) ).toLowerCase() != 'undefined' ) { setActiveStyleSheet( getPreferredStylesheet( 'color' ) , 'color' ); }
                //      if ( ( typeof( opacity_init  ) ).toLowerCase() != 'undefined' ) { opacity_init(); }
                //-->
                </script>
                <title>Tank! : Ruthsarian Layouts</title>
        </head>
        <body lang="en">
                <div id="pageWrapper">
                        <div id="masthead">

<h1>Ruthsarian Layouts</h1>
<h2>Tank!</h2>

                                <hr class="hide">
                        </div>
                        <div id="outerColumnContainer">
                                <div id="innerColumnContainer">
                                        <div id="contentColumn">

        <ul id="topMenu" class="clearfix rMenu-hRight rMenu-hor rMenu"
                ><li class="rMenu-expand"
                        ><a href="http://webhost.bridgew.edu/etribou/layouts/">Layouts</a
                        > <ul class="rMenu-ver"
                                ><li class="rMenu-expand"
                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/">Skidoo</a
                                        > <ul class=""
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/fixed_width.html">Fixed Width</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/fluid_width.html">Fluid Fixed Width</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/tweak_02.html">Detached Masthead</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/tweak_01.html">Border Into Masthead</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/bgImages.html">Background Images</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo/demos/gutterless.html">Gutterless</a
                                                ></li
                                        > </ul
                                ></li
                                ><li
                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo_too/">Skidoo Too</a
                                ></li
                                ><li
                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/skidoo_too/gargoyles/">Gargoyles</a
                                ></li
                                ><li class="rMenu-expand"
                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/exp/index.html">Experiments</a
                                        > <ul class=""
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/exp/plaine/">Plaine</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/exp/nausicaa/">NausicaƤ</a
                                                ></li
                                                ><li
                                                        ><a href="http://webhost.bridgew.edu/etribou/layouts/exp/bob/">Bob</a
                                                ></li
                                        > </ul
                                ></li
                        > </ul
                ></li
                ><li
                        ><a href="http://webhost.bridgew.edu/etribou/software/">Labs</a
                ></li
                ><li class="rMenu-expand"
                        ><a href="http://weblog.bridgew.edu/ruthsarian/">Blog</a
                        > <ul class="rMenu-ver"
                                ><li
                                        ><a href="http://weblog.bridgew.edu/ruthsarian/archives/cat_web_of_information.html">Web of Information</a
                                ></li
                                ><li
                                        ><a href="http://weblog.bridgew.edu/ruthsarian/archives/000130.html">Wide Images in CSS Layouts</a
                                ></li
                                ><li
                                        ><a href="http://weblog.bridgew.edu/ruthsarian/archives/000105.html">IE Boxing</a
                                ></li
                        > </ul
                ></li
                ><li
                        ><a href="mailto:ruthsarian@gmail.com">Contact</a
                ></li
        > </ul>

                                                <div class="inside">

<div class="twoColumns">
        <div class="leftColumn">
                <div class="inside">

<h3>Introduction</h3>
<p>
        <em>Tank!</em> is CSS-based web page layout. The goal for this layout
        was to incorporate several tricks/features that help further demonstrate
        the versatility of CSS. These include drop-down menus, theme switching,
        changing font size, source ordering, transparent images, multiple columns, 
        and hopefully some nice style.
</p>

<h3>A Work In Progress</h3>
<p>
        I'm releasing this layout a little early. It's still a work in progress.
        IE 5.0 (for Mac OS 9 and earlier) has some severe bugs that cause the text
        to not appear correctly; however IE 5.2 works just fine. Netscape 7.0 has
        a problem with the drop-down menus where they are displayed in the flow
        of the document, forcing the rest of the page's content down while the
        drop-menu is displayed. There is no Netscape 4 specific stylesheet
        at the moment. NS4 users will simply see a plain page. Oh, and if you
        figure out my not-completely-documented dropdown system and try to
        apply it to the vertical menu, you may run into some problems, so I 
        wouldn't try it right now.
</p>
<p>
        Feel free to send an e-mail to <em>ruthsarian at gmail dot com</em>
        if you find other bugs that you'd like to report.
</p>

<h3>No Zip (Yet)</h3>
<p>
        I'm not yet providing an archive of the layout with all the necessary
        CSS and JavaScript and all the paths worked out, etc.. in a single ZIP
        ready to go. This is because I don't consider this layout to be
        ready <em>enough</em>. If you want to take this layout for a test drive,
        you'll have to figure out how to pull out the CSS, HTML and JavaScript
        needed. This isn't hard at all, but if you don't know how then you probably
        aren't ready to use a layout that may still be a bit... touchy.
</p>

<h3>Short on documentation</h3>
<p>
        I'll try to add more documentation to this page as I have time. Right now
        I'm focusing in on the more important pieces of information about this layout,
        rather than worry about a full write-up on all the intricacies.
</p>

                </div>
        </div>
        <div class="rightColumn">
                <div class="inside">

<h3>Gargoyles - Season 2, Vol. 1</h3>
<p>
        <a href="http://www.amazon.com/gp/product/B000ATQYVA/">Gargoyles - Season 2, Volume 1</a>
        was released on December 6, 2005. The DVD contains the first half (26 half-hour episodes) of 
        the second seasion of <a href="http://tv.disney.go.com/jetix/gargoyles/">Gargoyles</a>. Special
        features include commentary on the 4-part "City of Stone", a featurette on the making of with
        new interviews of several cast members, and introductions of each episode by creator
        <a href="http://www.s8.org/gargoyles/askgreg/">Greg Weisman</a>.
</p>

<h3>Support / Donations</h3>
<p>
        Every so often I hear from someone who offers to make a donation or asks
        about ways to support my work. My position, as outlined in the content of 
        the <a href="http://webhost.bridgew.edu/etribou/layouts/skidoo_too/gargoyles/index.html">Skidoo 
        Too: Gargoyles</a> layout, remains the same: I don't want money. I'm not trying to make money, 
        I just want to share with others my own bits of work with CSS. I think the knowledge I gain 
        from my own work is its own reward (regardless of how corny that sounds).
</p>
<p>
        However, if you would like to support a cause near and dear to me, I
        would ask that you pick up a copy of <a href="http://www.amazon.com/gp/product/B000ATQYVA/">Gargoyles 
        - Season 2, Volume 1</a>. Gargoyles is a great show, well written, and entertaining
        to both kids and adults. I would like to see the show continued in some manner, but to
        do that we need to first get <a href="http://www.disney.com">Disney's</a> attention. That
        can be done through increasing salse of the latest <a href="http://www.amazon.com/gp/product/B000ATQYVA/">Gargoyles
        DVD</a>. If it sells well enough to make a blip on the radar of Disney's executives, <em>if they
        think they can make money with it</em>, Disney might just start producing new content (episodes) of
        the show. That would be something I would really like to see.
</p>
<p>
        So I ask that you pick up a copy of the DVD if you get the chance. I think
        you'll enjoy it if you take the time to watch the show. This is not just a kids'
        show and adults will absolutely enjoy it as much as (if not more than) children. 
        But, if you've got no interest, the least you can do is give it to a family member
        or friend who might be interested, or have children. It makes a great holidy gift!
</p>

                </div>
        </div>
        <div class="clear"></div>
</div>

<h3>Everything To The Right</h3>
<p>
        Key design issue is that the typical vertical menu you
        see in many web pages is included here. What isn't typical
        is that this menu is moved to the right side of this layout.
        The horizontal menu at the top of the page is also right-aligned.
</p>
<p>
        Why is this?
</p>
<p>
        This goes back to an old lesson in a Photoshop 3 book I read
        a long time ago. It recommended you move the toolbar over to the right
        side of your window. The reason being that it keeps the scroll bars
        closer to your toolbar, creating less distance for the mouse to travel
        and, thus, less movement for your hand. It helps relieve a small amount 
        of work (and stress) on the hand. It's also easier to navigate, in general,
        for right-handed people, which make up the majority of the people in the
        world. And it's something new and different so I wanted to give it a try.
</p>
<p>
        That large margin/gutter/gap on the left of the layout is there to help 
        reenforce the eyes to the right side of the page. The empty space also
        is a nice spot to catch when reading left to right and moving down a line.
        I also think it's visually interesting, but you can go ahead and delete it
        if you don't like it. It doesn't serve any critical function except to
        free up an otherwise busy layout.
</p>

<h3>Utility Stylesheets</h3>
<p>
        Several stylesheets used in this layout are part of my
        <a href="http://webhost.bridgew.edu/etribou/layouts/utility_css/">utility 
        stylesheets collection</a>. The point of these stylesheets is that they
        provide specific functionality that I use in several layouts. Rather than
        keeping several different copies of (basically) the same stylesheet, I've
        put them into one place. That way if a bug pops up in the drop-down menu
        stylesheet, I can fix one stylesheet and all my layouts that use it will
        be immediately updated.
</p>

<h3>JavaScript</h3>
<p>
        The goal is to rely on CSS as much as possible and to keep the layout functional
        even without JavaScript enabled. Despite this constant goal with all
        <a href="/etribou/layouts/">Ruthsarian layouts</a>, there is a fair amount of
        <a href="/etribou/layouts/javascript/ruthsarian_utilities.js">JavaScript</a> used 
        in this layout. A lot of it is there to provide a helping hand to some browsers 
        that either don't support full CSS or have a broken implementation of some
        CSS features. 
</p>
<p>
        For example, IE does not support the <code>:hover
pseudoclass on
elements other than anchor tags. As a result, the drop-down menus don't work. JavaScript
is used to apply an extra CSS class to list items while the mouse is over the element
to emulate the
:hover
pseudoclass. Position and appearence of the drop-down
menus is handled by CSS. If/When IE supports the
:hover
pseudoclass, this
bit of JavaScript can be removed and the drop-down will function completely without
JavaScript. Drop-down menus will work fine with FireFox
and several other new generation browsers without that JavaScript.



Other implementations of JavaScript in the layout bring functionality most likely already
available through a browser menu option into the page itself. One example of this is
the style switcher. Several browsers already support the switching or application of alternate
stylesheets (if defined) to a web page. The style switcher provides a different interface to
this feature. The same with the font size changing system. Almost all browsers offer a feature
to increase the base font size of the browser. This font size system just brings that interface
into the web page.



The point is this: you can remove all JavaScript from this layout and it will still
function. The only thing you lose is some ease-of-use accessories for the user and/or
minor compatibility issues that, by themselves, will not break the layout.



<h3>Quick Bits</h3>

Cookies are used to store the prefered font size and style so it remains through each
page visit.



If the page has short content the footer will
fill in the space between the bottom of the layout and the bottom of the
browser window.



Style switcher and font size setter HTML are created via JavaScript
document.write()
.
This way users who do not have JavaScript enabled will not see the interface for this JavaScript
dependant features.



The name Tank! comes from the song by the same name recorded by the Seatbelts. It is the
theme song to the anime series Cowboy Bebop. I was listening to that song when I decided
to finally name this layout. If you haven't, I highly recommend picking up Cowboy Bebop,
both the DVDs and the soundtracks (of which there are many).




</div>
<hr class="hide">
</div>
<div id="rightColumn">
<div class="inside">
<h3>Stylesheets</h3>
<ul class="rMenu-wide rMenu-ver rMenu"
><li
>tank.css</li
><li
>tank_base_theme.css</li
><li
>rMenu.css</li
><li
>visual_consistencies.css</li
></ul>

<h3>Theme Styles</h3>
<ul class="rMenu-wide rMenu-ver rMenu"
><li
>blue.css</li
><li
>green.css</li
><li
>camille.css</li
><li
>gray.css</li
><li
>black.css</li
></ul>

<h3>JavaScript</h3>
<ul class="rMenu-wide rMenu-ver rMenu"
><li
>ruthsarian_utilities.js</li
></ul>

<h3>References</h3>
<ul class="rMenu-wide rMenu-ver rMenu"
><li
>css-discuss.org</li
><li
>CSS Filters</li
><li>Piefecta Demo Layout</li
><li
>Douglas Livingstone's 3-Column Layout</li
><li
>456 Berea Street</li
><li
>Explore Color</li
></ul>

<h3>Menu Example</h3>
<ul id="rightMenu" class="rMenu-wide rMenu-vRight rMenu-ver rMenu" style="float:none;"
><li class="rMenu-expand"
>Layouts <ul class="rMenu-ver"
><li
>Tank!</li
><li
>Gargoyles</li
><li
>Skidoo Too</li
><li class="rMenu-expand"
>Skidoo <ul class=""
><li
>Fixed Width</li
><li
>Fluid Fixed Width</li
><li
>Detached Masthead</li
><li
>Border Into Masthead</li
><li
>Background Images</li
><li
>Gutterless</li
> </ul
></li
><li class="rMenu-expand"
>Experiments <ul class=""
><li
>Plaine</li
><li
>NausicaƤ</li
><li
>Bob</li
> </ul
></li
> </ul
></li
><li
>Labs</li
><li class="rMenu-expand"
>Blog <ul class="rMenu-ver"
><li
>Web of Information</li
><li
>Cold Fusion</li
><li
>Informational</li
> </ul
></li
><li
></li
> </ul>


<script type="text/javascript">
<!--
var browser = new browser_detect();
if ( browser.versionMajor > 4 || !( browser.isIE || browser.isNS ) )
{
/* only offer style/font changing to version 5 and later browsers
* which have javascript enabled. curiously, if you print this out
* in NS4, NS4 breaks for some reason.
*/
document.write(' \
<p class="fontsize-set"> \

><img src="images/font_small.gif" width="17" height="21" \
alt="Small Font" title="Small Font" \
><\/a> \

><img src="images/font_medium.gif" width="17" height="21" \
alt="Regular Font" title="Medium Font" \
><\/a> \

><img src="images/font_large.gif" width="17" height="21" \
alt="Large Font" title="Large Font" \
><\/a> \
<\/p> \
');
}
//-->
</script>

<script type="text/javascript">
<!--
if ( browser.versionMajor > 4 || !( browser.isIE || browser.isNS ) )
{
/* only offer style/font changing to version 5 and later browsers
* which have javascript enabled.
*/
document.write( ' \
<div class="colorPicker" \
>

onclick="setActiveStyleSheet( \'default\' , \'color\' ); return false;" \
title="Default><\/a \
>

onclick="setActiveStyleSheet( \'blue\' , \'color\' ); return false;" \
title="Blue" ><\/a \
>

onclick="setActiveStyleSheet( \'green\' , \'color\' ); return false;" \
title="Blue" ><\/a \
>

onclick="setActiveStyleSheet( \'camille\' , \'color\' ); return false;" \
title="Camill><\/a \
>

onclick="setActiveStyleSheet( \'gray\' , \'color\' ); return false;" \
title="Gray" ><\/a \
>

onclick="setActiveStyleSheet( \'black\' , \'color\' ); return false;" \
title="Black" ><\/a \
><div class="clear"><\/div \
><\/div> \
');
}
//-->
</script>


</div>
<hr class="hide">
</div>
<div class="clear"></div>
</div>
</div>
<div id="footer" class="inside">


No copyrights.

All content is released into the public domain.



<hr class="hide">
</div>
</div>
</body>
</html>

findout browser

// the navigator object stores the browser ...

<script type="text/javascript">
document.write("Your browser is " + navigator.appName);
</script>

Mask address bar so always set to yourdomain.com

// You can use frames to mask your address bar so it always shows www.yourdomain.com when viewing your pages. Use the frameset below in your default page (index.htm). In this example, the frameset will load home.htm and start your site from there. But the address bar will stay showing www.yourdomain.com.

<frameset rows="*">
<frame src="home.htm">
</frameset> 

Disable autocomplete on input fields

// Disable autocomplete on any input field with the "autocomplete" parameter in your input tag

<input name="first_name" type="text" autocomplete="off">

Disable right click

// added <body> to diable the right click.. works on *most* browsers

<body oncontextmenu="return false">
« Newer Snippets
Older Snippets »
41 total  XML / RSS feed