Gildas 3 лет назад
Родитель
Сommit
bea26c38ed
2 измененных файлов с 135 добавлено и 24 удалено
  1. 96 0
      src/ui/bg/ui-help.js
  2. 39 24
      src/ui/pages/help.html

+ 96 - 0
src/ui/bg/ui-help.js

@@ -0,0 +1,96 @@
+/*
+ * Copyright 2010-2020 Gildas Lormeau
+ * contact : gildas.lormeau <at> gmail.com
+ * 
+ * This file is part of SingleFile.
+ *
+ *   The code in this file is free software: you can redistribute it and/or 
+ *   modify it under the terms of the GNU Affero General Public License 
+ *   (GNU AGPL) as published by the Free Software Foundation, either version 3
+ *   of the License, or (at your option) any later version.
+ * 
+ *   The code in this file 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 Affero 
+ *   General Public License for more details.
+ *
+ *   As additional permission under GNU AGPL version 3 section 7, you may 
+ *   distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU 
+ *   AGPL normally required by section 4, provided you include this license 
+ *   notice and a URL through which recipients can access the Corresponding 
+ *   Source.
+ */
+
+/* global browser, document */
+
+let BACKGROUND_SAVE_SUPPORTED,
+	AUTO_SAVE_SUPPORTED,
+	OPEN_SAVED_PAGE_SUPPORTED,
+	AUTO_OPEN_EDITOR_SUPPORTED,
+	INFOBAR_SUPPORTED,
+	BOOKMARKS_API_SUPPORTED,
+	IDENTITY_API_SUPPORTED,
+	CLIPBOARD_API_SUPPORTED,
+	NATIVE_API_API_SUPPORTED,
+	WEB_BLOCKING_API_SUPPORTED,
+	SELECTABLE_TABS_SUPPORTED;
+browser.runtime.sendMessage({ method: "config.getConstants" }).then(data => {
+	({
+		BACKGROUND_SAVE_SUPPORTED,
+		AUTO_SAVE_SUPPORTED,
+		OPEN_SAVED_PAGE_SUPPORTED,
+		AUTO_OPEN_EDITOR_SUPPORTED,
+		INFOBAR_SUPPORTED,
+		BOOKMARKS_API_SUPPORTED,
+		IDENTITY_API_SUPPORTED,
+		CLIPBOARD_API_SUPPORTED,
+		NATIVE_API_API_SUPPORTED,
+		WEB_BLOCKING_API_SUPPORTED,
+		SELECTABLE_TABS_SUPPORTED
+	} = data);
+	init();
+});
+
+function init() {
+	if (!AUTO_SAVE_SUPPORTED) {
+		document.getElementById("autoSaveSection").hidden = true;
+		document.getElementById("autoSaveOptions").hidden = true;
+		document.getElementById("autoSaveMenu").hidden = true;
+		document.getElementById("autoSaveHint").hidden = true;
+	}
+	if (!BACKGROUND_SAVE_SUPPORTED) {
+		document.getElementById("backgroundSaveOption").hidden = true;
+		document.getElementById("confirmFilenameOption").hidden = true;
+		document.getElementById("filenameConflictActionOption").hidden = true;
+	}
+	if (!BOOKMARKS_API_SUPPORTED) {
+		document.getElementById("bookmarksSection").hidden = true;
+		document.getElementById("bookmarksOptions").hidden = true;
+	}
+	if (!OPEN_SAVED_PAGE_SUPPORTED) {
+		document.getElementById("openSavedPageOption").hidden = true;
+	}
+	if (!AUTO_OPEN_EDITOR_SUPPORTED) {
+		document.getElementById("autoOpenEditorOption").hidden = true;
+	}
+	if (!INFOBAR_SUPPORTED) {
+		document.getElementById("displayInfobarOption").hidden = true;
+	}
+	if (!IDENTITY_API_SUPPORTED) {
+		document.getElementById("saveToGDriveOption").hidden = true;
+		document.getElementById("saveToGDriveHint").hidden = true;
+	}
+	if (!CLIPBOARD_API_SUPPORTED) {
+		document.getElementById("saveToClipboardOption").hidden = true;
+	}
+	if (!NATIVE_API_API_SUPPORTED) {
+		document.getElementById("saveWithCompanionOption").hidden = true;
+	}
+	if (!WEB_BLOCKING_API_SUPPORTED) {
+		document.getElementById("passReferrerOnErrorOption").hidden = true;
+	}
+	if (!SELECTABLE_TABS_SUPPORTED) {
+		document.getElementById("selectableTabsMenu").hidden = true;
+		document.getElementById("shortcutsSection").hidden = true;
+	}
+}

+ 39 - 24
src/ui/pages/help.html

@@ -43,12 +43,12 @@
 						</ul>
 						</ul>
 					</li>
 					</li>
 					<li>You can also process multiple tabs in one click and save: <ul>
 					<li>You can also process multiple tabs in one click and save: <ul>
-							<li>the selected tabs,</li>
+							<li id="selectableTabsMenu">the selected tabs,</li>
 							<li>or the unpinned tabs,</li>
 							<li>or the unpinned tabs,</li>
 							<li>or all the tabs.</li>
 							<li>or all the tabs.</li>
 						</ul>
 						</ul>
 					</li>
 					</li>
-					<li>The context menu also allows you to activate the auto-save of: <ul>
+					<li id="autoSaveMenu">The context menu also allows you to activate the auto-save of: <ul>
 							<li>the current tab,</li>
 							<li>the current tab,</li>
 							<li>or the unpinned tabs,</li>
 							<li>or the unpinned tabs,</li>
 							<li>or all the tabs.</li>
 							<li>or all the tabs.</li>
@@ -57,17 +57,21 @@
 					<li>You can highlight text, add notes, format and remove content before saving the page with the <a
 					<li>You can highlight text, add notes, format and remove content before saving the page with the <a
 							href="#annotation-editor">Annotation editor</a> by selecting "Annotate and save the page..."
 							href="#annotation-editor">Annotation editor</a> by selecting "Annotate and save the page..."
 						in the context menu</li>
 						in the context menu</li>
-					<li>With auto-save active, pages are automatically saved every time after being loaded (or before
+					<li id="autoSaveHint">With auto-save active, pages are automatically saved every time after being
+						loaded (or before
 						being unloaded if not). </li>
 						being unloaded if not). </li>
 					<li>Select "Save Selection" from the context menu without selecting any content first to display a
 					<li>Select "Save Selection" from the context menu without selecting any content first to display a
 						selector that will help you choose content by hovering over it with the mouse.</li>
 						selector that will help you choose content by hovering over it with the mouse.</li>
 					<li>Right-click on the SingleFile button and select "Options" to open the options page.</li>
 					<li>Right-click on the SingleFile button and select "Options" to open the options page.</li>
-					<li>Enable the option "Destination &gt; upload to Google Drive" to upload pages to Google Drive</li>
-					<li>You can use the customizable shortcut Ctrl+Shift+Y to save the current tab or the selected tabs.
+					<li id="saveToGDriveHint">Enable the option "Destination &gt; upload to Google Drive" to upload
+						pages to Google Drive</li>
+					<li id="shortcutsSection">You can use the customizable shortcut Ctrl+Shift+Y to save the current tab
+						or the selected tabs.
 						Go to about:addons and select "Manage extension shortcuts" in the cogwheel menu to change it in
 						Go to about:addons and select "Manage extension shortcuts" in the cogwheel menu to change it in
 						Firefox. Go to chrome://extensions/shortcuts to change it in Chrome..</li>
 						Firefox. Go to chrome://extensions/shortcuts to change it in Chrome..</li>
 					<li>The default save folder is the download folder configured in your browser, cf. about:preferences
 					<li>The default save folder is the download folder configured in your browser, cf. about:preferences
-						in Firefox and chrome://settings in Chrome.</li>
+						in Firefox, chrome://settings in Chrome, and Settings > General > File download location in
+						Safari.</li>
 				</ul>
 				</ul>
 			</li>
 			</li>
 			<li><a id="options">Options description</a>
 			<li><a id="options">Options description</a>
@@ -107,7 +111,8 @@
 							resources. This reminds you that you should not close the tab. </p>
 							resources. This reminds you that you should not close the tab. </p>
 						<p class="notice">It is recommended to <u>check</u> this option</p>
 						<p class="notice">It is recommended to <u>check</u> this option</p>
 					</li>
 					</li>
-					<li data-options-label="displayInfobarLabel"> <span class="option">Option: display an infobar when
+					<li data-options-label="displayInfobarLabel" id="displayInfobarOption"> <span class="option">Option:
+							display an infobar when
 							viewing a saved page</span>
 							viewing a saved page</span>
 						<p>Check this option to display the ℹ button at the top right of the page when viewing a saved
 						<p>Check this option to display the ℹ button at the top right of the page when viewing a saved
 							page. By clicking this button, you can get more information about the saved date and open
 							page. By clicking this button, you can get more information about the saved date and open
@@ -134,7 +139,8 @@
 						<p>Check this option to display a prompt dialog in order to confirm the infobar content before
 						<p>Check this option to display a prompt dialog in order to confirm the infobar content before
 							saving the page. </p>
 							saving the page. </p>
 					</li>
 					</li>
-					<li data-options-label="openSavedPageLabel"> <span class="option">Option: open saved pages in a new
+					<li data-options-label="openSavedPageLabel" id="openSavedPageOption"> <span class="option">Option:
+							open saved pages in a new
 							tab</span>
 							tab</span>
 						<p>Check this option to display the saved page in a new tab. This option can be useful, for
 						<p>Check this option to display the saved page in a new tab. This option can be useful, for
 							example, in order to check the page is properly saved.</p>
 							example, in order to check the page is properly saved.</p>
@@ -175,13 +181,15 @@
 						<p>Enter the maximum length of the filename (without the extension) and its unit (bytes or
 						<p>Enter the maximum length of the filename (without the extension) and its unit (bytes or
 							characters).</p>
 							characters).</p>
 					</li>
 					</li>
-					<li data-options-label="confirmFilenameLabel"> <span class="option">Option: open the "Save as"
+					<li data-options-label="confirmFilenameLabel" id="confirmFilenameOption"> <span
+							class="option">Option: open the "Save as"
 							dialog to confirm the file name</span>
 							dialog to confirm the file name</span>
 						<p>Check this option to display the "Save as" dialog in order to confirm the file name before
 						<p>Check this option to display the "Save as" dialog in order to confirm the file name before
 							saving the page. If the option "save pages in background" is unchecked then a prompt dialog
 							saving the page. If the option "save pages in background" is unchecked then a prompt dialog
 							will be displayed instead of the "Save as" dialog. </p>
 							will be displayed instead of the "Save as" dialog. </p>
 					</li>
 					</li>
-					<li data-options-label="filenameConflictActionLabel"> <span class="option">Option: file name
+					<li data-options-label="filenameConflictActionLabel" id="filenameConflictActionOption"> <span
+							class="option">Option: file name
 							conflict resolution</span>
 							conflict resolution</span>
 						<p>Choose the most appropriate action when the filename of the saved page is conflicting with
 						<p>Choose the most appropriate action when the filename of the saved page is conflicting with
 							existing ones on the filesystem. The "skip duplicate files" action only detects duplicates
 							existing ones on the filesystem. The "skip duplicate files" action only detects duplicates
@@ -215,14 +223,14 @@
 							considerably reduce the size of the file without altering the document most of the time. It
 							considerably reduce the size of the file without altering the document most of the time. It
 							may also decrease the time needed to save a page.</p>
 							may also decrease the time needed to save a page.</p>
 					</li>
 					</li>
-					<li data-options-label="saveOriginalURLsLabel"> <span class="option"></span>Option: save original
+					<li data-options-label="saveOriginalURLsLabel"> <span class="option"></span>: save original
 						URLs of embedded resources</span>
 						URLs of embedded resources</span>
 						<p>Check this option to save the URLs of the resources embedded into the saved page. URLs
 						<p>Check this option to save the URLs of the resources embedded into the saved page. URLs
 							are stored in attributes with a name prefixed with "data-sf-original-" and suffixed with the
 							are stored in attributes with a name prefixed with "data-sf-original-" and suffixed with the
 							original attribute name (e.g. "data-sf-original-src", "data-sf-original-href") for HTML
 							original attribute name (e.g. "data-sf-original-src", "data-sf-original-href") for HTML
 							contents. For CSS contents, URLs are stored as comments beginning with "original URL:".
 							contents. For CSS contents, URLs are stored as comments beginning with "original URL:".
 					</li>
 					</li>
-					<li data-options-label="includeInfobarLabel"> <span class="option"></span>Option: include infobar in
+					<li data-options-label="includeInfobarLabel"> <span class="option"></span>: include infobar in
 						the saved page</span>
 						the saved page</span>
 						<p>Check this
 						<p>Check this
 							option to display the ℹ button at the top right of the page when viewing a saved page in a
 							option to display the ℹ button at the top right of the page when viewing a saved page in a
@@ -333,7 +341,8 @@
 						<p>Check this option to save the downloaded page on the filesystem of your computer.</p>
 						<p>Check this option to save the downloaded page on the filesystem of your computer.</p>
 						<p class="notice">It is recommended to <u>check</u> this option</p>
 						<p class="notice">It is recommended to <u>check</u> this option</p>
 					</li>
 					</li>
-					<li data-options-label="saveToClipboardLabel"> <span class="option">Option: copy to clipboard</span>
+					<li data-options-label="saveToClipboardLabel" id="saveToClipboardOption"> <span
+							class="option">Option: copy to clipboard</span>
 						<p>Check this option to copy the page to the clipboard.</p>
 						<p>Check this option to copy the page to the clipboard.</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>
 					</li>
 					</li>
@@ -385,7 +394,8 @@
 					<li data-options-label="webDAVPasswordLabel"> <span class="option">Option: password</span>
 					<li data-options-label="webDAVPasswordLabel"> <span class="option">Option: password</span>
 						<p>Enter your password.</p>
 						<p>Enter your password.</p>
 					</li>
 					</li>
-					<li data-options-label="saveToGDriveLabel"> <span class="option">Option: upload to Google
+					<li data-options-label="saveToGDriveLabel" id="saveToGDriveOption"> <span class="option">Option:
+							upload to Google
 							Drive</span>
 							Drive</span>
 						<p>Check this option to save the page on Google Drive.</p>
 						<p>Check this option to save the page on Google Drive.</p>
 						<p>The permissions requested by SingleFile allow it to access only to the files and folders it
 						<p>The permissions requested by SingleFile allow it to access only to the files and folders it
@@ -393,7 +403,8 @@
 							your Google Drive account. </p>
 							your Google Drive account. </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>
 					</li>
 					</li>
-					<li data-options-label="saveWithCompanionLabel"> <span class="option">Option: save with
+					<li data-options-label="saveWithCompanionLabel" id="saveWithCompanionOption"> <span
+							class="option">Option: save with
 							SingleFile Companion</span>
 							SingleFile Companion</span>
 						<p>Check this option to delegate the saving process to SingleFile Companion. It is a program
 						<p>Check this option to delegate the saving process to SingleFile Companion. It is a program
 							that runs outside the browser and can help to make the saving process more transparent. It
 							that runs outside the browser and can help to make the saving process more transparent. It
@@ -410,8 +421,8 @@
 							Check the options below to block the download of the corresponding resource types.
 							Check the options below to block the download of the corresponding resource types.
 						</p>
 						</p>
 					</li>
 					</li>
-					<li data-options-label="blockMixedContentLabel"> <span class="option"></span>Option: block mixed
-						contents</span>
+					<li data-options-label="blockMixedContentLabel"> <span class="option">Option: block mixed
+							contents</span>
 						<p>Check this option to block active content served from HTTP when viewing a page in HTTPS. You
 						<p>Check this option to block active content served from HTTP when viewing a page in HTTPS. You
 							can find more information about mixed content pages <a
 							can find more information about mixed content pages <a
 								href="https://developer.mozilla.org/docs/Web/Security/Mixed_content"
 								href="https://developer.mozilla.org/docs/Web/Security/Mixed_content"
@@ -442,7 +453,8 @@
 							(s)</span>
 							(s)</span>
 						<p>Enter the maximum download delay in seconds.</p>
 						<p>Enter the maximum download delay in seconds.</p>
 					</li>
 					</li>
-					<li data-options-label="passReferrerOnErrorLabel"> <span class="option">Option: pass \"Referer\"
+					<li data-options-label="passReferrerOnErrorLabel" id="passReferrerOnErrorOption"> <span
+							class="option">Option: pass \"Referer\"
 							header on
 							header on
 							cross-origin errors</span>
 							cross-origin errors</span>
 						<p>Check this option to pass the HTTP header "Referer" with the "origin" policy after an 401,
 						<p>Check this option to pass the HTTP header "Referer" with the "origin" policy after an 401,
@@ -487,15 +499,16 @@
 							removes the entry "Annotate and save the page..." from the context menu.</p>
 							removes the entry "Annotate and save the page..." from the context menu.</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>
 					</li>
 					</li>
-					<li data-options-label="autoOpenEditorLabel"> <span class="option">Option: open the annotation
+					<li data-options-label="autoOpenEditorLabel" id="autoOpenEditorOption"> <span class="option">Option:
+							open the annotation
 							editor when viewing a page saved with SingleFile </span>
 							editor when viewing a page saved with SingleFile </span>
 						<p>Check this option to open the annotation editor when displaying a page saved by SingleFile.
 						<p>Check this option to open the annotation editor when displaying a page saved by SingleFile.
 						</p>
 						</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>
 					</li>
 					</li>
 				</ul>
 				</ul>
-				<p>Bookmarks</p>
-				<ul>
+				<p id="bookmarksSection">Bookmarks</p>
+				<ul id="bookmarksOptions">
 					<li data-options-label="saveCreatedBookmarksLabel"> <span class="option">Option: save the page of a
 					<li data-options-label="saveCreatedBookmarksLabel"> <span class="option">Option: save the page of a
 							newly created bookmark</span>
 							newly created bookmark</span>
 						<p>Check this option to save pages that you add into your bookmarks. Note that if the page is to
 						<p>Check this option to save pages that you add into your bookmarks. Note that if the page is to
@@ -522,8 +535,8 @@
 						</p>
 						</p>
 					</li>
 					</li>
 				</ul>
 				</ul>
-				<p>Auto-save</p>
-				<ul>
+				<p id="autoSaveSection">Auto-save</p>
+				<ul id="autoSaveOptions">
 					<li data-options-label="autoSaveLoadOrUnloadLabel"> <span class="option">Option: auto-save after
 					<li data-options-label="autoSaveLoadOrUnloadLabel"> <span class="option">Option: auto-save after
 							page load or on page unload</span>
 							page load or on page unload</span>
 						<p>Check this option to auto-save pages after being loaded. If you browse to another page before
 						<p>Check this option to auto-save pages after being loaded. If you browse to another page before
@@ -599,7 +612,8 @@
 						<p>Enter your personal access token on Woleet, see the <a href="http://app.woleet.io/"
 						<p>Enter your personal access token on Woleet, see the <a href="http://app.woleet.io/"
 								target="_blank">registration page</a> on Woleet for more information.</p>
 								target="_blank">registration page</a> on Woleet for more information.</p>
 					</li>
 					</li>
-					<li data-options-label="backgroundSaveLabel"> <span class="option">Option: save pages in
+					<li data-options-label="backgroundSaveLabel" id="backgroundSaveOption"> <span class="option">Option:
+							save pages in
 							background</span>
 							background</span>
 						<p>Uncheck this option if you get invalid file names like
 						<p>Uncheck this option if you get invalid file names like
 							"37bec68b-446a-46a5-8642-19a89c231b46.html" or interrupted downloads when saving pages. You
 							"37bec68b-446a-46a5-8642-19a89c231b46.html" or interrupted downloads when saving pages. You
@@ -910,6 +924,7 @@
 			</li>
 			</li>
 		</ol>
 		</ol>
 	</div>
 	</div>
+	<script type="module" src="../bg/ui-help.js"></script>
 </body>
 </body>
 
 
 </html>
 </html>