Преглед изворни кода

removed deprecated filesystem saving

Gildas lormeau пре 14 година
родитељ
комит
6cda6015fe

+ 0 - 1
WebContent/core/pages/background.html

@@ -8,7 +8,6 @@
 <script type="text/javascript" src="../scripts/bg/nio.js"></script>
 <script type="text/javascript" src="../scripts/common/util.js"></script>
 <script type="text/javascript" src="../scripts/common/docprocessor.js"></script>
-<script type="text/javascript" src="../scripts/bg/storage.js"></script>
 <script type="text/javascript" src="../scripts/bg/bgcore.js"></script>
 <script type="text/javascript" src="../scripts/bg/background.js"></script>
 </head>

+ 0 - 3
WebContent/core/scripts/bg/background.js

@@ -27,8 +27,6 @@
 		removeHidden : false,
 		removeUnusedCSSRules : false,
 		displayProcessedPage : false,
-		savePage : false,
-		filenameMaxLength : 90,
 		processInBackground : true,
 		getContent : true,
 		getRawDoc : false
@@ -65,7 +63,6 @@
 
 	function setContentResponse(tabId, pageId, docData, content) {
 		var pageData = tabs[tabId][pageId];
-		pageData.endProcess(content);
 		processingPagesCount--;
 		chrome.extension.sendRequest(pageData.senderId, {
 			processEnd : true,

+ 1 - 16
WebContent/core/scripts/bg/bgcore.js

@@ -185,21 +185,6 @@
 				that.progressMax += docData.progressMax || 0;
 			});
 		},
-		endProcess : function(content) {
-			var that = this;
-			if (this.config.savePage)
-				singlefile.storage.addContent(this.title ? this.title.replace(/[\\\/:\*\?\"><|]/gi, "").trim() || "Unnamed page" : "Unnamed page", content
-						.replace(/<meta[^>]*http-equiv\s*=\s*["']?content-type[^>]*>/gi, "").replace(/<meta[^>]*charset\s*=[^>]*>/gi, ""),
-						this.config.filenameMaxLength, function(processed, filename) {
-							chrome.extension.sendRequest(that.senderId, {
-								pageSaved : true,
-								tabId : that.tabId,
-								pageId : that.pageId,
-								processed : processed,
-								filename : filename
-							});
-						});
-		},
 		getResourceContentRequest : function(url, requestId, winId, characterSet, mediaTypeParam, docData) {
 			this.requestManager.send(url, function(content) {
 				docData.getResourceContentResponse(content, requestId);
@@ -300,4 +285,4 @@
 		singlefile.winProperties = winProperties;
 	})();
 
-})();
+})();

+ 0 - 97
WebContent/core/scripts/bg/storage.js

@@ -1,97 +0,0 @@
-/*
- * Copyright 2011 Gildas Lormeau
- * contact : gildas.lormeau <at> gmail.com
- * 
- * This file is part of SingleFile Core.
- *
- *   SingleFile Core is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU Lesser General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   SingleFile Core is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU Lesser General Public License for more details.
- *
- *   You should have received a copy of the GNU Lesser General Public License
- *   along with SingleFile Core.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-(function() {
-	var STORAGE_SIZE = 1073741824, FILENAME_MAX_LENGTH = 256, BOM, fs, requestFS = window.requestFileSystem || window.webkitRequestFileSystem, BBuilder = window.BlobBuilder
-			|| window.WebKitBlobBuilder;
-
-	singlefile.storage = {};
-
-	singlefile.storage.isEnabled = typeof requestFS != "undefined" && typeof ArrayBuffer != "undefined" && typeof Uint8Array != "undefined";
-
-	function init() {
-		var view;
-		if (!singlefile.storage.isEnabled)
-			return;
-		BOM = new ArrayBuffer(3);
-		view = new Uint8Array(BOM);
-		view.set([ 0xEF, 0xBB, 0xBF ]);
-		requestFS(true, STORAGE_SIZE, function(filesystem) {
-			fs = filesystem;
-			singlefile.storage.isEnabled = true;
-		}, function(e) {
-			singlefile.storage.isEnabled = false;
-			console.log(e);
-		});
-	}
-
-	singlefile.storage.addContent = function(name, content, maxLength, callback, index) {
-		var suffix = (index ? " (" + (index + 1) + ")" : ""), max = maxLength - suffix.length, filename = (name.length > max - 6 ? name.substring(0, max - 6)
-				+ "[...] " : name)
-				+ suffix + ".html";
-		if (fs) {
-			fs.root.getFile(filename, {
-				create : true,
-				exclusive : true
-			}, function(fileEntry) {
-				fileEntry.createWriter(function(fileWriter) {
-					var blobBuilder = new BBuilder();
-					blobBuilder.append(BOM);
-					blobBuilder.append(content);
-					fileWriter.onerror = function(e) {
-						callback(false, filename);
-					};
-					fileWriter.onwrite = function(e) {
-						callback(true, filename);
-					};
-					fileWriter.write(blobBuilder.getBlob());
-				}, function(e) {
-					console.log(e);
-					callback(false, filename);
-				});
-			}, function(e) {
-				if (e.code == e.INVALID_MODIFICATION_ERR) {
-					index = index || 0;
-					index++;
-					singlefile.storage.addContent(name, content, maxLength, callback, index);
-				} else {
-					console.log(e);
-					callback(false, filename);
-				}
-			});
-		} else
-			callback(false, filename);
-	};
-
-	singlefile.storage.reset = function() {
-		var rootReader;
-		if (fs) {
-			rootReader = fs.root.createReader("/");
-			rootReader.readEntries(function(entries) {
-				var i;
-				for (i = 0; i < entries.length; i++)
-					entries[i].remove();
-			});
-		}
-	};
-
-	init();
-
-})();

+ 1 - 1
WebContent/core/scripts/common/util.js

@@ -44,4 +44,4 @@
 		return getDoctype(doc) + docElement.outerHTML;
 	};
 
-})();
+})();

+ 1 - 1
WebContent/core/scripts/content/content.js

@@ -376,7 +376,7 @@
 				setContentResponse : true,
 				winId : "0",
 				pageId : pageId,
-				content : config.savePage || config.getContent ? content : null
+				content : config.getContent ? content : null
 			});
 		}
 

+ 0 - 4
WebContent/ui/pages/options.css

@@ -84,10 +84,6 @@ a {
 	right: 0px;
 }
 
-#filenameMaxLengthInput {
-	width: 20px;
-}
-
 .help {
 	font-size: 9pt;
 	color: LightSlateGrey;

+ 13 - 36
WebContent/ui/pages/options.html

@@ -4,7 +4,6 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>SingleFile options</title>
 <link rel="stylesheet" href="options.css">
-<script type="text/javascript" src="../scripts/bg/options.js"></script>
 </head>
 <body>
 <div>
@@ -48,61 +47,39 @@
 		</div>
 	</div>
 	<div class="option">
-		<label for="getContentInput">scrapbook the page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="getContentInput">
+		<label for="displayInContextMenuInput">add entry into the context menu<img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="displayInContextMenuInput">
 		<div class="help">
-			<p>Check this option to send the processed page to Scrapbook for SingleFile.</p>
-			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
+			<p>Check this option to launch processing on a page with context menu.</p>
+			<p class="notice">It is recommended to <u>check</u> this option</p>
 		</div>
 	</div>
+	<h4>Advanced options:</h4>
 	<div class="option">
-		<label for="displayInContextMenuInput">display a context menu entry <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="displayInContextMenuInput">
+		<label for="getContentInput">scrapbook the page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="getContentInput">
 		<div class="help">
-			<p>Check this option to launch processing on a page with context menu.</p>
-			<p class="notice">It is recommended to <u>check</u> this option</p>
+			<p>Check this option to send the processed page to Scrapbook for SingleFile.</p>
+			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
-	</div>	
-	<h4>Advanced options:</h4>
+	</div>
 	<div class="option">
 		<label for="processInBackgroundInput">process in background <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="processInBackgroundInput">
 		<div class="help">
 			<p>Check this option to process the page in background. Processing in background means it won't be blocking.</p>
-			<p class="notice">It is recommended to <u>uncheck</u> this option</p>		
-		</div>
-	</div>
-	<div id="storageOptions">
-		<div class="option">
-			<label for="savePageInput">save processed page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="savePageInput">
-			<div class="help">
-				<p>Check this option to save the processed page on filesystem.</p>
-				<p class="notice">It is recommended to <u>uncheck</u> this option</p>		
-			</div>
-		</div>
-		<div class="option">
-			<label for="displayProcessedPageInput">display processed page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="displayProcessedPageInput">
-			<div class="help">
-				<p>Check this option to display the processed page in the tab.</p>
-				<p class="notice">It is recommended to <u>check</u> this option</p>
-			</div>
+			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
-		<div class="option">
-			<label for="filenameMaxLengthInput">max filename length <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="text" id="filenameMaxLengthInput">
-			<div class="help">
-				<p>Set the value of maximum filename length. This value is used when "save processed page" option is checked.</p>
-				<p class="notice">It is recommended to set this option to <u>90</u> (if you are using Windows)</p>
-			</div>
-		</div>		
 	</div>
 	<div class="option">
 		<label for="getRawDocInput">process raw document <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="getRawDocInput">
 		<div class="help">
 			<p>Check this option to process the raw downloaded document instead of the displayed document. This option also helps to not alter the saved page when "remove scripts" is unchecked</p>
-			<p class="notice">It is recommended to <u>uncheck</u> this option</p>		
+			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
 	</div>
 	<div class="option">	
 		<a href="help.html" target="SingleSileHelpPage">help</a><button id="resetButton" title="Reset all the options to default (i.e. recommended) state">Reset to default options</button>
-	</div>	
+	</div>
 </div>
 </div>
+<script type="text/javascript" src="../scripts/bg/options.js"></script>
 </body>
-</html>
+</html>

+ 1 - 1
WebContent/ui/scripts/bg/background.js

@@ -47,7 +47,7 @@
 	}
 
 	function process(tabId, url, processSelection) {
-		var SINGLE_FILE_CORE_EXT_ID = dev ? /* "oabofdibacblkhpogjinmdbcekfkikjc" */"onlinihoegnbbcmeeocfeplgbkmoidla" : "jemlklgaibiijojffihnhieihhagocma";
+		var SINGLE_FILE_CORE_EXT_ID = dev ? "onlinihoegnbbcmeeocfeplgbkmoidla" : "jemlklgaibiijojffihnhieihhagocma";
 		detectExtension(SINGLE_FILE_CORE_EXT_ID, function(detected) {
 			if (detected) {
 				if (processable(url)) {

+ 2 - 4
WebContent/ui/scripts/bg/config.js

@@ -35,8 +35,6 @@
 			removeUnusedCSSRules : false,
 			processInBackground : false,
 			displayProcessedPage : true,
-			savePage : false,
-			filenameMaxLength : 90,
 			getContent : false,
 			getRawDoc : false,
 			displayInContextMenu : true
@@ -49,7 +47,7 @@
 
 	// migration 0.1 -> 0.2
 	delete localStorage.options;
-	
+
 	// migration 0.2.26 -> 0.2.27
 	if (localStorage.config) {
 		var conf = singlefile.config.get();
@@ -57,7 +55,7 @@
 			conf.displayInContextMenu = true;
 			singlefile.config.set(conf);
 		}
-			
+
 	}
 
 })();

+ 12 - 39
WebContent/ui/scripts/bg/options.js

@@ -17,24 +17,10 @@
  *   You should have received a copy of the GNU Lesser General Public License
  *   along with SingleFile.  If not, see <http://www.gnu.org/licenses/>.
  */
+(function() {
 
-function load() {
-	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, getRawDocInput, displayProcessedPageInput, savePageInput, getContentInput, displayInContextMenu;
-	var bgPage = chrome.extension.getBackgroundPage(), config = bgPage.singlefile.config.get(), filenameMaxLengthInput, storageIsEnabled = (typeof window.requestFileSystem != "undefined" || typeof window.webkitRequestFileSystem != "undefined")
-			&& typeof ArrayBuffer != "undefined";
-
-	function refresh() {
-		savePageInput.disabled = !storageIsEnabled;
-		if (savePageInput.disabled)
-			savePageInput.checked = false;
-		displayProcessedPageInput.disabled = !savePageInput.checked || removeUnusedCSSRulesInput.checked;
-		if (displayProcessedPageInput.disabled) {
-			document.querySelector("label[for=displayProcessedPageInput]").style.opacity = ".5";
-			displayProcessedPageInput.checked = true;
-		} else
-			document.querySelector("label[for=displayProcessedPageInput]").style.opacity = "1";
-	}
-
+	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, getRawDocInput, getContentInput, displayInContextMenu, bgPage = chrome.extension
+			.getBackgroundPage(), config = bgPage.singlefile.config.get();
 	removeFramesInput = document.getElementById("removeFramesInput");
 	removeScriptsInput = document.getElementById("removeScriptsInput");
 	removeObjectsInput = document.getElementById("removeObjectsInput");
@@ -43,12 +29,8 @@ function load() {
 	displayInContextMenuInput = document.getElementById("displayInContextMenuInput");
 	processInBackgroundInput = document.getElementById("processInBackgroundInput");
 	getRawDocInput = document.getElementById("getRawDocInput");
-	displayProcessedPageInput = document.getElementById("displayProcessedPageInput");
-	savePageInput = document.getElementById("savePageInput");
-	filenameMaxLengthInput = document.getElementById("filenameMaxLengthInput");
 	getContentInput = document.getElementById("getContentInput");
 	document.getElementById("popupContent").onchange = function() {
-		refresh();
 		bgPage.singlefile.config.set({
 			removeFrames : removeFramesInput.checked,
 			removeScripts : removeScriptsInput.checked,
@@ -58,9 +40,6 @@ function load() {
 			displayInContextMenu : displayInContextMenuInput.checked,
 			processInBackground : processInBackgroundInput.checked,
 			getRawDoc : getRawDocInput.checked,
-			displayProcessedPage : displayProcessedPageInput.checked,
-			savePage : savePageInput.checked,
-			filenameMaxLength : parseInt(filenameMaxLengthInput.value, 10),
 			getContent : getContentInput.checked
 		});
 	};
@@ -72,25 +51,19 @@ function load() {
 	displayInContextMenuInput.checked = config.displayInContextMenu;
 	processInBackgroundInput.checked = config.processInBackground;
 	getRawDocInput.checked = config.getRawDoc;
-	displayProcessedPageInput.checked = config.displayProcessedPage;
-	savePageInput.checked = config.savePage;
-	filenameMaxLengthInput.value = config.filenameMaxLength;
 	getContentInput.checked = config.getContent;
-	refresh();
 	displayInContextMenuInput.addEventListener("click", bgPage.singlefile.refreshMenu);
 	document.getElementById("resetButton").addEventListener("click", function() {
 		bgPage.singlefile.config.reset();
 		load();
 	});
-	document.getElementById("storageOptions").style.display = storageIsEnabled ? "" : "none";
-}
+	addEventListener("click", function(event) {
+		var tooltip;
+		if (event.target.className == "question-mark") {
+			tooltip = event.target.parentElement.parentElement.children[2];
+			tooltip.style.display = tooltip.style.display == "block" ? "none" : "block";
+			event.preventDefault();
+		}
+	});
 
-addEventListener("load", load);
-addEventListener("click", function(event) {
-	var tooltip;
-	if (event.target.className == "question-mark") {
-		tooltip = event.target.parentElement.parentElement.children[2];
-		tooltip.style.display = tooltip.style.display == "block" ? "none" : "block";
-		event.preventDefault();
-	}
-});
+})();