mozdev.org

Mozile (xhtml editing in your browser)    

resources:
Overview

warning.xul

Summary

A "warning" dialog for the Mozile Extension which allows the user to choose whether or not to enhance the Mozile editor on a given page.

Version: 0.7

Author: James A. Overton


Method Summary
static void mozileRemovePref(pref, value)
          
static void mozileWarningAccept()
          
static void mozileWarningInit()
          

<?xml version="1.0" encoding="UTF-8"?>

<!--
/* ***** BEGIN LICENSE BLOCK *****
 * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * Full Terms at http://mozile.mozdev.org/license2.html
 *
 * 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 James A. Overton's code (james@overton.ca).
 *
 * The Initial Developer of the Original Code is James A. Overton.
 * Portions created by the Initial Developer are Copyright (C) 2005-2006
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *	James A. Overton <james@overton.ca>
 *
 * ***** END LICENSE BLOCK ***** */

/** 
 * @fileoverview A "warning" dialog for the Mozile Extension which allows the user to choose whether or not to enhance the Mozile editor on a given page.
 * @link http://mozile.mozdev.org 
 * @author James A. Overton <james@overton.ca>
 * @version 0.7
 */
-->

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozile/content/core/interface.css" type="text/css"?>
<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        xmlns:html="http://www.w3.org/1999/xhtml"
        id="MozileWarning"
        class="mozileInterface"
        orient="vertical"
        title="Mozile Warning"
  	  	flex="1"
  	  	onload="this.moveToAlertPosition(); this.sizeToContent(); mozileWarningInit()"
        buttons="cancel,accept"
  	  	buttonlabelaccept="Enhance"
  	  	ondialogaccept="mozileWarningAccept()"
  	  	width="360px">


	<script type="application/x-javascript">	
	
	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

	var mozilePrefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch(null);	
	
	var host = window.arguments[0];

	function mozileWarningInit() {
		var trustedSite = document.getElementById("trustedSite");
		var autoEnhanceSite = document.getElementById("autoEnhanceSite");
		if(host) {
			trustedSite.label = trustedSite.label.replace("this web site", host);
			autoEnhanceSite.label = autoEnhanceSite.label.replace("this web site", host);
		}
		if(window.arguments[1]) {
			autoEnhanceSite.checked = window.arguments[1];
		}
	}
	
	function mozileWarningAccept() {
		var trustedSite = document.getElementById("trustedSite");
		if(trustedSite.checked) mozileSetPref("mozile.trustedSites", host);
		else mozileRemovePref("mozile.trustedSites", host);
		
		var autoEnhanceSite = document.getElementById("autoEnhanceSite");
		if(autoEnhanceSite.checked) mozileSetPref("mozile.autoEnhanceSites", host);
		else mozileRemovePref("mozile.autoEnhanceSites", host);
		
		var neverWarn = document.getElementById("neverWarn");
		if(neverWarn.checked) mozilePrefs.setBoolPref("mozile.neverWarn", true);
		
		opener.mozileExtension.enhancePage();
	}
	
	function mozileSetPref(pref, value) {	
		var prefArray = mozilePrefs.getCharPref(pref).split(";");
		prefArray = prefString.split(";");
		for(var i=0; i &lt; prefArray.length; i++) {
			if(value == prefArray[i]) return;
		}
		prefArray.push(value);
		mozilePrefs.setCharPref(pref, prefArray.join(";"));
	}
	
	function mozileRemovePref(pref, value) {	
		var prefArray = mozilePrefs.getCharPref(pref).split(";");
		for(var i=0; i &lt; prefArray.length; i++) {
			if(value == prefArray[i]) prefArray[i]=undefined;
		}
		mozilePrefs.setCharPref(pref, prefArray.join(";"));
	}
	</script>


	<hbox class="header">
		<label value="Mozile Warning" />
	</hbox>
	
	<vbox>
		<description>Mozile can enhance Mozile editors in pages on the World Wide Web. Enhancements include access to the system clipboard, and saving files on the local computer. There is a security risk when a page is enhanced. Only enhance pages that you trust.</description>
		<checkbox id="trustedSite" label="Always trust this web site." checked="false"/>
		<checkbox id="autoEnhanceSite" label="Automatically enhance when editing this web site." checked="false"/>
		<checkbox id="neverWarn" label="Do not show warnings." checked="false"/>
	</vbox>


</dialog>


Documentation generated by JSDoc on Wed Nov 1 15:11:15 2006

The mozile project can be contacted through the mailing list or the member list.
Copyright © 2000-2019. All rights reserved. Terms of Use & Privacy Policy.