home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
komunikace
/
kmeleon
/
K-Meleon1.1.3en-US.exe
/
chrome
/
newsfox.jar
/
content
/
newsfox
/
programOptions.js
< prev
next >
Wrap
Text File
|
2007-09-06
|
7KB
|
196 lines
/* ***** 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 NewsFox.
*
* The Initial Developer of the Original Code is
* Andy Frank <andy@andyfrank.com>.
* Portions created by the Initial Developer are Copyright (C) 2005-2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Andrey Gromyko <andrey@gromyko.name>
* Ron Pruitt <wa84it@gmail.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 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 ***** */
var curDir = "";
var processedDir = "";
var canAccept = true;
function init()
{
var style = window.arguments[0].style;
var list = document.getElementById("style");
list.selectedIndex = style-1;
var args = window.arguments[0];
document.getElementById("cbCheckOnStartup").checked = args.checkOnStartup;
document.getElementById("cbAutoRefresh").checked = args.autoRefresh;
document.getElementById("autoRefreshInterval").value = args.autoRefreshInterval;
document.getElementById("autoRefreshInterval").disabled = !args.autoRefresh;
document.getElementById("cbNotifyUponNew").checked = args.notifyUponNew;
document.getElementById("cbConfirmDelete").checked = args.confirmDelete;
var keyIndex = args.keyIndex;
document.getElementById("shortcut").selectedIndex = keyIndex;
if (keyIndex != 3) document.getElementById("custshortcut").hidden = true;
curDir = args.nfDir;
document.getElementById("nfdir").value = curDir;
var dat = new Date(NEWSFOX_DATE);
document.getElementById("date0").label = displayDate(dat,0);
document.getElementById("date1").label = displayDate(dat,1);
document.getElementById("date2").label = displayDate(dat,2);
document.getElementById("dateStyle").selectedIndex = -1;
document.getElementById("dateStyle").selectedIndex = args.dateStyle;
}
function doAccept()
{
if (!canAccept)
{
canAccept = true;
return false;
}
const NF_SB = document.getElementById("newsfox-string-bundle");
var args = window.arguments[0];
var elem = document.getElementById("style");
args.style = parseInt(elem.value);
args.checkOnStartup = document.getElementById("cbCheckOnStartup").checked;
args.autoRefresh = document.getElementById("cbAutoRefresh").checked;
elem = document.getElementById("autoRefreshInterval");
args.autoRefreshInterval = parseInt(elem.value);
args.notifyUponNew = document.getElementById("cbNotifyUponNew").checked;
args.confirmDelete = document.getElementById("cbConfirmDelete").checked;
args.newKeyIndex = document.getElementById("shortcut").selectedIndex;
args.dateStyle = document.getElementById("dateStyle").selectedIndex;
var nfDir = document.getElementById("nfdir").value;
args.nfDir = nfDir;
var mvContents = document.getElementById("mvNfDir").selectedIndex;
args.mvContents = mvContents;
if (mvContents < 2 && curDir != nfDir)
{
var nsIPH = Components.classes["@mozilla.org/network/protocol;1?name=file"].createInstance(Components.interfaces.nsIFileProtocolHandler);
var nfDirFile = nsIPH.getFileFromURLSpec(nfDir);
var dirNotEmpty = NF_SB.getString('dirNotEmpty');
if (nfDirFile.directoryEntries.hasMoreElements()) // not empty
if (!window.confirm(dirNotEmpty))
{
document.getElementById("nfdir").value = curDir;
checkDir();
return false;
}
}
if( args.autoRefresh )
{
var autoCheckIntervalWarning = NF_SB.getString('autoCheckIntervalWarning');
if( 10 > args.autoRefreshInterval )
alert(autoCheckIntervalWarning);
}
args.ok = true;
}
function cbAutoRefreshOnCommand()
{
document.getElementById("autoRefreshInterval").disabled = !document.getElementById("cbAutoRefresh").checked;
}
function chooseDir()
{
var nsIPH = Components.classes["@mozilla.org/network/protocol;1?name=file"].createInstance(Components.interfaces.nsIFileProtocolHandler);
var url = document.getElementById("nfdir").value;
var file = nsIPH.getFileFromURLSpec(url);
var picker = nfDirPicked(file);
if (picker)
{
var nfdir = nsIPH.getURLSpecFromFile(picker.file);
processDir(nfdir);
}
}
function checkDir()
{
canAccept = true;
var nfdir = document.getElementById("nfdir").value;
if (nfdir == "") nfdir = curDir;
if (nfdir.charAt(nfdir.length-1) != "/") nfdir += "/";
document.getElementById("nfdir").value = nfdir;
if (nfdir == processedDir) return true;
var nsIPH = Components.classes["@mozilla.org/network/protocol;1?name=file"].createInstance(Components.interfaces.nsIFileProtocolHandler);
const NF_SB = document.getElementById("newsfox-string-bundle");
try
{ var nffile = nsIPH.getFileFromURLSpec(nfdir); }
catch(e)
{
alert(NF_SB.getString('badDir'));
document.getElementById("nfdir").value = curDir;
canAccept = false;
return false;
}
if (!nffile.exists())
{
if (window.confirm(NF_SB.getString('createDir')))
nffile.create(0x01, 0750);
else
nfdir = curDir;
}
processDir(nfdir);
return false;
}
function processDir(nfdir)
{
canAccept = false;
document.getElementById("nfdir").value = nfdir;
processedDir = nfdir;
var mvContents = document.getElementById("mvNfDirHBox");
if (curDir == nfdir)
mvContents.hidden = true;
else
{
document.getElementById("mvNFDirCopy").hidden = false;
document.getElementById("mvNFDirMove").hidden = false;
document.getElementById("mvChild").hidden = true;
document.getElementById("mvParent").hidden = true;
mvContents.hidden = false;
if (nfdir.indexOf(curDir) > -1 || curDir.indexOf(nfdir) > -1)
{
document.getElementById("mvNFDirCopy").hidden = true;
document.getElementById("mvNFDirMove").hidden = true;
document.getElementById("mvNfDir").selectedIndex = 2;
if (nfdir.indexOf(curDir) > -1)
document.getElementById("mvChild").hidden = false;
else
document.getElementById("mvParent").hidden = false;
}
}
window.sizeToContent();
}