// WebBrick Javascript API version 1.0 // Amnon Silverstein, Feb 2001 /// Setup variables // PUT YOUR URL HERE var WebBrickURL="http://" + myip + ":7070/"; var Attempts = 20; // Number of attempts to reach the WebBrick server var TryFor_msec = 500; // msec per wait for reply /// Global variables var DataImage = new Image(); var Timeout=0; var Sensor=0; Queue_Tasks=new Array(); Queue_Active=0; AlphaCodes="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /////////////////////////////////// ///// WebBrick Helper Functions ///// You probably want to keep these. function GetNumber(){ return ((DataImage.width-1)+(DataImage.height-1)*256*256); } function TryReading(OnReading,OnFailure){ Timeout++; if (Timeout>Attempts){ Timeout=0; eval(OnFailure); ClearQueue(); // Cleans out the queue until the problem can be solved } else if (DataImage.complete){ Reading=GetNumber(); Timeout=0; eval(OnReading); Queue(); // Runs the next task in the queue } else window.setTimeout("TryReading("+Freeze(OnReading)+","+Freeze(OnFailure)+")",TryFor_msec); } function AlertFailure(){ // This code runs when the reading fails, by default // You can increase the number of connect attempts if you like. } function Freeze(task){ // Inverse of Eval // eval(Freeze(foo)) => foo // Converts a task into a string that can later be evaled // replace every " with \" // replace every \ with \\ quote = '"'; slash = '\\'; i=0; while (i
Hosted by www.Geocities.ws

1