home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2005 October
/
Gamestar_77_2005-10_dvd.iso
/
Programy
/
nsb-install-8-0.exe
/
chrome
/
toolkit.jar
/
content
/
mozapps
/
autofill
/
SetAutoLockTime.js
< prev
next >
Wrap
Text File
|
2005-07-29
|
6KB
|
185 lines
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
* Ben Goodger <ben@netscape.com>
* Blake Ross <blakeross@telocity.com>
* Joe Hewitt <hewitt@netscape.com>
*
* 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 NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function setLabelForNode(aNode, aLabel, aIsLabelFlag)
{
// This is for labels with possible accesskeys
var accessKeyIndex;
if (/^\&[^\&]/.test(aLabel)) { // access key is at the start
accessKeyIndex = 0;
} else {
accessKeyIndex = aLabel.search(/[^\&]\&[^\&]/) + 1;
if (accessKeyIndex == 0) {
accessKeyIndex = -1; // magic value for no accesskey
}
}
// If a character has an & before it, then it should become an accesskey
if (accessKeyIndex >= 0 && accessKeyIndex < aLabel.length - 1) {
// This will also cause the accesskey attribute to be set via xbl
aNode.accessKey = aLabel.charAt(accessKeyIndex + 1);
// Set the label to the string without the &
aLabel = aLabel.substr(0, accessKeyIndex) +
aLabel.substr(accessKeyIndex + 1);
}
aLabel = aLabel.replace(/\&\&/g, "&");
if (aIsLabelFlag) { // Set text for <label> element
aNode.setAttribute("value", aLabel);
} else { // Set text for other xul elements
aNode.label = aLabel;
}
}
function setAutolockOnLoad()
{
dump("*************in setAutolockOnLoad*************");
//get preferences
var prefs = GetPreferencesInterface();
var rbGroupElement = document.getElementById("radiogroup1");
if (prefs != null)
{
var selectedRadio = prefs.getCharPref("browser.preferences.autolock");
var selectedTime = prefs.getCharPref("browser.preferences.autolockTime");
var selectedTimeUnit = prefs.getCharPref("browser.preferences.autolockTimeUnit");
dump("*******The selected radiobutton is" + selectedRadio);
dump("*******The selected time is" + selectedTime);
dump("*******The selected time unit is" + selectedTimeUnit);
if(selectedRadio == "0")
{
rbGroupElement.selectedIndex = 0;
document.getElementById("timeTextbox").value = selectedTime;
if(selectedTimeUnit == "0")
document.getElementById("dropdownMenulist").selectedIndex = 0;
else
document.getElementById("dropdownMenulist").selectedIndex = 1;
}
else
rbGroupElement.selectedIndex = 1;
}
else
{
document.getElementById("timeTextbox").disabled = true;
document.getElementById("dropdownMenulist").disabled = true;
rbGroupElement.selectedIndex = 1;
}
}
function commonDialogReenableButtons()
{
document.documentElement.getButton("accept").disabled = false;
document.documentElement.getButton("extra1").disabled = false;
document.documentElement.getButton("extra2").disabled = false;
}
function setElementText(aElementID, aValue, aChildNodeFlag)
{
var element = document.getElementById(aElementID);
if (!aChildNodeFlag && element) {
setLabelForNode(element, aValue, true);
} else if (aChildNodeFlag && element) {
element.appendChild(document.createTextNode(aValue));
}
}
function GetPreferencesInterface()
{
return Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
}
function setCheckbox(aChkMsg, aChkValue)
{
if (aChkMsg) {
// XXX Would love to use hidden instead of collapsed, but the checkbox
// fails to size itself properly when I do this.
document.getElementById("checkboxContainer").removeAttribute("collapsed");
var checkboxElement = document.getElementById("checkbox");
setLabelForNode(checkboxElement, aChkMsg);
checkboxElement.checked = aChkValue > 0;
}
}
function unHideElementById(aElementID)
{
var element = document.getElementById(aElementID);
element.hidden = false;
}
function hideElementById(aElementID)
{
var element = document.getElementById(aElementID)
element.hidden = true;
}
function isVisible(aElementId)
{
return document.getElementById(aElementId).hasAttribute("hidden");
}
function setAutolockOnAccept()
{
var prefs = GetPreferencesInterface();
if (prefs)
{
if(document.getElementById("radio0").selected)
{
//save prefs
prefs.setCharPref("browser.preferences.autolock", "0");
prefs.setCharPref("browser.preferences.autolockTime", document.getElementById("timeTextbox").value);
prefs.setCharPref("browser.preferences.autolockTimeUnit", document.getElementById("dropdownMenulist").selectedItem.value);
}
else
prefs.setCharPref("browser.preferences.autolock", "1");
}
return true;
}