Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Real time counter!?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
IM



Joined: 19 Jun 2004
Posts: 42
Location: Zagreb, Hrvatska

PostPosted: 15.04.2005 08:26    Post subject: Real time counter!? Add user to your forum ignore list Reply with quote

Evo ovako, odite na Deviantart, vidite ovaj brojač koji imaju koji broji pristigle radove, radi u realnom vremenu, bez refresha. Kako to izvesti, malo sam im gledao source code, mislim da koriste neki javascript, evo ga:

Code:
//<![CDATA[
    try{
        var Deviations=11557203,DevCount,DevTimes=("1 0 1 1 0 6 0 1 5 0 3 4 0 0 2 8 3 0 2 3 2 1 1 1 1 1 3 0 2 0 7 0 0 5 3").split(" "),iDev=0;
        DevCount=document.getElementById("devlove");
        function Deviate(){
            var r;
            DevCount.childNodes[0].nodeValue = prettyNumber(Deviations++)+" deviations";
            r=DevTimes[iDev++];
            if(iDev==DevTimes.length)iDev=0;
            r*=1000;
            r+=Math.random()*100+(r?-50:Math.random()*500); // Fluctuate, since given times are rounded
            window.setTimeout("Deviate();",r);
        }
        Deviate();
    }catch(e){}
    //]]>


Neznam jeli ovo stvarno javascript, može li mi netko malo pojasniti kod, htio bih nešto slično izvesti na mom siteu. Very Happy Confused
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 24.04.2005 01:32    Post subject: Add user to your forum ignore list Reply with quote

Odi na gmail.google.com pa tamo ukradi onaj sto broji megabajte storagea... Isti kua...

A ovdje gore nisi pejstao cijelu skriptu, fali nekoliko dijelova vjerojatno...
Back to top
View user's profile Send private message Visit poster's website Twitter profile
IM



Joined: 19 Jun 2004
Posts: 42
Location: Zagreb, Hrvatska

PostPosted: 24.04.2005 08:04    Post subject: Add user to your forum ignore list Reply with quote

Evo, ovo se includa na mjesto gdje treba biti brojac:
Code:

<!--
quota = el("quota");
updateQuota();
// -->


a ovo su funkcije:

Code:

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 = 'Over ' + 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);
  }
}


function el(id) {
  if (document.getElementById) {
    return document.getElementById(id);
  } else if (window[id]) {
    return window[id];
  }
  return null;
}
var PAD = '.000000';


samo što ja i dalje ne kužim od kud on uzima varijablu za brojač, itd. Općenito kako stvar funkcionira...[/code]
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 24.04.2005 15:51    Post subject: Add user to your forum ignore list Reply with quote

I opet si propustio ono najbitnije:
Code:
var CP = [
 [ 1112439600000, 2050 ],
 [ 1114308000000, 2125 ]
];

Sto predstavlja datum i kolicinu storage-a s kojima se barata...

Al cijelo vrijeme samo barata sa tim podacima unutra i trenutnim timestampom...
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group