// This script is used to create a vertical scrolling event box, that pulls its // data via AJAX from a datafile on the server. // // (09/22/2006) //Copyright 2006 Computer Magic And Software Design //http://www.cmagic.biz //===============================================================// //= Script settings =// //===============================================================// var scrollspeed = 1; // Scrolling rate. var swidth = "490px"; // Width of the scroller box. var sheight = "18px"; // Height of the scroller box. var contents = "

Loading Events...

"; // Contents of the scroller box at start. var datfile = "/tusa/includes/Scroller/get_events.php"; // Datafile to pull events from, this file is written in HTML. //===============================================================// // Variables. var scroll, nsscroll; // Handle to scroller box. var real_height= ''; // The true height of the scroller box after offsets. var iedocm = document.all||document.getElementById; // Handle to document manager. // AJAX flags and variables. var newcontent = false; var newcontenttext = ''; var http = false; // Prevent from grabbing ajax stuff again var pulled = false; var loaded = false; var orig_scroll_speed = scrollspeed; // Turn off scrolling when showing the loading screen scrollspeed=0; var orig_sheight = sheight; // Scroll Offset var scroll_rate = 1; // Timeout speed var timeout_speed = 90; function waitingcontent() { if(http.readyState == 4) { newcontent = true; newcontenttext = http.responseText; } else { newcontent = false; } } function pull_contents() { if (pulled == true) { return; } if (navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP") } else { http = new XMLHttpRequest(); } http.open("GET", datfile, true); http.onreadystatechange = waitingcontent; http.send(null); pulled = true; } function set_contents() { contents = newcontenttext; newcontent = false; if (iedocm) { scroll.innerHTML = contents; real_height = scroll.offsetHeight; scroll.style.top = parseInt(sheight) + scroll_rate + "px"; } else if (document.layers) { nsscroll.document.write(contents); nsscroll.document.close(); real_height = nsscroll.document.height; nsscroll.top = parseInt(sheight) + scroll_rate; } } // Used to fill the information into the scroller body, and get everything ready to go. function init_scroller() { if (iedocm) { scroll = document.getElementById ? document.getElementById("myscroller") : document.all.myscroller; //scroll.style.top = parseInt(sheight) + scroll_rate + "px"; scroll.style.top = 0; scroll.innerHTML = contents; real_height = scroll.offsetHeight; } else if (document.layers) { nsscroll = document.nsmyscroller.document.nsmyscroller2; //nsscroll.top = parseInt(sheight) + scroll_rate; nsscroll.top = 0; nsscroll.document.write(contents); nsscroll.document.close(); real_height = nsscroll.document.height; } // Start the first data pull. pull_contents(); // Use a timer to make scroller box scroll. timeleft = setInterval ("scroll_it()", timeout_speed); //pulltime = setInterval ("pull_contents()", 1) } // Force scroller Init on page load. //window.onload = init_scroller // Used to make the scroller box actually scroll. function scroll_it() { if (loaded != true && newcontent==true) { // Get rid of the loading screen asap set_contents(); scrollspeed=orig_scroll_speed; } sheight = orig_sheight; if(iedocm) { real_height = scroll.offsetHeight; //document.all['debug'].value = 'Real Height: ' + real_height + ' Top: ' + scroll.style.top + ' SHeight: ' + sheight; //if(parseInt(scroll.style.top) > (real_height * (-1) + scroll_rate)) { if(parseInt(scroll.style.top) > (real_height + scroll_rate) * -1) { scroll.style.top = parseInt(scroll.style.top)-scrollspeed+"px"; } else { // Get the new contents and output them. if (newcontent) { // alert('NewContent'); set_contents(); } scroll.style.top = parseInt(sheight)+scroll_rate+"px"; //alert('SHeight: ' + sheight + ' Top: ' + scroll.style.top + ' Scroll Rate: ' + scroll_rate); } } else if (document.layers) { real_height = nsscroll.document.height; if (nsscroll.top > (real_height + scroll_rate) * -1) { nsscroll.top -= Math.max(1, scrollspeed-1); } else { //pull_contents(); if (newcontent) { set_contents(); } nsscroll.top = parseInt(sheight) + scroll_rate; } } } function insert_scroller() { if (iedocm || document.layers) { with (document) { if (iedocm) { write('
'); write('
'); write('
'); write('
'); //write(''); } else if (document.layers) { write('/table>'); } } } } insert_scroller(); init_scroller();
'); write(''); write(''); write('