www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

proxy.js (2735B)


      1 /*
      2     ***** BEGIN LICENSE BLOCK *****
      3     
      4     Copyright © 2009 Center for History and New Media
      5                      George Mason University, Fairfax, Virginia, USA
      6                      http://zotero.org
      7     
      8     This file is part of Zotero.
      9     
     10     Zotero is free software: you can redistribute it and/or modify
     11     it under the terms of the GNU Affero General Public License as published by
     12     the Free Software Foundation, either version 3 of the License, or
     13     (at your option) any later version.
     14     
     15     Zotero is distributed in the hope that it will be useful,
     16     but WITHOUT ANY WARRANTY; without even the implied warranty of
     17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     18     GNU Affero General Public License for more details.
     19     
     20     You should have received a copy of the GNU Affero General Public License
     21     along with Zotero.  If not, see <http://www.gnu.org/licenses/>.
     22     
     23     
     24     Utilities based in part on code taken from Piggy Bank 2.1.1 (BSD-licensed)
     25     
     26     ***** END LICENSE BLOCK *****
     27 */
     28 
     29 /**
     30  * Interface for proxy.xul add proxy confirmation dialog
     31  * @namespace
     32  */
     33 var Zotero_Proxy_Dialog = new function() {
     34 	var halfSecondsRemaining = 4;
     35 	var acceptButton;
     36 	var addString;
     37 	
     38 	/**
     39 	 * Initializes dialog
     40 	 */
     41 	this.init = function() {
     42 		document.getElementById("description").firstChild.nodeValue = Zotero.getString("proxies.recognized.message",
     43 			[window.arguments[0].site, window.arguments[0].proxy]);
     44 		acceptButton = document.documentElement.getButton("accept")
     45 		acceptButton.disabled = true;
     46 		addString = Zotero.getString("proxies.recognized.add");
     47 		var prefs = Components.classes["@mozilla.org/preferences-service;1"]
     48 							  .getService(Components.interfaces.nsIPrefBranch);
     49 		halfSecondsRemaining = Math.round(prefs.getIntPref("security.dialog_enable_delay")/500)+1;
     50 		_updateRemaining();
     51 	}
     52 	
     53 	/**
     54 	 * Called when "Add" button is pressed
     55 	 */
     56 	this.accept = function() {
     57 		window.arguments[0].disable = false;//document.getElementById("disable").checked;
     58 		window.arguments[0].add = true;
     59 	}
     60 	
     61 	/**
     62 	 * Called when "Ignore" button is pressed
     63 	 */
     64 	this.cancel = function() {
     65 		window.arguments[0].disable = false;//document.getElementById("disable").checked;
     66 		window.arguments[0].add = false;
     67 	}
     68 	
     69 	/**
     70 	 * Updates the number of seconds the accept button remains disabled, then sets a timeout to call
     71 	 * itself again, or alternatively, enables the button
     72 	 * @inner
     73 	 */
     74 	function _updateRemaining() {
     75 		halfSecondsRemaining--;
     76 		if(halfSecondsRemaining == 0) {
     77 			acceptButton.disabled = false;
     78 			acceptButton.label = addString;
     79 		} else {
     80 			acceptButton.label = addString+" ("+halfSecondsRemaining+")";
     81 			window.setTimeout(_updateRemaining, 500);
     82 		}
     83 	}
     84 }