single parents dating websites

www sex in the uk

personals escort

largest online dating sites

clark singles

curious personals

cockold couples

sex chatt

hot match up com

swinging websites

islamic dating sites

cheap sex phone

sex cam

corona singles

dating lawyer

south florida dating

single swinger

lasbian girl

dating and men

sex dating nederland

escort in boston

personals cheating

date in

american dating agency

free dating ads

internet online dating

adul friend finder

kenyan singles

www goerie com personals

singles to italy

company dating

online chat web

affairs network

dating big men

latter day singles

carolina personals

gay hookups

oral sex gay men

friendfinder

nashville singles bars

college station singles

largest personals

late night hookups brianna

mexican dating sites

new club singles

dating valentine 2006

pics of sex parties

new dating site in uk

best dating services

senior friend finder com

midget dating

hook up tonight

friend singles

place to meet women

dating sites millionaire

kerren swinger

christian single chat

www sex om

dating columbian women

truematch com

personals men

sexual chats

singles groups kansas city

mature women over 40

100 free dating site in us

american match maker

singles cape cod

australian matchmaker

air force singles

dating free woman

movie one night stand

japan singles

swinger web

kansas friend finder

gallery escort agency

swinger private

independence singles

couples wife swapping

nc swinger clubs

singles over 50

dream mates com

www nastygirls com

raleigh singles

sex websites

bi sex couples

yahoo online dating

australian chat rooms

odd couple tv series dvd

christian singles club

real sex

dating best site

sex sit

thunder bay personals

gay muscle personals

swinging couples photos

dating millionaire

discreet personals

myspace singles

dating free profile

young professional singles

Regular Expression Helper

Posted by jonathan on February 11, 2008

Click here to play with a simple reg exp helper for JavaScript.

Regular Expression Helper in JavaScript

Paste some text in, then experiment with typing in regular expressions, and watching the matches listed as you type.

Using Javascript to Set a Slide Background

Posted by jonathan on February 28, 2006

One of the problems of making a good image display page is the problem that some images come in portrait format, and some come in landscape. There are several ways to set up appropriately formatted thumbnail backgrounds including:

  • pick each thumbnail background manually, or
  • use only one format so a consistent background can be applied, or
  • write some code! (This is what we’ll be doing!)

In this blog entry I’ll use the slide templates from project two into the book ‘More Eric Meyer on CSS’ (by Eric Meyer). You can get the files here. Also, the book is highly recommended.

As you can see, Eric has done a really nice job of creating a great set of formatting that really does look like slides on a lightbox. However, there is a big problem. We need to know beforehand about the shape, portrait or landscape of each slide.

Here’s the (unwrapped) css formatting magic that Eric uses:

body {background: #EED; margin: 1em;}
div#footer {clear: both; padding-top: 3em;
font: 85% Verdana, sans-serif;}
div.pic {float: left; height: 130px; width: 130px;
padding: 15px; margin: 5px 3px;
background: url(frame-ls.gif) center no-repeat;}
div.pt {background-image: url(frame-pt.gif);}
div.pic img {border: 1px solid; border-color: #444 #AAA #AAA #444;}
div.ls img {height: 96px; width: 128px; margin: 16px 0;}
div.pt img {height: 128px; width: 96px; margin: 0 16px;}
div.pic ul {display: none;}

As you can see, we have a div.ls and a div.ps to be used for landscape and portrait images respectively.

This code does great formatting, but has the big problem that you need to set up each thumbnail individually. This is a problem when you are dealing with large numbers of images, or when generating sets of a few random images from a large list of images.

I’m going to take the approach of shimming in some Javascript to looks at the images and pick the appropriate div formatting dynamically as the page loads.

Lets take a look at the required Javascript.

// ::slide_frame()
// Use the correct slide frame for loaded images
// This gets called when the body is loaded.

function slide_frame() {
// Get slide divs in document
slides = document.getElementsByName( “slide” );

// Iterate over all the slides
count = slides.length;
for( i=0 ; i

// Get child img, we need this to handle any whitespace
// in the div.
for( node=0 ; length > node ; ++node ) {
if( slides[i].childNodes[node].className == ‘flh’ ) {
pic = slides[i].childNodes[node];
break;
}
}

// Set offset of image within slide (In this case I hardcoded to the slide size)
w = (160 – pic.width) / 2;
h = (160 – pic.height)/ 2;
pic.style.margin= h + “px ” + w + “px ” + h + “px ” + w + “px “;
pic.style.border=”1px dotted black”;

// Check aspect ratio of thumbnail
if( pic.width > pic.height ) {

// Give it a landscape slide background
slides[i].style.background=”url(‘frame-ls.gif’)”;
}
}
}
The Javascript should be pretty clear as all it does is switch the background property of the slide div.

Now all we need to do is construct some slides to display, and attach the slide_frame() code to the onLoad event of the document body.

Click here for an example of this in action.