projects
/
plack-app-gruntmaster.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
102e5f4
)
Do not request server time when page has no timers
author
Marius Gavrilescu
<marius@ieval.ro>
Sat, 18 Apr 2015 08:07:36 +0000
(11:07 +0300)
committer
Marius Gavrilescu
<marius@ieval.ro>
Sat, 18 Apr 2015 08:52:00 +0000
(11:52 +0300)
js/90-timers.js
patch
|
blob
|
blame
|
history
diff --git
a/js/90-timers.js
b/js/90-timers.js
index e03ae08dcf3171a13ad872225f1a94da512d0efa..c9b095039873c84b3f886eaaac06c2b48ee510d7 100644
(file)
--- a/
js/90-timers.js
+++ b/
js/90-timers.js
@@
-30,12
+30,14
@@
$(() => {
update_timer(item);
setInterval(() => update_timer(item), 1000);
});
update_timer(item);
setInterval(() => update_timer(item), 1000);
});
- let xhr = new XMLHttpRequest();
- xhr.open('HEAD', '/');
- xhr.onload = () => {
- let srvtime = Date.parse(xhr.getResponseHeader('Date'));
- offset = Math.ceil((srvtime - Date.now()) / 1000);
- console.log("Offset from server: " + offset);
- };
- xhr.send();
+ if($('.timer').length > 0) {
+ let xhr = new XMLHttpRequest();
+ xhr.open('HEAD', '/');
+ xhr.onload = () => {
+ let srvtime = Date.parse(xhr.getResponseHeader('Date'));
+ offset = Math.ceil((srvtime - Date.now()) / 1000);
+ console.log("Offset from server: " + offset);
+ };
+ xhr.send();
+ }
});
});
This page took
0.010407 seconds
and
4
git commands to generate.