Article View: pl.comp.lang.javascript
Article #49813Optymalizacja kodu
From: Stefan
Date: Sat, 13 Feb 2010 19:36
Date: Sat, 13 Feb 2010 19:36
33 lines
1500 bytes
1500 bytes
Jest sobie taki kod: http://pastebin.ca/1795545
==
var cosTam = {
lastRefresh : 0,
autoRefresh : function(){
var dateobj=new Date();
if (dateobj.getTime()-cosTam.lastRefresh>10000) {
cosTam.lastRefresh=dateobj.getTime();
cosTam.refresh();
}
},
refresh : function () {
// ....
}
}
$(document).focus(cosTam.autoRefresh);
==
Jako ze event focus jest wywolywany przy kazdym kliknieciu mysza,
podpiety pod to zdarzenie autoRefresh pilnuje aby nie dokonywac dzialan
czesciej niz co 10 sekund.
Pytanie jest o linie
var dateobj=new Date()
Czy inicjalizacja powinna byc przeniesiona 2 linie wyzej, do deklaracji
obiektu cosTam?
Technical Details
Message-ID:
<hl6uvr$niu$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.gazeta.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.gazeta.pl!not-for-mail From: Stefan <stefan@costam.wp.pl> Newsgroups: pl.comp.lang.javascript Subject: Optymalizacja kodu Date: Sat, 13 Feb 2010 20:36:27 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 33 Message-ID: <hl6uvr$niu$1@inews.gazeta.pl> NNTP-Posting-Host: aaej225.neoplus.adsl.tpnet.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1266089787 24158 83.4.113.225 (13 Feb 2010 19:36:27 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Sat, 13 Feb 2010 19:36:27 +0000 (UTC) X-User: uboh4cho User-Agent: Thunderbird 2.0.0.23 (X11/20090817) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit