home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 December / PCWorld_2005-12_cd.bin / komunikace / netscape / nsb-install-8-0.exe / chrome / comm.jar / content / cookie / pref-popups.xul < prev   
Extensible Markup Language  |  2005-09-26  |  11KB  |  259 lines

  1. <?xml version="1.0"?> 
  2.  
  3. <!-- ***** BEGIN LICENSE BLOCK *****
  4.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.    -
  6.    - The contents of this file are subject to the Mozilla Public License Version
  7.    - 1.1 (the "License"); you may not use this file except in compliance with
  8.    - the License. You may obtain a copy of the License at
  9.    - http://www.mozilla.org/MPL/
  10.    -
  11.    - Software distributed under the License is distributed on an "AS IS" basis,
  12.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.    - for the specific language governing rights and limitations under the
  14.    - License.
  15.    -
  16.    - The Original Code is mozilla.org code.
  17.    -
  18.    - The Initial Developer of the Original Code is
  19.    - Netscape Communications Corporation.
  20.    - Portions created by the Initial Developer are Copyright (C) 2002
  21.    - the Initial Developer. All Rights Reserved.
  22.    -
  23.    - Contributor(s):
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
  40.  
  41. <!DOCTYPE page [
  42. <!ENTITY % prefPopupsDTD SYSTEM "chrome://cookie/locale/pref-popups.dtd" >
  43. %prefPopupsDTD;
  44. ]>
  45.  
  46. <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  47.       id="popupsPanel"
  48.       onload="parent.initPanel('chrome://cookie/content/pref-popups.xul');"
  49.       headertitle="&title;">
  50.           
  51.   <script type="application/x-javascript">
  52.     <![CDATA[
  53.  
  54.       var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
  55.  
  56.       const nsIPermissionManager = Components.interfaces.nsIPermissionManager
  57.       const popupType = "popup";
  58.  
  59.       var gPolicyCheckbox;
  60.       var gSoundCheckbox;
  61.       var gSoundUrlBox;
  62.       var gSoundUrlButton;
  63.       var gPreviewSoundButton;
  64.       var gIconCheckbox;
  65.  
  66.       var permissionManager;
  67.       var ioService;
  68.  
  69.       function Startup() {
  70.         permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
  71.                                       .getService(Components.interfaces.nsIPermissionManager);
  72.  
  73.         ioService = Components.classes["@mozilla.org/network/io-service;1"]
  74.                               .getService(Components.interfaces.nsIIOService);
  75.  
  76.         gPolicyCheckbox = document.getElementById("popupPolicy");
  77.         gSoundCheckbox = document.getElementById("playSound");
  78.         gSoundUrlBox = document.getElementById("playSoundUrl");
  79.         gSoundUrlButton = document.getElementById("selectSound");
  80.         gPreviewSoundButton = document.getElementById("previewSound");
  81.         gIconCheckbox = document.getElementById("displayIcon");   
  82.  
  83.         var removeBlacklist = (document.getElementById("removeBlacklist").getAttribute("value") == "true");
  84.         if (removeBlacklist) {
  85.           clearBlacklist();
  86.           document.getElementById("removeBlacklist").setAttribute("value", false);
  87.         }
  88.  
  89.         var prefillWhitelist = (document.getElementById("prefillWhitelist").getAttribute("value") == "true");        
  90.         if (prefillWhitelist) {          
  91.           loadWhitelist();
  92.           document.getElementById("prefillWhitelist").setAttribute("value", false);
  93.         }
  94.  
  95.         if (parent.queuedTag == "chrome://cookie/content/pref-popups.xul") {
  96.           // opened from About Popups menuitem
  97.           gPolicyCheckbox.checked = true;
  98.           parent.queuedTag = null;
  99.         }
  100.  
  101.         setButtons();
  102.       }
  103.  
  104.       function clearBlacklist() {
  105.         var enumerator = permissionManager.enumerator;
  106.         var hosts = [];
  107.   
  108.         while (enumerator.hasMoreElements()) {                
  109.           var permission = enumerator.getNext();
  110.           if (permission) {
  111.             permission = permission.QueryInterface(Components.interfaces.nsIPermission);
  112.             if ((permission.type == popupType) && (permission.capability == nsIPermissionManager.DENY_ACTION))
  113.               hosts[hosts.length] = permission.host;
  114.           }
  115.         }
  116.         
  117.         for (var i = 0; i < hosts.length; i++) {
  118.           permissionManager.remove(hosts[i], popupType);
  119.         }    
  120.       
  121.       }
  122.  
  123.       function loadWhitelist() {
  124.         try {
  125.           var whitelist;
  126.           var hosts;
  127.           var prefService = Components.classes["@mozilla.org/preferences-service;1"]
  128.                                       .getService(Components.interfaces.nsIPrefService);
  129.           var prefs = prefService.getBranch(null);
  130.           whitelist = prefs.getComplexValue("privacy.popups.default_whitelist",
  131.                                             Components.interfaces.nsIPrefLocalizedString).data;
  132.           hosts = whitelist.split(",");
  133.  
  134.           for (var i = 0; i < hosts.length; i++) {
  135.             var host = hosts[i];
  136.             host = "http://" + host;
  137.             var uri = ioService.newURI(host, null, null);
  138.             permissionManager.add(uri, popupType, true);
  139.           }
  140.         } 
  141.         catch (ex) { }
  142.       }
  143.  
  144.       function setButtons() {
  145.         var exceptionsButton = document.getElementById("exceptionsButton");
  146.         exceptionsButton.disabled = !gPolicyCheckbox.checked;
  147.  
  148.         if (!gPolicyCheckbox.checked) {
  149.           gSoundCheckbox.disabled = true;
  150.           gSoundUrlBox.disabled = true;
  151.           gSoundUrlButton.disabled = true;
  152.           gPreviewSoundButton.disabled = true;
  153.           gIconCheckbox.disabled = true;
  154.         }
  155.         else {
  156.           gSoundCheckbox.disabled = false;
  157.           gSoundUrlBox.disabled = false;
  158.           gSoundUrlButton.disabled = false;
  159.           gPreviewSoundButton.disabled = false;
  160.           gIconCheckbox.disabled = false;
  161.                   
  162.           enableSoundUrl(gSoundCheckbox.checked);
  163.         }
  164.       }
  165.  
  166.       function selectSound() {
  167.         var nsIFilePicker = Components.interfaces.nsIFilePicker;
  168.         var filepicker = Components.classes["@mozilla.org/filepicker;1"]
  169.                                    .createInstance(nsIFilePicker);
  170.  
  171.         filepicker.init(window, document.getElementById("selectSound").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
  172.         filepicker.appendFilters(nsIFilePicker.filterAll);
  173.  
  174.         var ret = filepicker.show();
  175.         if (ret == nsIFilePicker.returnOK)
  176.           gSoundUrlBox.value = filepicker.file.path;
  177.         
  178.         onSoundInput();
  179.       }
  180.  
  181.       function previewSound() {
  182.         var soundUrl = gSoundUrlBox.value;
  183.         var sound = Components.classes["@mozilla.org/sound;1"]
  184.                               .createInstance(Components.interfaces.nsISound);
  185.         if (soundUrl.indexOf("file://") == -1) {
  186.           sound.playSystemSound(soundUrl);
  187.         }
  188.         else {
  189.           var url = Components.classes["@mozilla.org/network/standard-url;1"]
  190.                               .createInstance(Components.interfaces.nsIURL);
  191.           url.spec = soundUrl;
  192.           sound.play(url)
  193.         }        
  194.       }
  195.  
  196.       function enableSoundUrl(soundChecked) {
  197.         gSoundUrlBox.disabled = !soundChecked;
  198.         gSoundUrlButton.disabled = !soundChecked;
  199.         if (soundChecked && gSoundUrlBox.value) {
  200.           gPreviewSoundButton.disabled = false;
  201.         }
  202.         else
  203.           gPreviewSoundButton.disabled = true;
  204.       }
  205.  
  206.       function onSoundInput() {
  207.         gPreviewSoundButton.disabled = gSoundUrlBox.value == "";
  208.       }
  209.  
  210.       function viewPopups() {
  211.         window.openDialog("chrome://communicator/content/popupManager.xul", "",
  212.                           "chrome,resizable=yes", "");
  213.       }
  214.  
  215.     ]]>
  216.   </script>
  217.  
  218.   <groupbox id="popupsArea">
  219.     <caption label="&popupBlocking.label;"/>
  220.  
  221.     <hbox align="center">      
  222.       <checkbox id="popupPolicy" label="&popupBlock.label;" accesskey="&popupBlock.accesskey;"
  223.                 oncommand="setButtons()"
  224.                 preftype="bool" prefstring="dom.disable_open_during_load"
  225.                 prefattribute="checked"/>   
  226.             <spacer flex="1"/>
  227.       <button id="exceptionsButton" label="&popupExceptions.label;"
  228.               accesskey="&popupExceptions.accesskey;"
  229.                     oncommand="viewPopups();"/>
  230.           </hbox>
  231.     <separator class="thin"/>
  232.     <description id="whenBlock">&whenBlock.description;</description>
  233.     <hbox align="center">
  234.       <checkbox id="playSound" label="&playSound.label;"
  235.                 oncommand="enableSoundUrl(this.checked);"
  236.                 preftype="bool" prefstring="privacy.popups.sound_enabled"
  237.                 prefattribute="checked"/>
  238.     </hbox>
  239.     <hbox align="center">
  240.       <textbox flex="1" id="playSoundUrl"
  241.                prefstring="privacy.popups.sound_url" oninput="onSoundInput()"/>
  242.       <button id="selectSound" label="&selectSound.label;" accesskey="&selectSound.accesskey;"
  243.               filepickertitle="&selectSound.title;" oncommand="selectSound();"/>
  244.       <button id="previewSound" label="&previewSound.label;" accesskey="&previewSound.accesskey;"
  245.               oncommand="previewSound();"/>
  246.     </hbox>
  247.     <hbox align="center">
  248.       <checkbox id="displayIcon" label="&displayIcon.label;"
  249.                 preftype="bool" prefstring="privacy.popups.statusbar_icon_enabled"
  250.                 prefattribute="checked"/>
  251.     </hbox>
  252.     <separator class="thin"/>
  253.     <description>&popupNote.description;</description>
  254.     <data id="prefillWhitelist" preftype="bool" prefattribute="value" prefstring="privacy.popups.prefill_whitelist"/>
  255.     <data id="removeBlacklist" preftype="bool" prefattribute="value" prefstring="privacy.popups.remove_blacklist"/>
  256.   </groupbox>
  257.  
  258. </page>
  259.