]> git.wh0rd.org - chrome-ext/clearhistory-advance-fork.git/commitdiff
options: move unique functions in here
authorMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 15:04:53 +0000 (20:49 +0545)
committerMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 15:04:53 +0000 (20:49 +0545)
Nothing else uses these, so move them over to avoid having to export+import.

javascript/options.js
javascript/util.js

index c4ffda4634b32cc5255b86a395d4df369a25bbf1..e5d53ec5de7f1b5f2d13ad31e717b045a3aa6ceb 100644 (file)
@@ -7,6 +7,34 @@
 
 window.addEventListener('load', init, false);
 
+/**
+ * Pours the data in template string.
+ * @param {Object} datObject The data object to be filled in template string.
+ * @return {string} The new string created from template string and filled
+ *     with the given data.
+ */
+String.prototype.supplant = function(datObject) {
+  return this.replace(/{([^{}]*)}/g,
+    function(match, firstSubMatch) {
+      var replace = datObject[firstSubMatch];
+      return (typeof replace === 'string' || typeof replace === 'number') ?
+          replace : match;
+    });
+};
+
+/**
+ * Queries the DOM.
+ * @param {string} selector Selector to execute.
+ * @param {HTMLElement=} context HTMLElement to query (optional).
+ * @return {Array.<HTMLElement>} Array of matched elements (non-live).
+ */
+function $(selector, context) {
+  if (!(context && context instanceof HTMLElement)) {
+    context = document;
+  }
+  return Array.prototype.slice.call(context.querySelectorAll(selector));
+}
+
 /**
  * Initializes the i18n strings.
  * Loads values from localStorage and applies them to the elements
index a428b3b7af768f28757091ba982ebbdcb2918951..6a233b5a04424f05d0dd3972bff26c4a25bc1494 100644 (file)
@@ -4,34 +4,6 @@
  * @fileoverview Some basic, useful utility functions.
  */
 
-/**
- * Pours the data in template string.
- * @param {Object} datObject The data object to be filled in template string.
- * @return {string} The new string created from template string and filled
- *     with the given data.
- */
-String.prototype.supplant = function(datObject) {
-  return this.replace(/{([^{}]*)}/g,
-    function(match, firstSubMatch) {
-      var replace = datObject[firstSubMatch];
-      return (typeof replace === 'string' || typeof replace === 'number') ?
-          replace : match;
-    });
-};
-
-/**
- * Queries the DOM.
- * @param {string} selector Selector to execute.
- * @param {HTMLElement=} context HTMLElement to query (optional).
- * @return {Array.<HTMLElement>} Array of matched elements (non-live).
- */
-function $(selector, context) {
-  if (!(context && context instanceof HTMLElement)) {
-    context = document;
-  }
-  return Array.prototype.slice.call(context.querySelectorAll(selector));
-}
-
 /**
  * Provides units for time, given in hours, as hours or days.
  * @param {number} time The time, in hours.