options.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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, getRawDocInput, getContentInput, displayInContextMenu, bgPage = chrome.extension
  22. .getBackgroundPage(), config = bgPage.singlefile.config.get();
  23. removeFramesInput = document.getElementById("removeFramesInput");
  24. removeScriptsInput = document.getElementById("removeScriptsInput");
  25. removeObjectsInput = document.getElementById("removeObjectsInput");
  26. removeHiddenInput = document.getElementById("removeHiddenInput");
  27. removeUnusedCSSRulesInput = document.getElementById("removeUnusedCSSRulesInput");
  28. displayInContextMenuInput = document.getElementById("displayInContextMenuInput");
  29. processInBackgroundInput = document.getElementById("processInBackgroundInput");
  30. getRawDocInput = document.getElementById("getRawDocInput");
  31. getContentInput = document.getElementById("getContentInput");
  32. document.getElementById("popupContent").onchange = function() {
  33. bgPage.singlefile.config.set({
  34. removeFrames : removeFramesInput.checked,
  35. removeScripts : removeScriptsInput.checked,
  36. removeObjects : removeObjectsInput.checked,
  37. removeHidden : removeHiddenInput.checked,
  38. removeUnusedCSSRules : removeUnusedCSSRulesInput.checked,
  39. displayInContextMenu : displayInContextMenuInput.checked,
  40. processInBackground : processInBackgroundInput.checked,
  41. getRawDoc : getRawDocInput.checked,
  42. getContent : getContentInput.checked
  43. });
  44. };
  45. removeFramesInput.checked = config.removeFrames;
  46. removeScriptsInput.checked = config.removeScripts;
  47. removeObjectsInput.checked = config.removeObjects;
  48. removeHiddenInput.checked = config.removeHidden;
  49. removeUnusedCSSRulesInput.checked = config.removeUnusedCSSRules;
  50. displayInContextMenuInput.checked = config.displayInContextMenu;
  51. processInBackgroundInput.checked = config.processInBackground;
  52. getRawDocInput.checked = config.getRawDoc;
  53. getContentInput.checked = config.getContent;
  54. displayInContextMenuInput.addEventListener("click", bgPage.singlefile.refreshMenu);
  55. document.getElementById("resetButton").addEventListener("click", function() {
  56. bgPage.singlefile.config.reset();
  57. load();
  58. });
  59. addEventListener("click", function(event) {
  60. var tooltip;
  61. if (event.target.className == "question-mark") {
  62. tooltip = event.target.parentElement.parentElement.children[2];
  63. tooltip.style.display = tooltip.style.display == "block" ? "none" : "block";
  64. event.preventDefault();
  65. }
  66. });
  67. })();