]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/commitdiff
convert JS to ES6 modules
authorMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 15:20:57 +0000 (21:05 +0545)
committerMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 15:20:57 +0000 (21:05 +0545)
Makefile
javascript/background.js
javascript/clearhistory.js
javascript/options.js
javascript/util.js
manifest.files
manifest.json
views/background.html [new file with mode: 0644]
views/options.html

index 47d1a38d18ba7c2dbdc2af0fb0f792a2d017a777..be698a6dca90cb6be09e67abd42c9bd51b39a0c5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
-CLOSURE = closure-compiler --language_in ECMASCRIPT5
+CLOSURE = closure-compiler --language_in ECMASCRIPT_2020
+CLOSURE = cat
 YUICOMPRESSOR = yuicompressor
 
 all:
index 9473cdaa6c40b99fd28d4d2b4e5c31c9bc2b83f3..77069e8cf506e32bf00125d7dc645fd4b2a549a8 100644 (file)
@@ -5,7 +5,7 @@
  * @author arunjit@google.com (Arunjit Singh)
  */
 
-var CONSTANTS = {
+export const CONSTANTS = {
   /**
    * The available time ranges (in hours). -1 => eternity.
    * @type {Array.<number>}
index a8cad41640e15f00e6687d612886d5ce8bcca181..6cfa78562e94de461488ec642c1ce8bb13e4c0c1 100644 (file)
@@ -5,6 +5,9 @@
  * @author arunjit@google.com (Arunjit Singh)
  */
 
+import {CONSTANTS} from './background.js';
+import {getUnitsForTime} from './util.js';
+
 function getClearDate(s) {
   var time = ~~(s.time) || CONSTANTS.DEFAULT_TIME;
   if (time == -1)
index e5d53ec5de7f1b5f2d13ad31e717b045a3aa6ceb..5f81fea950eeca9e347e52c3ca531e231a1e388f 100644 (file)
@@ -5,6 +5,9 @@
  * @author arunjit@google.com (Arunjit Singh)
  */
 
+import {CONSTANTS} from './background.js';
+import {getUnitsForTime} from './util.js';
+
 window.addEventListener('load', init, false);
 
 /**
index 6a233b5a04424f05d0dd3972bff26c4a25bc1494..c56589f951c53ac044d2a75b552c45cec1dc3b15 100644 (file)
@@ -9,7 +9,7 @@
  * @param {number} time The time, in hours.
  * @return {Object} The time and units of time (pluralized and localized).
  */
-function getUnitsForTime(time) {
+export function getUnitsForTime(time) {
   var units = 'hour';
   if (time >= 24) {
     units = 'day';
index 64a52aedf459bb84df4469f7864002a1af331bcf..b9a3a9b59154005957773e7e6afff863eb9668e4 100644 (file)
@@ -9,4 +9,5 @@ javascript/background.js
 javascript/clearhistory.js
 javascript/options.js
 javascript/util.js
+views/background.html
 views/options.html
index 2904a3f5b6b2df0ff5155ee57525ea7ad742c3ad..5094d6e6c477f8b8f2b072ddcf2ea7afaa8fea62 100644 (file)
   ],
   "background": {
     "persistent": false,
-    "scripts": [
-      "javascript/background.js",
-      "javascript/util.js",
-      "javascript/clearhistory.js"
-    ]
+    "page": "views/background.html"
   },
   "options_page": "views/options.html",
   "browser_action": {
diff --git a/views/background.html b/views/background.html
new file mode 100644 (file)
index 0000000..1a6a1d5
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset='utf-8'/>
+    <script type='module' src='../javascript/clearhistory.js'></script>
+  </head>
+</html>
index 78373245a7d0ab7c250f89868c407f1191a84e47..69ad9677f0c289e537f1254549bb695fd568e664 100644 (file)
 
   </div>
 
-    <script src="../javascript/background.js"></script>
-    <script src="../javascript/util.js"></script>
-    <script src="../javascript/options.js"></script>
+    <script type="module" src="../javascript/options.js"></script>
   </body>
 </html>