options.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2010 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 load() {
  21. var bgPage = chrome.extension.getBackgroundPage(), options = bgPage.singlefile.getOptions(), removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedInput;
  22. removeFramesInput = document.getElementById("removeFramesInput");
  23. removeScriptsInput = document.getElementById("removeScriptsInput");
  24. removeObjectsInput = document.getElementById("removeObjectsInput");
  25. removeHiddenInput = document.getElementById("removeHiddenInput");
  26. removeUnusedInput = document.getElementById("removeUnusedInput");
  27. document.getElementById("popupContent").onchange = function() {
  28. setTimeout(function() {
  29. bgPage.singlefile.setOptions( {
  30. removeFrames : removeFramesInput.checked,
  31. removeScripts : removeScriptsInput.checked,
  32. removeObjects : removeObjectsInput.checked,
  33. removeHidden : removeHiddenInput.checked,
  34. removeUnused : removeUnusedInput.checked
  35. });
  36. }, 500);
  37. };
  38. removeFramesInput.checked = options.removeFrames;
  39. removeScriptsInput.checked = options.removeScripts;
  40. removeObjectsInput.checked = options.removeObjects;
  41. removeHiddenInput.checked = options.removeHidden;
  42. removeUnusedInput.checked = options.removeUnused;
  43. removeScriptsInput.addEventListener("click", function() {
  44. removeHiddenInput.checked = false;
  45. removeUnusedInput.checked = false;
  46. });
  47. document.getElementById("resetButton").addEventListener("click", function() {
  48. bgPage.singlefile.resetOptions();
  49. load();
  50. });
  51. }