SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to Edit Prototype 1.4 to 1.5

    Hey all.

    I have been looking around for a perodic refresh that I could implement to update a DIV in my site every 5 seconds. And I did with the little example from AjaxPatterns.

    However while implementing it with Prototype 1.5 It has seemed to die.
    (In IE.) In Firefox everything works like a charm.

    I was wondering if someone could tell my my flaw and maybe help me through it.

    (Here is a copy of the code from time2.js)

    PHP Code:
    ajaxCaller.shouldDebug false;
    var 
    timeURL "bars.php";
    var 
    running true;
    var 
    REFRESH_PERIOD 2000;
    var 
    TIMEOUT_TIME 30000;
    var 
    refreshTimer;
    var 
    warningTimer;
    var 
    timeoutTimer;

    window.onload = function() {
      
    document.getElementsByTagName("body")[0].onmouseover = function(event) {
        
    renewSession();
      }
      $(
    "defaultTime").onclick=function() {
        
    renewSession();
        
    requestDefaultTime();
      }
      $(
    "customTime").onclick=function() {
        
    renewSession();
        
    requestCustomTime;
      }
      
    requestBothTimes();
      $(
    "timeoutMessage").style.display "none";
      
    refreshTimer setInterval(requestBothTimesREFRESH_PERIOD);
      
    timeoutTimer setTimeout(onTimeoutTIMEOUT_TIME);
    }

    function 
    requestBothTimes() {
      
    requestDefaultTime();
      
    requestCustomTime();
    }

    function 
    requestDefaultTime() {
      
    ajaxCaller.getPlainText(timeURLshowDefaultTime);
    }

    function 
    showDefaultTime(text) {
      var 
    defaultTimeLabel = $("defaultTimeLabel");
      
    defaultTimeLabel.innerHTML text;
    }

    function 
    requestCustomTime() {
      var 
    vars = new Array();
      
    vars["showWeekday"]=0;
      
    vars["showTimezone"]=0;
      
    vars["showYear"]=1;
      var 
    callingContext Math.round(Math.random() * 100);
      
    ajaxCaller.get(timeURLvarsshowCustomTimefalsecallingContext);
    }

    function 
    showCustomTime(textcallingContext) {
      var 
    customTimeLabel = $("customTimeLabel");
      
    customTimeLabel.innerHTML text "." callingContext;
    }

    function 
    onTimeout() {
      new 
    Effect.BlindDown($("timeoutMessage"));
      
    clearInterval(refreshTimer);
    }

    function 
    renewSession() {
      
    clearInterval(timeoutTimer);
      
    timeoutTimer setTimeout(onTimeoutTIMEOUT_TIME);

    Thank you,
    -Jim

    Update: Ie never mind! I found prototypes update function.
    Now I jsut must figure out how to get a timeout going.

    Thanks!
    Last edited by Datawalke; Jun 26, 2006 at 12:34. Reason: Mistype


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •