Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: options/time.js

Issue 8493027: Acquired Opera AdBlock code (Closed)
Patch Set: Created Oct. 8, 2012, 5:58 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « options/privacy.js ('k') | options/whitelist.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « options/privacy.js ('k') | options/whitelist.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld