瀏覽代碼

renamed class SingleFile to SingleFileBrowser

Gildas 7 年之前
父節點
當前提交
6297db83ae
共有 3 個文件被更改,包括 12 次插入12 次删除
  1. 2 2
      extension/core/bg/processor.js
  2. 9 9
      extension/core/content/content.js
  3. 1 1
      lib/single-file/single-file-browser.js

+ 2 - 2
extension/core/bg/processor.js

@@ -18,7 +18,7 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* global browser, SingleFile, singlefile, Blob, URL */
+/* global browser, SingleFileBrowser, singlefile, Blob, URL */
 
 singlefile.processor = (() => {
 
@@ -61,7 +61,7 @@ singlefile.processor = (() => {
 				singlefile.ui.button.onEnd(tabId, { autoSave: true });
 			}
 		};
-		const processor = new (SingleFile.getClass())(options);
+		const processor = new (SingleFileBrowser.getClass())(options);
 		await processor.initialize();
 		await processor.run();
 		const page = await processor.getPageData();

+ 9 - 9
extension/core/content/content.js

@@ -18,12 +18,12 @@
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* global browser, SingleFile, singlefile, frameTree, document, Blob, MouseEvent, getSelection, prompt, addEventListener, Node, window, lazyLoader, URL */
+/* global browser, SingleFileBrowser, singlefile, frameTree, document, Blob, MouseEvent, getSelection, prompt, addEventListener, Node, window, lazyLoader, URL */
 
 this.singlefile.top = this.singlefile.top || (() => {
 
 	const MESSAGE_PREFIX = "__SingleFile__::";
-	const SingleFileClass = SingleFile.getClass();
+	const SingleFile = SingleFileBrowser.getClass();
 
 	let processing = false;
 
@@ -82,7 +82,7 @@ this.singlefile.top = this.singlefile.top || (() => {
 
 	async function processPage(options) {
 		singlefile.ui.onStartPage();
-		const processor = new SingleFileClass(options);
+		const processor = new SingleFile(options);
 		const preInitializationPromises = [];
 		options.insertSingleFileComment = true;
 		options.insertFaviconLink = true;
@@ -167,24 +167,24 @@ this.singlefile.top = this.singlefile.top || (() => {
 				}
 				if (selectionFound) {
 					const element = treeWalker.currentNode.nodeType == Node.ELEMENT_NODE ? treeWalker.currentNode : treeWalker.currentNode.parentElement;
-					element.setAttribute(SingleFileClass.SELECTED_CONTENT_ATTRIBUTE_NAME, "");
+					element.setAttribute(SingleFile.SELECTED_CONTENT_ATTRIBUTE_NAME, "");
 				}
 			}
 			if (selectionFound) {
-				ancestorElement.setAttribute(SingleFileClass.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
+				ancestorElement.setAttribute(SingleFile.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
 			}
 		}
 		return selectionFound;
 	}
 
 	function markSelectedArea(selectedAreaElement) {
-		selectedAreaElement.setAttribute(SingleFileClass.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
-		selectedAreaElement.querySelectorAll("*").forEach(element => element.setAttribute(SingleFileClass.SELECTED_CONTENT_ATTRIBUTE_NAME, ""));
+		selectedAreaElement.setAttribute(SingleFile.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME, "");
+		selectedAreaElement.querySelectorAll("*").forEach(element => element.setAttribute(SingleFile.SELECTED_CONTENT_ATTRIBUTE_NAME, ""));
 	}
 
 	function unmarkSelectedContent() {
-		document.querySelectorAll("[" + SingleFileClass.SELECTED_CONTENT_ATTRIBUTE_NAME + "]").forEach(selectedContent => selectedContent.removeAttribute(SingleFileClass.SELECTED_CONTENT_ATTRIBUTE_NAME));
-		document.querySelectorAll("[" + SingleFileClass.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME + "]").forEach(selectedContent => selectedContent.removeAttribute(SingleFileClass.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME));
+		document.querySelectorAll("[" + SingleFile.SELECTED_CONTENT_ATTRIBUTE_NAME + "]").forEach(selectedContent => selectedContent.removeAttribute(SingleFile.SELECTED_CONTENT_ATTRIBUTE_NAME));
+		document.querySelectorAll("[" + SingleFile.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME + "]").forEach(selectedContent => selectedContent.removeAttribute(SingleFile.SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME));
 	}
 
 	async function downloadPage(page, options) {

+ 1 - 1
lib/single-file/single-file-browser.js

@@ -20,7 +20,7 @@
 
 /* global SingleFileCore, DOMParser, URL, setTimeout, TextDecoder, Blob, fetch, FileReader, superFetch, srcsetParser, cssMinifier, htmlMinifier, cssRulesMinifier, fontsMinifier, fontsAltMinifier, serializer, docHelper, mediasMinifier, TextEncoder, crypto, matchedRules, imagesAltMinifier, FontFace, cssTree */
 
-this.SingleFile = this.SingleFile || (() => {
+this.SingleFileBrowser = this.SingleFileBrowser || (() => {
 
 	const ONE_MB = 1024 * 1024;
 	const DEBUG = false;