From: Mike Frysinger Date: Fri, 7 Oct 2022 15:20:57 +0000 (+0545) Subject: convert JS to ES6 modules X-Git-Tag: v2.0~2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=c930a5d63083025d1ffe5dc29b08583b9ff44049;p=chrome-ext%2Fclearhistory-advance-fork.git convert JS to ES6 modules --- diff --git a/Makefile b/Makefile index 47d1a38..be698a6 100644 --- 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: diff --git a/javascript/background.js b/javascript/background.js index 9473cda..77069e8 100644 --- a/javascript/background.js +++ b/javascript/background.js @@ -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.} diff --git a/javascript/clearhistory.js b/javascript/clearhistory.js index a8cad41..6cfa785 100644 --- a/javascript/clearhistory.js +++ b/javascript/clearhistory.js @@ -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) diff --git a/javascript/options.js b/javascript/options.js index e5d53ec..5f81fea 100644 --- a/javascript/options.js +++ b/javascript/options.js @@ -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); /** diff --git a/javascript/util.js b/javascript/util.js index 6a233b5..c56589f 100644 --- a/javascript/util.js +++ b/javascript/util.js @@ -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'; diff --git a/manifest.files b/manifest.files index 64a52ae..b9a3a9b 100644 --- a/manifest.files +++ b/manifest.files @@ -9,4 +9,5 @@ javascript/background.js javascript/clearhistory.js javascript/options.js javascript/util.js +views/background.html views/options.html diff --git a/manifest.json b/manifest.json index 2904a3f..5094d6e 100644 --- a/manifest.json +++ b/manifest.json @@ -17,11 +17,7 @@ ], "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 index 0000000..1a6a1d5 --- /dev/null +++ b/views/background.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/views/options.html b/views/options.html index 7837324..69ad967 100644 --- a/views/options.html +++ b/views/options.html @@ -148,8 +148,6 @@ - - - +