Advanced Search

Results 1 to 4 of 4

Thread: Looking for a simple script or some basic advice

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Looking for a simple script or some basic advice

    Hello DD!
    First off I am new here so hello all you regulars. This website has been useful to me for years now.

    My Question:
    I am looking for a simple script that I can modify that automatically increments a number while the page is loaded. Similar to the number located under "Lots of space" on http://gmail.com when your not logged into an account.
    I looked all over the site and found nothing, I just finished a class on perl, html/css, and just started one on php. I know the basic syntax of most languages but I need to make this in javascript for what I need to accomplish.

    Thanks in advance

  2. #2
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    try doing this.. just look at their javascript and copy it...

    what I do when i want to know something I take the whole page, fix the urls so they are complete urls then I start taking code by code out until what I want it works...

    Code:
    <script type=text/javascript src="https://mail.google.com/mail?view=page&name=browser"></script>
    <script type=text/javascript>
    <!--
    
    var start_time = (new Date()).getTime();
    
    if ((top.location != self.location)&&(top.location.href.indexOf('https://www.google.com/analytics/siteopt/preview')!=0)) {
     top.location = self.location.href;
    }
    
    function SetGmailCookie(name, value) {
      document.cookie = name + "=" + value + ";path=/;domain=.google.com";
    }
    
    function lg() {
      var now = (new Date()).getTime();
    
      var cookie = "T" + start_time + "/" + start_time + "/" + now;
      SetGmailCookie("GMAIL_LOGIN", cookie);
    }
    
    function gaiacb_onLoginSubmit() {
      lg();
      if (!fixed) {
        FixForm();
      }
      return true;
    }
    
    function StripParam(url, param) {
      var start = url.indexOf(param);
      if (start == -1) return url;
      var end = start + param.length;
    
      var charBefore = url.charAt(start-1);
      if (charBefore != '?' && charBefore != '&') return url;
    
      var charAfter = (url.length >= end+1) ? url.charAt(end) : '';
      if (charAfter != '' && charAfter != '&') return url;
      if (charBefore == '&') {
      --start;
      } else if (charAfter == '&') {
      ++end;
      }
      return url.substring(0, start) + url.substring(end);
    }
    var fixed = 0;
    function FixForm() {
      if (is_browser_supported) {
      var form = el("gaia_loginform");
      if (form && form["continue"]) {
      var url = form["continue"].value;
      url = StripParam(url, "ui=html");
      url = StripParam(url, "zy=l");
      form["continue"].value = url;
      }
      }
      fixed = 1;
    }
    function el(id) {
      if (document.getElementById) {
      return document.getElementById(id);
      } else if (window[id]) {
      return window[id];
      }
      return null;
    }
    // Estimates of nanite storage generation over time.
    var CP = [
     [ 1175414400000, 2835 ],
     [ 1192176000000, 2912 ],
     [ 1193122800000, 4321 ],
     [ 1199433600000, 6283 ],
     [ 2147328000000, 43008 ],
     [ 46893711600000, Number.MAX_VALUE ]
    ];
    var quota;
    var ONE_PX = "https://mail.google.com/mail/images/c.gif?t=" +
      (new Date()).getTime();
    function LogRoundtripTime() {
      var img = new Image();
      var start = (new Date()).getTime();
      img.onload = GetRoundtripTimeFunction(start);
      img.src = ONE_PX;
    }
    function GetRoundtripTimeFunction(start) {
      return function() {
      var end = (new Date()).getTime();
      SetGmailCookie("GMAIL_RTT", (end - start));
      }
    }
    function MaybePingUser() {
      var f = el("gaia_loginform");
      if (f.Email.value) {
      new Image().src = 'https://mail.google.com/mail?gxlu=' +
      encodeURIComponent(f.Email.value) +
      '&zx=' + (new Date().getTime());
      }
    }
    function OnLoad() {
      gaia_setFocus();
      MaybePingUser();
      el("gaia_loginform").Passwd.onfocus = MaybePingUser;
      LogRoundtripTime();
      if (!quota) {
      quota = el("quota");
      updateQuota();
      }
      LoadConversionScript();
    }
    function updateQuota() {
      if (!quota) {
      return;
      }
      var now = (new Date()).getTime();
      var i;
      for (i = 0; i < CP.length; i++) {
        if (now < CP[i][0]) {
          break;
        }
      }
      if (i == 0) {
        setTimeout(updateQuota, 1000); 
      } else if (i == CP.length) {
        quota.innerHTML = CP[i - 1][1];
      } else {
        var ts = CP[i - 1][0];
        var bs = CP[i - 1][1];
        quota.innerHTML = format(((now-ts) / (CP[i][0]-ts) * (CP[i][1]-bs)) + bs); 
        setTimeout(updateQuota, 1000); 
      } 
    } 
     
    var PAD = '.000000'; 
     
    function format(num) { 
      var str = String(num); 
      var dot = str.indexOf('.'); 
      if (dot < 0) { 
         return str + PAD; 
      } if (PAD.length > (str.length - dot)) {
      return str + PAD.substring(str.length - dot);
      } else {
      return str.substring(0, dot + PAD.length);
      }
    }
    var google_conversion_type = 'landing';
    var google_conversion_id = 1069902127;
    var google_conversion_language = "en_US";
    var google_conversion_format = "1";
    var google_conversion_color = "FFFFFF";
    function LoadConversionScript() {
      var script = document.createElement("script");
      script.type = "text/javascript";
      script.src = "https://www.googleadservices.com/pagead/conversion.js";
    }
    // -->
    </script>
    then add this..
    <span id=quota>2757.272164</span>

    not really sure if this is right...
    Hey new design new look, goto xudas for personal webdsign help.. (:

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Thanks for the advice but there is a lot of code I dont uderstand yet in that page, I couldn't work with it. I figure I will learn more by making this on my own.

    The script below just prints a number over and over incrementing it along the way. Now I have two more things I would like my code to be able to do.

    1. Instead of printing over and over I would like to just update the same text on the webpage. Similar to the incrementing space counter that can be found on gmail.com when your not logged into an account.

    2. I want to be able to slow down the rate at which the number is updating. I attempted to use setInterval() in my example but its not working. I also attempted to put the addition to numbero into a seperate function and called the function from SetInterval like this: setInterval("myotherfunction();",1000);
    That didn't seem to work either.

    Sorry to ask such lame questions but I am a total noob to javascript and I need to have this done by morning or my a$$ is grass

    Code:
    <html>
    <head>
    
    <script type = "text/javascript">
    var numbero = 500;
    </script>
    
    </head>
    <body>
    
    <script type = "text/javascript">
    
    while (numbero < 10000)
    {
     numbero = numbero + 1000;
     window.document.write(numbero);
     setInterval("",1000);
     window.document.write('<br>');
    }
    
    </script>
    </body>
    </html>

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Why not set a base number (say 500) and getDate(), then run a function based on the seconds that have passed.

    you could include a state for your buttons, ( a + and a - ) and on click will increment the value faster or slower?

    For example 500 + myDate.getSeconds(); *n = number shown incrementing when N=5.

    then the + button gives N +=1 and - button = N-=1??

    Not up on all the exact JS coding, but I use ActionScript which is basically the same thing.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

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
  •