options.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2011 Gildas Lormeau
  3. * contact : gildas.lormeau <at> gmail.com
  4. *
  5. * This file is part of SingleFile.
  6. *
  7. * SingleFile is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * SingleFile is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. (function() {
  21. var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, maxFrameSizeInput, getRawDocInput, sendToPageArchiverInput, displayBannerInput, displayInContextMenuInput, bgPage = chrome.extension
  22. .getBackgroundPage(), config;
  23. function refresh() {
  24. config = bgPage.singlefile.config.get();
  25. removeFramesInput.checked = config.removeFrames;
  26. removeScriptsInput.checked = config.removeScripts;
  27. removeObjectsInput.checked = config.removeObjects;
  28. removeHiddenInput.checked = config.removeHidden;
  29. removeUnusedCSSRulesInput.checked = config.removeUnusedCSSRules;
  30. displayInContextMenuInput.checked = config.displayInContextMenu;
  31. displayBannerInput.checked = config.displayBanner;
  32. processInBackgroundInput.checked = config.processInBackground;
  33. maxFrameSizeInput.value = config.maxFrameSize;
  34. getRawDocInput.checked = config.getRawDoc;
  35. sendToPageArchiverInput.checked = config.sendToPageArchiver;
  36. if (displayBannerInput.checked)
  37. processInBackgroundInput.checked = processInBackgroundInput.disabled = true;
  38. }
  39. function update() {
  40. bgPage.singlefile.config.set({
  41. removeFrames : removeFramesInput.checked,
  42. removeScripts : removeScriptsInput.checked,
  43. removeObjects : removeObjectsInput.checked,
  44. removeHidden : removeHiddenInput.checked,
  45. removeUnusedCSSRules : removeUnusedCSSRulesInput.checked,
  46. displayInContextMenu : displayInContextMenuInput.checked,
  47. displayBanner : displayBannerInput.checked,
  48. displayProcessedPage : !displayBannerInput.checked,
  49. processInBackground : processInBackgroundInput.checked,
  50. maxFrameSize: maxFrameSizeInput.valueAsNumber || 0,
  51. getRawDoc : getRawDocInput.checked,
  52. sendToPageArchiver : sendToPageArchiverInput.checked
  53. });
  54. }
  55. function updateProcessInBackground() {
  56. processInBackgroundInput.checked = processInBackgroundInput.disabled = displayBannerInput.checked;
  57. update();
  58. }
  59. removeFramesInput = document.getElementById("removeFramesInput");
  60. removeScriptsInput = document.getElementById("removeScriptsInput");
  61. removeObjectsInput = document.getElementById("removeObjectsInput");
  62. removeHiddenInput = document.getElementById("removeHiddenInput");
  63. removeUnusedCSSRulesInput = document.getElementById("removeUnusedCSSRulesInput");
  64. displayInContextMenuInput = document.getElementById("displayInContextMenuInput");
  65. displayBannerInput = document.getElementById("displayBannerInput");
  66. processInBackgroundInput = document.getElementById("processInBackgroundInput");
  67. maxFrameSizeInput = document.getElementById("maxFrameSizeInput");
  68. getRawDocInput = document.getElementById("getRawDocInput");
  69. sendToPageArchiverInput = document.getElementById("sendToPageArchiverInput");
  70. displayInContextMenuInput.addEventListener("click", bgPage.singlefile.refreshMenu);
  71. displayBannerInput.addEventListener("click", updateProcessInBackground, false);
  72. document.getElementById("resetButton").addEventListener("click", function() {
  73. bgPage.singlefile.config.reset();
  74. refresh();
  75. update();
  76. }, false);
  77. addEventListener("click", function(event) {
  78. var tooltip;
  79. if (event.target.className == "question-mark") {
  80. tooltip = event.target.parentElement.parentElement.children[2];
  81. tooltip.style.display = tooltip.style.display == "block" ? "none" : "block";
  82. event.preventDefault();
  83. }
  84. }, false);
  85. document.getElementById("popupContent").onchange = update;
  86. refresh();
  87. })();