OLD | NEW |
| (Empty) |
1 const updateTime = { | |
2 display: function() { | |
3 var elements = document.getElementsByClassName('update_time'); | |
4 for(i = 0; i < elements.length; i++) { | |
5 var key = elements[i].parentNode.id; | |
6 if(preferences.exist(key + '-time')) { | |
7 var difference = getTime() - preferences.int(key
+ '-time'); | |
8 elements[i].innerHTML = ' ' + this.string(differ
ence); | |
9 } | |
10 else { | |
11 elements[i].innerHTML = ' ' + translate.get('upd
ate_just'); | |
12 } | |
13 } | |
14 }, | |
15 string: function(time) { | |
16 if(time < 60000) //< 1 minute | |
17 return (translate.get('update_just')); | |
18 if(time < 2*60000) //< 2 minutes | |
19 return (translate.get('update_minute')); | |
20 if(time < 60*60000) //< 1 hour | |
21 return (translate.get('update_minutes')).replace(/%/, Ma
th.floor(time / (60000))); | |
22 if(time < 2*60*60000) //< 2 hours | |
23 return (translate.get('update_hour')); | |
24 if(time < 24*60*60000) //< 1 day | |
25 return (translate.get('update_hours')).replace(/%/, Math
.floor(time / (60*60000))); | |
26 if(time < 2*24*60*60000) //< 2 days | |
27 return (translate.get('update_day')); | |
28 if(time < 30*24*60*60000) //< 1 month | |
29 return (translate.get('update_days')).replace(/%/, Math.
floor(time / (24*60*60000))); | |
30 else //> 1 month | |
31 return (translate.get('update_old')); | |
32 } | |
33 }; | |
34 | |
35 updateTime.display(); | |
36 window.setInterval("updateTime.display();", 5000) | |
OLD | NEW |