Przeglądaj źródła

renamed singlefile.ui.* method names

Gildas 7 lat temu
rodzic
commit
bf4f14235f
2 zmienionych plików z 15 dodań i 18 usunięć
  1. 9 12
      extension/core/scripts/bg/bg.js
  2. 6 6
      extension/ui/scripts/bg/ui.js

+ 9 - 12
extension/core/scripts/bg/bg.js

@@ -26,32 +26,29 @@
 
 	chrome.tabs.onActivated.addListener(activeInfo => chrome.tabs.get(activeInfo.tabId, tab => {
 		if (!chrome.runtime.lastError) {
-			singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url));
+			singlefile.ui.active(tab.id, isAllowedURL(tab.url));
 		}
 	}));
-	chrome.tabs.onCreated.addListener(tab => singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url)));
-	chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => singlefile.ui.notifyTabActive(tab.id, isAllowedURL(tab.url)));
-	chrome.tabs.onRemoved.addListener(tabId => singlefile.ui.notifyTabRemoved(tabId));
+	chrome.tabs.onCreated.addListener(tab => singlefile.ui.active(tab.id, isAllowedURL(tab.url)));
+	chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => singlefile.ui.active(tab.id, isAllowedURL(tab.url)));
+	chrome.tabs.onRemoved.addListener(tabId => singlefile.ui.removed(tabId));
 
 	chrome.runtime.onMessage.addListener((request, sender) => {
-		if (request.processStart) {
-			singlefile.ui.notifyProcessProgress(sender.tab.id, request.index, request.maxIndex);
-		}
-		if (request.processProgress) {
-			singlefile.ui.notifyProcessProgress(sender.tab.id, request.index, request.maxIndex);
+		if (request.processStart || request.processProgress) {
+			singlefile.ui.progress(sender.tab.id, request.index, request.maxIndex);
 		}
 		if (request.processEnd) {
-			singlefile.ui.notifyProcessEnd(sender.tab.id);
+			singlefile.ui.end(sender.tab.id);
 		}
 		if (request.processError) {
-			singlefile.ui.notifyProcessError(sender.tab.id);
+			singlefile.ui.error(sender.tab.id);
 		}
 		return false;
 	});
 
 	chrome.browserAction.onClicked.addListener(tab => {
 		if (isAllowedURL(tab.url)) {
-			singlefile.ui.notifyProcessInit(tab.id);
+			singlefile.ui.init(tab.id);
 			chrome.tabs.sendMessage(tab.id, { processStart: true, options: singlefile.config.get() });
 		}
 	});

+ 6 - 6
extension/ui/scripts/bg/ui.js

@@ -33,7 +33,7 @@ singlefile.ui = (() => {
 	let badgeRefreshPending = [];
 
 	return {
-		notifyProcessInit(tabId) {
+		init(tabId) {
 			tabs[tabId] = {
 				id: tabId,
 				text: "...",
@@ -45,7 +45,7 @@ singlefile.ui = (() => {
 			};
 			refreshBadge(tabId);
 		},
-		notifyProcessError(tabId) {
+		error(tabId) {
 			const tabData = tabs[tabId];
 			tabData.text = "ERR";
 			tabData.color = [229, 4, 12, 255];
@@ -55,7 +55,7 @@ singlefile.ui = (() => {
 			tabData.barProgress = -1;
 			refreshBadge(tabId);
 		},
-		notifyProcessEnd(tabId) {
+		end(tabId) {
 			const tabData = tabs[tabId];
 			tabData.text = "OK";
 			tabData.color = [4, 229, 36, 255];
@@ -65,7 +65,7 @@ singlefile.ui = (() => {
 			tabData.barProgress = -1;
 			refreshBadge(tabId);
 		},
-		notifyProcessProgress(tabId, index, maxIndex) {
+		progress(tabId, index, maxIndex) {
 			const tabData = tabs[tabId];
 			const progress = Math.max(Math.min(100, Math.floor((index / maxIndex) * 100)), 0);
 			if (tabData.progress != progress) {
@@ -81,10 +81,10 @@ singlefile.ui = (() => {
 				refreshBadge(tabId);
 			}
 		},
-		notifyTabRemoved(tabId) {
+		removed(tabId) {
 			delete tabs[tabId];
 		},
-		notifyTabActive(tabId, isActive) {
+		active(tabId, isActive) {
 			if (isActive) {
 				chrome.browserAction.enable(tabId);
 			} else {