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
Wrap
Extensible Markup Language
|
2005-09-26
|
11KB
|
259 lines
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<!DOCTYPE page [
<!ENTITY % prefPopupsDTD SYSTEM "chrome://cookie/locale/pref-popups.dtd" >
%prefPopupsDTD;
]>
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="popupsPanel"
onload="parent.initPanel('chrome://cookie/content/pref-popups.xul');"
headertitle="&title;">
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["popupPolicy","playSound","playSoundUrl","displayIcon","removeBlacklist","prefillWhitelist"];
const nsIPermissionManager = Components.interfaces.nsIPermissionManager
const popupType = "popup";
var gPolicyCheckbox;
var gSoundCheckbox;
var gSoundUrlBox;
var gSoundUrlButton;
var gPreviewSoundButton;
var gIconCheckbox;
var permissionManager;
var ioService;
function Startup() {
permissionManager = Components.classes["@mozilla.org/permissionmanager;1"]
.getService(Components.interfaces.nsIPermissionManager);
ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
gPolicyCheckbox = document.getElementById("popupPolicy");
gSoundCheckbox = document.getElementById("playSound");
gSoundUrlBox = document.getElementById("playSoundUrl");
gSoundUrlButton = document.getElementById("selectSound");
gPreviewSoundButton = document.getElementById("previewSound");
gIconCheckbox = document.getElementById("displayIcon");
var removeBlacklist = (document.getElementById("removeBlacklist").getAttribute("value") == "true");
if (removeBlacklist) {
clearBlacklist();
document.getElementById("removeBlacklist").setAttribute("value", false);
}
var prefillWhitelist = (document.getElementById("prefillWhitelist").getAttribute("value") == "true");
if (prefillWhitelist) {
loadWhitelist();
document.getElementById("prefillWhitelist").setAttribute("value", false);
}
if (parent.queuedTag == "chrome://cookie/content/pref-popups.xul") {
// opened from About Popups menuitem
gPolicyCheckbox.checked = true;
parent.queuedTag = null;
}
setButtons();
}
function clearBlacklist() {
var enumerator = permissionManager.enumerator;
var hosts = [];
while (enumerator.hasMoreElements()) {
var permission = enumerator.getNext();
if (permission) {
permission = permission.QueryInterface(Components.interfaces.nsIPermission);
if ((permission.type == popupType) && (permission.capability == nsIPermissionManager.DENY_ACTION))
hosts[hosts.length] = permission.host;
}
}
for (var i = 0; i < hosts.length; i++) {
permissionManager.remove(hosts[i], popupType);
}
}
function loadWhitelist() {
try {
var whitelist;
var hosts;
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var prefs = prefService.getBranch(null);
whitelist = prefs.getComplexValue("privacy.popups.default_whitelist",
Components.interfaces.nsIPrefLocalizedString).data;
hosts = whitelist.split(",");
for (var i = 0; i < hosts.length; i++) {
var host = hosts[i];
host = "http://" + host;
var uri = ioService.newURI(host, null, null);
permissionManager.add(uri, popupType, true);
}
}
catch (ex) { }
}
function setButtons() {
var exceptionsButton = document.getElementById("exceptionsButton");
exceptionsButton.disabled = !gPolicyCheckbox.checked;
if (!gPolicyCheckbox.checked) {
gSoundCheckbox.disabled = true;
gSoundUrlBox.disabled = true;
gSoundUrlButton.disabled = true;
gPreviewSoundButton.disabled = true;
gIconCheckbox.disabled = true;
}
else {
gSoundCheckbox.disabled = false;
gSoundUrlBox.disabled = false;
gSoundUrlButton.disabled = false;
gPreviewSoundButton.disabled = false;
gIconCheckbox.disabled = false;
enableSoundUrl(gSoundCheckbox.checked);
}
}
function selectSound() {
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var filepicker = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
filepicker.init(window, document.getElementById("selectSound").getAttribute("filepickertitle"), nsIFilePicker.modeOpen);
filepicker.appendFilters(nsIFilePicker.filterAll);
var ret = filepicker.show();
if (ret == nsIFilePicker.returnOK)
gSoundUrlBox.value = filepicker.file.path;
onSoundInput();
}
function previewSound() {
var soundUrl = gSoundUrlBox.value;
var sound = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
if (soundUrl.indexOf("file://") == -1) {
sound.playSystemSound(soundUrl);
}
else {
var url = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURL);
url.spec = soundUrl;
sound.play(url)
}
}
function enableSoundUrl(soundChecked) {
gSoundUrlBox.disabled = !soundChecked;
gSoundUrlButton.disabled = !soundChecked;
if (soundChecked && gSoundUrlBox.value) {
gPreviewSoundButton.disabled = false;
}
else
gPreviewSoundButton.disabled = true;
}
function onSoundInput() {
gPreviewSoundButton.disabled = gSoundUrlBox.value == "";
}
function viewPopups() {
window.openDialog("chrome://communicator/content/popupManager.xul", "",
"chrome,resizable=yes", "");
}
]]>
</script>
<groupbox id="popupsArea">
<caption label="&popupBlocking.label;"/>
<hbox align="center">
<checkbox id="popupPolicy" label="&popupBlock.label;" accesskey="&popupBlock.accesskey;"
oncommand="setButtons()"
preftype="bool" prefstring="dom.disable_open_during_load"
prefattribute="checked"/>
<spacer flex="1"/>
<button id="exceptionsButton" label="&popupExceptions.label;"
accesskey="&popupExceptions.accesskey;"
oncommand="viewPopups();"/>
</hbox>
<separator class="thin"/>
<description id="whenBlock">&whenBlock.description;</description>
<hbox align="center">
<checkbox id="playSound" label="&playSound.label;"
oncommand="enableSoundUrl(this.checked);"
preftype="bool" prefstring="privacy.popups.sound_enabled"
prefattribute="checked"/>
</hbox>
<hbox align="center">
<textbox flex="1" id="playSoundUrl"
prefstring="privacy.popups.sound_url" oninput="onSoundInput()"/>
<button id="selectSound" label="&selectSound.label;" accesskey="&selectSound.accesskey;"
filepickertitle="&selectSound.title;" oncommand="selectSound();"/>
<button id="previewSound" label="&previewSound.label;" accesskey="&previewSound.accesskey;"
oncommand="previewSound();"/>
</hbox>
<hbox align="center">
<checkbox id="displayIcon" label="&displayIcon.label;"
preftype="bool" prefstring="privacy.popups.statusbar_icon_enabled"
prefattribute="checked"/>
</hbox>
<separator class="thin"/>
<description>&popupNote.description;</description>
<data id="prefillWhitelist" preftype="bool" prefattribute="value" prefstring="privacy.popups.prefill_whitelist"/>
<data id="removeBlacklist" preftype="bool" prefattribute="value" prefstring="privacy.popups.remove_blacklist"/>
</groupbox>
</page>