Andrew Bedno
AndrewBedno.com  •  Andrew@Bedno.com  •  773-442-2386
 History   Kudos   Samples 

JavaScript
November -0001 - November -0001
JavaScript (click for next photo)


Randomly generates and speaks moves for the popular "Twister" game for playing without a spinner.
Also download my library of JavaScript date, calendar, and cookie related functions for creating active web pages.

<SCRIPT LANGUAGE=JAVASCRIPT TYPE='TEXT/JAVASCRIPT'>
// Get args for previous spin, seconds and repeats, defaulting if unset.
// Calculate next spin and set cookies.
// Embed current spin sound.
// Render dynamic page portion, showing current spin graphics and text.
// Output remainder of page, showing graphics, instructions, links, etc.
function GetArg(ga_name) {
  var ga_start=location.search.indexOf("?"+ga_name+"=");
  if (ga_start<0) ga_start=location.search.indexOf("&"+ga_name+"=");
  if (ga_start<0) return '';
  ga_start += ga_name.length+2;
  var ga_end=location.search.indexOf("&",ga_start)-1;
  if (ga_end<0) ga_end=location.search.length;
  var ga_result=location.search.substring(ga_start,ga_end);
  var ga_result='';
  for(var ga_i=ga_start; ga_i<=ga_end; ga_i++) {
    var ga_c=location.search.charAt(ga_i);
    ga_result=ga_result+(ga_c=='+'?' ':ga_c);
  }
  return unescape(ga_result);
}
SpinCodes = new Array(
  "lfb", "lfg", "lfr", "lfy",
  "lhb", "lhg", "lhr", "lhy",
  "rfb", "rfg", "rfr", "rfy",
  "rhb", "rhg", "rhr", "rhy" );
SpinDescs = new Array(
  "Left Foot Blue", "Left Foot Green", "Left Foot Red", "Left Foot Yellow",
  "Left Hand Blue", "Left Hand Green", "Left Hand Red", "Left Hand Yellow",
  "Right Foot Blue", "Right Foot Green", "Right Foot Red", "Right Foot Yellow",
  "Right Hand Blue", "Right Hand Green", "Right Hand Red", "Right Hand Yellow" );
SpinColors = new Array(
  "Blue", "Green", "Red", "Yellow",
  "Blue", "Green", "Red", "Yellow",
  "Blue", "Green", "Red", "Yellow",
  "Blue", "Green", "Red", "Yellow" );
var spin_prev = GetArg("p");
var spin_secs = GetArg("t");
if ( (spin_secs == "") || (spin_secs < 3) || (spin_secs > 300) ) { spin_secs = 12; }
var spin_reps = GetArg("r");
if ( (spin_reps == "") || (spin_reps < 1) || (spin_reps > 10) ) { spin_reps = 2; }
var spin_num = -1;
var spin_code = "";
do {
  spin_num = Math.floor(Math.random() * 16);
  if ( (spin_num >= 0) && (spin_num <= 15) ) spin_code = SpinCodes[spin_num];
} while ( (spin_code == "") || (spin_code == spin_prev) );
var spin_desc = SpinDescs[spin_num];
var spin_color = SpinColors[spin_num];
document.write("<bgsound src='"+spin_code+".wav' loop='"+spin_reps+"'>\n");
function PageRefresh() {
  top.location.href = "index.htm?p="+spin_code+"&t="+spin_secs+"&r="+spin_reps;
}
setTimeout("PageRefresh()",(spin_secs*1000));


CLIPPED...



 MEDIA   DOWNLOAD         < NEWER       OLDER > 

2004.01.01