[thelist] web site on a cd?

Jeff Howden jeff at jeffhowden.com
Wed Apr 2 08:49:30 CST 2003


simon,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Simon Hibbard
>
> Wondered if anyone out there may have any suggestions
> for something i have been asked to produce (if
> possible). Basically i developed a web site for a
> company intranet allowing the users to browse through
> thousands of images taken on comapany trips, add to a
> shopping cart and order.
>
> Now the this is all fine and works well - but they also
> have users who want to be able to order from home, and
> these users all use a company dial up which is slow
> anyway, and the fact that the site uses high quality
> images (so people can identify themselves) it is just
> too slow (fine on intranet as was designed for).
>
> So basically they have asked if i can porvide the same
> sort of system on a CD to give to employees only
> requiring it to access the intranet via remote access
> to pass info to the order form.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

i'd recommend against replicating the site and using a client-side cart.
instead, just replicate the organization of the images and burn those to cd.
on your intranet site, variablize the path to the images so the path can be
changed easily.  then, give the user a page where they can identify the cd
drive letter.  by choosing no drive letter they'll be using the images off
the intranet.  store the drive letter in a cookie or session variable on the
server.  in your application logic, if there's a drive letter then the
variable for the path to the images changes from something like /images/ to
file:///{drive letter}:/.  "magically" all the images on the site that you
want to offer on cd are suddenly being requested from their local cd drive
and should be near lightning fast.  the trick is making sure that the
organization/naming of the images on the intranet doesn't change once the cd
is burned.

to make this a truly smooth solution you'd want to implement a couple of
checks.  one, place a tiny javascript file on a pre-defined location on the
cd.  have an identical file on the intranet.  in your code, make the path
dynamic like you did for the images that are on the cd.  the path to this
.js file uses the same image path variable.  when they choose to browse
images off the cd, that path changes to follow suit.

<script language="JavaScript" type="text/javascript"
src="{pathvariable}/scripts/connection.js">

above this file you'll have an inline script block that'll have at the least
a single variable with a boolean value of false:

<script language="JavaScript" type="text/javascript">
<!--
  var isConnected = false;
// -->
</script>

in your .js file you'll set the isConnected variable to true.

now, write out the .js file include from above.

<script language="JavaScript" type="text/javascript"
src="{pathvariable}/scripts/connection.js">

now, write out another inline script block that does some checking on that
variable value.  if both a drive letter is chosen (evidence they want to
browse local instead of the intranet) and isConnected is false, throw an
alert to the user that they may not have the cd in the drive or they may
have selected an incorrect drive letter.

next, attach an onerror event handler to every <img> tag on your site
that'll reference images from the cd.  hopefully they're all the same size
or this could get interesting.  when the onerror event handler fires, check
to see if there's a drive letter.  if not, they're browsing the intranet and
you've got a broken image.  change the src of the image to a good path on
the intranet to a "sorry, image not found" image.  otherwise, if isConnected
is true, show an image off the intranet that says "the image you're trying
to view is newer than the cd you currently have.  please contact us for a
new cd".  alternatively, you could get really fancy and use the onload event
handler to check the path of the loaded image.  if it's to the "there's a
newer image on the intranet" image, pop a confirm() dialog asking them if
they'd like to view it off the intranet instead.  additionally, this could
be a preference they could make on the drive letter selection page in which
you wouldn't have to pop the confirm.  you'd simply show the one off the
intranet or not depending on their answer.

now, if isConnected is false, you'll want to use the onerror event handler
to change to an image on the intranet that tells the user the image can't be
displayed cause they didn't select the correct drive letter or the cd isn't
in the drive.

get all that?

.jeff

http://evolt.org/

NOTICE:  members.evolt.org web and email address are changing!
---------------------------------------------------------------------
| OLD:                            | NEW:                            |
| jeff at members.evolt.org          | evolt at jeffhowden.com            |
| http://members.evolt.org/jeff/  | http://evolt.jeffhowden.com/    |
---------------------------------------------------------------------





More information about the thelist mailing list