Added save indicator in the options page in Gecko

Firefox doesn't allow extensions to close the options page via
window.close, so this commit adds a "Saved" message each time the
options are saved.

In Chromium, the behavior continues to be the same as before (the
options page is closed after saving the changes).

Change-Id: I4f313f382b527e205ba1dc9976af53cb13a0cba6
diff --git a/src/options.js b/src/options.js
index 5f965b9..49bc2ec 100644
--- a/src/options.js
+++ b/src/options.js
@@ -24,6 +24,8 @@
   'batchduplicate',
 ];
 
+var savedSuccessfullyTimeout = null;
+
 function cleanUpOptions(options) {
   var ok = true;
   for (const [opt, value] of Object.entries(defaultOptions)) {
@@ -50,6 +52,16 @@
 
   chrome.storage.sync.set(options, function() {
     window.close();
+
+    // In browsers like Firefox window.close is not supported:
+    if (savedSuccessfullyTimeout !== null)
+      window.clearTimeout(savedSuccessfullyTimeout);
+
+    document.getElementById('save-indicator').innerText =
+        '✓ ' + chrome.i18n.getMessage('options_saved');
+    savedSuccessfullyTimeout = window.setTimeout(_ => {
+      document.getElementById('save-indicator').innerText = '';
+    }, 3699);
   });
 }