Index: options/time.js |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/options/time.js |
@@ -0,0 +1,36 @@ |
+const updateTime = { |
+ display: function() { |
+ var elements = document.getElementsByClassName('update_time'); |
+ for(i = 0; i < elements.length; i++) { |
+ var key = elements[i].parentNode.id; |
+ if(preferences.exist(key + '-time')) { |
+ var difference = getTime() - preferences.int(key + '-time'); |
+ elements[i].innerHTML = ' ' + this.string(difference); |
+ } |
+ else { |
+ elements[i].innerHTML = ' ' + translate.get('update_just'); |
+ } |
+ } |
+ }, |
+ string: function(time) { |
+ if(time < 60000) //< 1 minute |
+ return (translate.get('update_just')); |
+ if(time < 2*60000) //< 2 minutes |
+ return (translate.get('update_minute')); |
+ if(time < 60*60000) //< 1 hour |
+ return (translate.get('update_minutes')).replace(/%/, Math.floor(time / (60000))); |
+ if(time < 2*60*60000) //< 2 hours |
+ return (translate.get('update_hour')); |
+ if(time < 24*60*60000) //< 1 day |
+ return (translate.get('update_hours')).replace(/%/, Math.floor(time / (60*60000))); |
+ if(time < 2*24*60*60000) //< 2 days |
+ return (translate.get('update_day')); |
+ if(time < 30*24*60*60000) //< 1 month |
+ return (translate.get('update_days')).replace(/%/, Math.floor(time / (24*60*60000))); |
+ else //> 1 month |
+ return (translate.get('update_old')); |
+ } |
+}; |
+ |
+updateTime.display(); |
+window.setInterval("updateTime.display();", 5000) |