瀏覽代碼

defined constant

Former-commit-id: bcb84fabec6910990ce2106c82437c4e359730a9
Gildas 6 年之前
父節點
當前提交
d9ffcd901a
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      extension/core/content/content-bootstrap.js

+ 5 - 3
extension/core/content/content-bootstrap.js

@@ -27,6 +27,8 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 
 	const singlefile = this.singlefile;
 
+	const PUSH_STATE_NOTIFICATION_EVENT_NAME = "single-file-push-state";
+
 	let unloadListenerAdded, options, autoSaveEnabled, autoSaveTimeout, autoSavingPage, pageAutoSaved;
 	singlefile.extension.core.content.updatedResources = {};
 	browser.runtime.sendMessage({ method: "autosave.init" }).then(message => {
@@ -36,7 +38,7 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 	});
 	browser.runtime.onMessage.addListener(message => { onMessage(message); });
 	browser.runtime.sendMessage({ method: "ui.processInit" });
-	addEventListener("single-file-push-state", () => browser.runtime.sendMessage({ method: "ui.processInit" }));
+	addEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, () => browser.runtime.sendMessage({ method: "ui.processInit" }));
 	return {};
 
 	async function onMessage(message) {
@@ -95,12 +97,12 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 		if (autoSaveEnabled && options && (options.autoSaveUnload || options.autoSaveLoadOrUnload)) {
 			if (!unloadListenerAdded) {
 				addEventListener("unload", onUnload);
-				addEventListener("single-file-push-state", onUnload);
+				addEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, onUnload);
 				unloadListenerAdded = true;
 			}
 		} else {
 			removeEventListener("unload", onUnload);
-			removeEventListener("single-file-push-state", onUnload);
+			removeEventListener(PUSH_STATE_NOTIFICATION_EVENT_NAME, onUnload);
 			unloadListenerAdded = false;
 		}
 	}