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
/
ui.js
< prev
Wrap
Text File
|
2007-10-15
|
45KB
|
1,579 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 ***** */
////////////////////////////////////////////////////////////////
// Global
////////////////////////////////////////////////////////////////
// shared with rss.js
var gAutoRefreshTimer = null;
var gCheckInProgress = false;
var gFeedsToCheck = new Array();
var gNewItemsCount = 0;
var gNumToCheck;
var gDisplayArticle = true;
// ui.js only
var defaultURL = "";
var firstLoad = true;
var loadIndex;
var initNewsfox = false;
var clean = false;
////////////////////////////////////////////////////////////////
// Lifecycle
////////////////////////////////////////////////////////////////
function startup()
{
// This method was getting called twice, not sure why
// so short circuit if method already invoked.
if (initNewsfox) return;
initNewsfox = true;
if (navigator.userAgent.indexOf('K-Meleon') > -1) gKMeleon = true;
if (navigator.userAgent.indexOf('Firefox\/3') > -1 || navigator.userAgent.indexOf('GranParadiso') > -1) gFF3 = true;
document.getElementById("notBusyText").value = NEWSFOX + " " + VERSION;
gOptions.startup();
doHorizontal(gOptions.horiz);
makeCss();
getAccel();
gCollect = new EmptyCollection();
loadModels();
backupOpml();
setTimeout(loadAllFeeds,30);
doLivemarks();
frames["hrefContent"].location.href = "chrome://newsfox/content/help/start.xhtml";
var newFeedUrl = gOptions.addUrl;
if (newFeedUrl != "") addFeedUrl();
if(gOptions.checkOnStartup)
{
if (newFeedUrl != "" && !gCheckInProgress)
gFeedsToCheck.push(newFeedUrl); // check new feed first
checkFeeds();
}
if( gOptions.autoRefresh )
gAutoRefreshTimer = setTimeout(this.checkFeeds, gOptions.autoRefreshInterval * 60 * 1000);
}
function saveModels()
{
saveFeedModel();
saveGroupModel();
saveIndices();
}
function refreshModel()
{
loadFeedModel();
loadGroupModel();
loadIndices();
var tree = document.getElementById("newsfox.feedTree");
tree.view = new FeedTreeModel();
}
function refreshModelSelect(index)
{
var feedtree = document.getElementById("newsfox.feedTree");
var fRow = feedtree.treeBoxObject.getFirstVisibleRow();
feedtree.view = new FeedTreeModel();
feedtree.treeBoxObject.scrollToRow(fRow);
feedtree.view.selection.select(index);
feedtree.treeBoxObject.ensureRowIsVisible(index);
}
function cleanup()
{
if (!initNewsfox) return;
if (clean) return;
if( null != gAutoRefreshTimer )
clearTimeout(gAutoRefreshTimer);
gOptions.rmObserver();
saveFeedModel();
saveGroupModel();
saveIndices();
clean = true;
}
function fixIndices()
{
for (var i=0; i<gFdGroup.length; i++)
{
gIdx.fdgp[i] = i;
gIdx.feed[i] = -1;
gIdx.catg[i] = 0;
gIdx.open[i] = gFdGroup[i].expanded = false;
}
gIdx.fdgp.length = gIdx.feed.length = gIdx.catg.length = gIdx.open.length = gFdGroup.length;
var feedtree = document.getElementById("newsfox.feedTree");
feedtree.view = new FeedTreeModel();
saveIndices();
// check all feeds in group 0
var modelSize = gFmodel.size();
var isIn = new Array();
for (i=0; i<modelSize; i++) isIn[i] = false;
for (i=0; i<gFdGroup[0].list.length; i++)
isIn[gFdGroup[0].list[i]] = true;
for (i=0; i<modelSize; i++)
if (!isIn[i]) gFdGroup[0].list.push(i);
// check no higher numbered feeds
for (i=0; i<gFdGroup.length; i++)
for (var j=0; j<gFdGroup[i].list.length; j++)
if (gFdGroup[i].list[j] >= modelSize)
gFdGroup[i].list.splice(j,1);
}
function loadModels()
{
var file = getProfileDir();
file.append("master.xml");
var hasFeeds = file.exists();
var file = getProfileDir();
file.append("master_index.xml");
var hasGroups = file.exists();
if (!hasGroups)
{
gFdGroup[0] = new FeedGroup();
gFdGroup.length = 1;
const NF_SB = document.getElementById("newsfox-string-bundle");
gFdGroup[0].title = NF_SB.getString('FEEDS');
gFdGroup[0].expanded = false;
gIdx.fdgp[0] = 0;
gIdx.feed[0] = -1;
gIdx.catg[0] = 0;
gIdx.open[0] = false;
if (hasFeeds)
{
loadFeedModel();
for (var i=0; i<gFmodel.size(); i++)
gFdGroup[0].list[i] = i;
gFdGroup[0].list.length = gFmodel.size();
}
else
{
gFdGroup[0].list.length = 0;
}
saveGroupModel();
saveIndices();
}
if (hasFeeds) loadFeedModel();
loadGroupModel();
loadIndices();
var feedtree = document.getElementById("newsfox.feedTree");
feedtree.view = new FeedTreeModel();
if (!hasGroups && hasFeeds) feedtree.view.toggleOpenState(0);
}
function loadAllFeeds()
{
if (!firstLoad) return;
firstLoad = false;
loadIndex = gFmodel.size() - 1;
if (loadIndex < 0) return;
setTimeout(loadAFeed,30);
}
function loadAFeed()
{
if (loadIndex == 0) return;
loadFeed(gFmodel.get(loadIndex));
loadIndex--;
setTimeout(loadAFeed,30);
}
////////////////////////////////////////////////////////////////
// Commands
////////////////////////////////////////////////////////////////
/**
* Check feeds for new items.
*/
function feedCheck(button)
{
// need to pass array of URLs in case feeds are deleted during check
if (gCheckInProgress) return;
gCheckInProgress = true;
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
var level = feedtree.view.getLevel(index);
if (index == -1 || button) level = -1;
var elem = document.getElementById("busyText");
elem.removeAttribute("hidden");
var elem = document.getElementById("notBusyText");
elem.hidden = "true";
switch(level)
{
case 0: // check in group
var curGrp = gIdx.fdgp[index];
for (var i=0; i<gFdGroup[curGrp].list.length; i++)
gFeedsToCheck.push(gFmodel.get(gFdGroup[curGrp].list[i]).url);
break;
case 2: // in category, check its feed
while (feedtree.view.getLevel(index) != 1) index--;
feedtree.view.toggleOpenState(index);
feedtree.view.selection.select(index);
case 1: // check feed
gFeedsToCheck.push(gFmodel.get(gIdx.feed[index]).url);
break;
case -1: // none selected or button, do auto
var autoFeed = false;
if (gFeedsToCheck.length > 0) autoFeed = true;
if( null != gAutoRefreshTimer )
clearTimeout(gAutoRefreshTimer);
for (var i=0; i<gFdGroup[0].list.length; i++)
if (gFmodel.get(gFdGroup[0].list[i]).autoCheck)
gFeedsToCheck.push(gFmodel.get(gFdGroup[0].list[i]).url);
var rootList = gFdGroup[0].list;
var checkLast = gFmodel.get(rootList[rootList.length-1]).autoCheck;
if (autoFeed)
if (checkLast) gFeedsToCheck.length--; // don't do new feed twice
else gFeedsToCheck.shift(); // don't do new feed at all
}
gNumToCheck = gFeedsToCheck.length;
gNewItemsCount = 0;
precheckFeed(gFeedsToCheck);
}
/**
* Auto check feeds.
*/
function checkFeeds()
{
if (gCheckInProgress) setTimeout(checkFeeds,500);
feedCheck(true);
}
/**
* Add a new group.
*/
function addGroup(isSearch)
{
var num = gFdGroup.length;
var grp = new FeedGroup();
if (isSearch) grp.search = true;
gFdGroup.push(grp);
var index = gIdx.fdgp.length;
gIdx.fdgp.push(num);
gIdx.feed.push(-1);
gIdx.catg.push(0);
gIdx.open.push(false);
saveIndices();
saveGroupModel();
var feedtree = document.getElementById("newsfox.feedTree");
feedtree.treeBoxObject.rowCountChanged(index,1);
showGroupOptions(index,true,isSearch);
}
/**
* Delete a group.
*/
function deleteGroup(confirm)
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
if (feedtree.view.getLevel(index) != 0) return;
var curGrp = gIdx.fdgp[index];
if (curGrp == 0) return;
const NF_SB = document.getElementById("newsfox-string-bundle");
var confirmationMessage = NF_SB.getString('confirmation.deleteGroup');
confirmationMessage += "\n\n" + gFdGroup[curGrp].title;
if (!confirm || !gOptions.confirmDelete || window.confirm(confirmationMessage))
{
if (gFdGroup[curGrp].expanded) feedtree.view.toggleOpenState(index);
gFdGroup.splice(curGrp,1);
for (var i=index+1;i < gIdx.fdgp.length;i++)
gIdx.fdgp[i]--;
gIdx.fdgp.splice(index,1);
gIdx.feed.splice(index,1);
gIdx.catg.splice(index,1);
gIdx.open.splice(index,1);
feedtree.treeBoxObject.rowCountChanged(index,-1);
saveGroupModel();
saveIndices();
if (index >= gIdx.fdgp.length) index = gIdx.fdgp.length - 1;
feedtree.view.selection.select(index);
}
}
/**
* Add a new feed.
*/
function addFeed(isStartup)
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
var pRow = feedtree.treeBoxObject.getFirstVisibleRow();
var pGrp = gIdx.fdgp[index];
var pFeed = gIdx.feed[index];
var exp0 = gFdGroup[0].expanded;
var url = defaultURL;
createNewFeed(gFmodel, url, false, true);
var nFeed = gFmodel.size() - 1;
index = 0;
while (nFeed != gIdx.feed[index]) index++;
if (!isStartup)
{
index = showFeedOptions(index,true);
if (gOptions.selectAddedFeed)
{
if (!exp0 && gIdx.fdgp[index] != 0)
{
feedtree.view.toggleOpenState(0);
feedtree.treeBoxObject.scrollToRow(pRow);
feedtree.treeBoxObject.ensureRowIsVisible(feedtree.currentIndex);
}
}
else
{
if (!exp0) feedtree.view.toggleOpenState(0);
var i = gIdx.fdgp.length-1;
while ((gIdx.fdgp[i] != pGrp || gIdx.feed[i] != pFeed) && i > 0) i--;
feedtree.treeBoxObject.scrollToRow(pRow);
feedtree.view.selection.select(i);
feedtree.treeBoxObject.ensureRowIsVisible(i);
}
}
else
{
feedCheck(false);
feedtree.view.selection.select(index);
}
}
function addFeedUrl()
{
var isStartup = false;
if (gOptions.addUrl == NEWSFOX_RSS) isStartup = true;
defaultURL = gOptions.addUrl;
gOptions.addUrl = "";
gOptions.save();
if (!isStartup || gFmodel.size() == 0) addFeed(isStartup);
defaultURL = "";
}
function deleteRow()
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
var level = feedtree.view.getLevel(index);
if (level == 1) deleteFeed(index,true);
else if (level == 0) deleteGroup(true);
}
function deleteSingleFeedRow()
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
if (feedtree.view.getLevel(index) != 1) return;
var nGrp = gIdx.fdgp[index];
if (nGrp == 0) return;
var nFeed = gIdx.feed[index];
if (!(index + 1 < gIdx.feed.length && gIdx.feed[index+1] >= 0)) // next is not feed
index--;
for (var j=gFdGroup[nGrp].list.length-1; j>=0; j--)
if (gFdGroup[nGrp].list[j] == nFeed)
gFdGroup[nGrp].list.splice(j,1);
if (gFdGroup[nGrp].list.length == 0) gIdx.open[getGroupRow(nGrp)] = gFdGroup[nGrp].expanded = false;
for (var i=gIdx.feed.length-1; i>=0; i--)
if (gIdx.fdgp[i] == nGrp && gIdx.feed[i] == nFeed)
{
gIdx.fdgp.splice(i,1);
gIdx.feed.splice(i,1);
gIdx.catg.splice(i,1);
gIdx.open.splice(i,1);
feedtree.treeBoxObject.rowCountChanged(i,-1);
}
feedtree.view.selection.select(index);
}
/**
* Permanently delete a feed.
*/
function deleteFeed(index,confirm)
{
var feedtree = document.getElementById("newsfox.feedTree");
var fRow = feedtree.treeBoxObject.getFirstVisibleRow();
if (index == -1) index = feedtree.currentIndex;
if (feedtree.view.getLevel(index) != 1) return;
var nGrp = gIdx.fdgp[index];
var nFeed = gIdx.feed[index];
var newFeed;
if (index + 1 < gIdx.feed.length && gIdx.feed[index+1] >= 0)
newFeed = gIdx.feed[index+1];
else
newFeed = gIdx.feed[index-1];
if (newFeed > nFeed) newFeed--;
var feed = gFmodel.get(nFeed);
const NF_SB = document.getElementById("newsfox-string-bundle");
var confirmationMessage = NF_SB.getString('confirmation.deleteFeed');
confirmationMessage += "\n\n" + feed.getDisplayName();
if (!confirm || !gOptions.confirmDelete || window.confirm(confirmationMessage))
{
deleteFeedFromDisk(feed);
for (var i=0; i<gFdGroup.length; i++)
for (var j=0; j<gFdGroup[i].list.length; j++)
if (gFdGroup[i].list[j] >= nFeed)
(gFdGroup[i].list[j] == nFeed) ? gFdGroup[i].list[j]=-2 : gFdGroup[i].list[j]--;
for (i=0; i<gIdx.feed.length; i++)
if (gIdx.feed[i] >= nFeed)
(gIdx.feed[i] == nFeed) ? gIdx.feed[i]=-2 : gIdx.feed[i]--;
for (var i=0; i<gFdGroup.length; i++)
{
for (var j=gFdGroup[i].list.length-1; j>=0; j--)
if (gFdGroup[i].list[j] == -2)
gFdGroup[i].list.splice(j,1);
if (gFdGroup[i].list.length == 0) gIdx.open[getGroupRow(i)] = gFdGroup[i].expanded = false;
}
for (i=gIdx.feed.length-1; i>=0; i--)
if (gIdx.feed[i] == -2)
{
gIdx.fdgp.splice(i,1);
gIdx.feed.splice(i,1);
gIdx.catg.splice(i,1);
gIdx.open.splice(i,1);
feedtree.treeBoxObject.rowCountChanged(i,-1);
}
gFmodel.remove(feed);
saveModels();
feedtree.treeBoxObject.scrollToRow(fRow);
if (newFeed < 0)
feedtree.view.selection.select(getGroupRow(nGrp));
else
feedtree.view.selection.select(getFeedRow(nGrp,newFeed));
setTitle();
}
}
/**
* Delete articles.
*/
function deleteArticle()
{
try
{
var tree = document.getElementById("newsfox.feedTree");
var index = tree.currentIndex;
var feed = gFmodel.get(gIdx.feed[index]);
const NF_SB = document.getElementById("newsfox-string-bundle");
var confirmationMessage = NF_SB.getString('confirmation.deleteArticles');
if (gOptions.confirmDelete && !confirm(confirmationMessage))
return;
// Regular delete
var arttree = document.getElementById("newsfox.articleTree");
for (var i=0; i<gCollect.size(); i++)
if (arttree.view.selection.isSelected(i))
gCollect.getFeed(i).deleteById(gCollect.get(i).id);
if (gCollect.type == 0 || gCollect.type == 3) // group or search
{
var curGrp = gFdGroup[gCollect.grpindex];
for (i=0; i<curGrp.list.length; i++)
saveFeed(gFmodel.get(curGrp.list[i]));
}
else // feed or category
saveFeed(feed);
saveFeedModel();
// Update unread count
tree = document.getElementById("newsfox.feedTree");
tree.treeBoxObject.invalidate();
feedSelected(); // need new collection
setTitle();
}
catch (err)
{
var msg = "deleteArticle(): " + err;
alert(msg);
}
}
/**
* Open articles.
*/
function openArticle()
{
try
{
var arttree = document.getElementById("newsfox.articleTree");
for (var i=0; i<gCollect.size(); i++)
if (arttree.view.selection.isSelected(i))
openNewTab(gCollect.get(i).link);
}
catch (err)
{
var msg = "openArticle(): " + err;
alert(msg);
}
}
function catchUp(doflag)
{
var feedtree = document.getElementById("newsfox.feedTree");
feedtree.view.selection.select(0);
markFlaggedUnread(doflag,true);
}
function markFlaggedUnread(doflag,read)
{
for(var i=0; i < gCollect.size(); i++)
{
var flagged = gCollect.isFlagged(i);
gCollect.setRead(i, doflag ? !flagged : (read ? true : false));
if (doflag) gCollect.setFlagged(i,0);
}
var feedtree = document.getElementById("newsfox.feedTree");
feedtree.treeBoxObject.invalidate();
var articleTree = document.getElementById("newsfox.articleTree");
articleTree.treeBoxObject.invalidate();
setTitle();
}
function openUnread()
{
var feedTree = document.getElementById("newsfox.feedTree");
if( feedTree.currentIndex == -1) return;
var article, read;
for(var i=0; i < gCollect.size(); i++)
{
article = gCollect.get(i);
read = gCollect.isRead(i);
gCollect.setRead(i,true);
if (!read) openNewTab(article.link);
}
feedTree.treeBoxObject.invalidate();
var articleTree = document.getElementById("newsfox.articleTree");
articleTree.treeBoxObject.invalidate();
}
/**
* Show help.
*/
function help()
{
frames["hrefContent"].location.href = "chrome://newsfox/content/help/overview.xhtml";
var contentDeck = document.getElementById("contentDeck");
contentDeck.selectedIndex = 0;
}
function showShortcuts()
{
var art = new Article();
var shortcutMenu = document.getElementById("help.shortcut");
art.title = shortcutMenu.label;
art.date = new Date();
art.category = "";
art.link = "";
art.body = "";
var keySet = document.getElementById("shortcut-keys");
var mods;
for (var i=keySet.firstChild; i != null; i=i.nextSibling)
{
mods = i.getAttribute("modifiers");
mods += (mods.length > 0) ? "-" : "";
art.body += i.getAttribute("label") + ": " + mods + i.getAttribute("key") + "<br/>";
}
const NF_SB = document.getElementById("newsfox-string-bundle");
var customShortcut = NF_SB.getString('customShortcut');
art.body += "<br/>" + customShortcut + "<br/>";
var contentDeck = document.getElementById("contentDeck");
resetIframe();
getTextView(art);
contentDeck.selectedIndex = 1;
}
/**
* Goto to homepage of selected feed.
*/
function home()
{
var tree = document.getElementById("newsfox.feedTree");
var feed = gFmodel.get( gIdx.feed[tree.currentIndex] );
openNewTab(feed.homepage);
}
////////////////////////////////////////////////////////////////
// Options
////////////////////////////////////////////////////////////////
/**
* Show global options.
*/
function showOptions()
{
var keyType = new Array();
var index = 0;
var keySet = document.getElementById("shortcut-keys");
for (var i=keySet.firstChild; i != null; i=i.nextSibling)
{
keyType[index] = 3; // 3 is custom
for (var j=0; j<3; j++)
{
var modMatch = (i.getAttribute("modifiers") == i.getAttribute("mod"+j));
var keyMatch = (i.getAttribute("key") == i.getAttribute("key"+j));
if (modMatch && keyMatch)
keyType[index] = j;
}
if (keyType[index] != keyType[0])
keyType[0] = 3; // it is custom
index++;
}
var keyIndex = keyType[0];
if (keySet.firstChild == null) keyIndex = 0;
var newKeyIndex, mvContents;
var curDir = getPref("global.directory", "str", "");
var params = { ok:false, style:gOptions.globalStyle, checkOnStartup:gOptions.checkOnStartup, autoRefresh:gOptions.autoRefresh, autoRefreshInterval:gOptions.autoRefreshInterval, notifyUponNew:gOptions.notifyUponNew, confirmDelete:gOptions.confirmDelete, keyIndex:keyIndex, newKeyIndex:newKeyIndex, nfDir:curDir, mvContents:mvContents, dateStyle:gOptions.dateStyle };
var win = window.openDialog("chrome://newsfox/content/programOptions.xul",
"newsfox-dialog","chrome,centerscreen,modal", params);
var oldAutoRefreshInterval = gOptions.autoRefreshInterval;
if (params.ok)
{
gOptions.globalStyle = params.style;
gOptions.checkOnStartup = params.checkOnStartup;
gOptions.autoRefresh = params.autoRefresh;
if( gOptions.autoRefresh )
{
if( gOptions.autoRefreshInterval != params.autoRefreshInterval )
{
if( null != gAutoRefreshTimer )
clearTimeout(gAutoRefreshTimer);
gAutoRefreshTimer = setTimeout(this.checkFeeds, params.autoRefreshInterval * 60 * 1000);
}
}
else if( null != gAutoRefreshTimer )
clearTimeout(gAutoRefreshTimer);
gOptions.autoRefreshInterval = params.autoRefreshInterval;
gOptions.notifyUponNew = params.notifyUponNew;
gOptions.confirmDelete = params.confirmDelete;
gOptions.dateStyle = params.dateStyle;
newKeyIndex = params.newKeyIndex;
if (keyIndex != newKeyIndex) updateShortcuts(newKeyIndex);
gOptions.save(false);
if (curDir != params.nfDir)
{
var nsIPH = Components.classes["@mozilla.org/network/protocol;1?name=file"].createInstance(Components.interfaces.nsIFileProtocolHandler);
var feedtree = document.getElementById("newsfox.feedTree");
cleanup();
feedtree.view = null;
gMsgDone = true;
if (params.mvContents < 2) // copy or move
{
var oldDirFile = nsIPH.getFileFromURLSpec(curDir);
var newDirFile = nsIPH.getFileFromURLSpec(params.nfDir);
var newDirName = newDirFile.leafName;
var newDirParent = newDirFile.parent;
// TODO need to put up a progress meter if long copy
// doesn't work:
//var hithere = setTimeout(lttOn,500);
try
{
newDirFile.remove(true);
oldDirFile.copyTo(newDirParent,newDirName);
}
catch(err)
{
const NF_SB = document.getElementById("newsfox-string-bundle");
var dirNotChanged = NF_SB.getString('dirNotChanged');
alert(dirNotChanged + "\n\n" + err);
return;
}
//if (hithere != null) clearTimeout(hithere);
//loadingTooltip(false);
setPref("global.directory", "str", params.nfDir);
gNewsfoxDirURL = params.nfDir;
refreshModel();
if (params.mvContents == 1) oldDirFile.remove(true);
}
else
{
setPref("global.directory", "str", params.nfDir);
location.href = "chrome://newsfox/content/newsfox.xul";
}
}
}
return;
}
//function lttOn()
//{
// loadingTooltip(true);
//}
/**
* Show options dialog for current feed/group.
*/
function chooseOptions()
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
if (index == -1) return;
var level = feedtree.view.getLevel(index);
var isSearch = gFdGroup[gIdx.fdgp[index]].search;
if (level == 1) showFeedOptions(index,false);
else showGroupOptions(index,false,isSearch);
}
/**
* Show options dialog for current group/search.
*/
function showGroupOptions(index,isNew,isSearch)
{
// following two lines due to a bug in FF that sometimes doesn't
// hide context menu properly
var feedMenu = document.getElementById("feedMenu");
feedMenu.hidePopup();
var feedtree = document.getElementById("newsfox.feedTree");
var grp = gIdx.fdgp[index];
var expgrp = false;
if (grp != 0 && gFdGroup[grp].expanded)
{
feedtree.view.toggleOpenState(index);
expgrp = true;
}
var exp0 = false;
if (gFdGroup[0].expanded)
{
feedtree.view.toggleOpenState(0);
exp0 = true;
}
var feeds = new Array();
for (var i=0; i<gFmodel.size(); i++)
feeds.push(gFmodel.get(i));
var titlelist = new Array();
for (i=0; i<gFdGroup.length; i++)
titlelist.push(gFdGroup[i].title);
var lists = new Array();
lists[0] = new Array();
for (i=0; i<gFdGroup[0].list.length; i++)
lists[0].push(gFdGroup[0].list[i]);
lists[1] = new Array();
for (i=0; i<gFdGroup[grp].list.length; i++)
lists[1].push(gFdGroup[grp].list[i]);
var flagged = null;
var unread = null;
var text = null;
var textflags = null;
var startTime = null;
var endTime = null;
if (isSearch)
{
var srchdat = gFdGroup[grp].srchdat;
flagged = srchdat.flagged;
unread = srchdat.unread;
text = srchdat.text;
textflags = srchdat.textflags;
startTime = srchdat.startTime;
endTime = srchdat.endTime;
}
var params = { ok:false, grp:grp, newGrp:grp, feeds:feeds, titlelist:titlelist, lists:lists, flagged:flagged, unread:unread, text:text, textflags:textflags, startTime:startTime, endTime:endTime, isSearch:isSearch, fdGp:gFdGroup, isNew:isNew };
var win = window.openDialog("chrome://newsfox/content/groupOptions.xul",
"newsfox-dialog","chrome,centerscreen,modal", params);
if (params.ok)
{
if (isSearch)
{
gFdGroup[grp].srchdat.flagged = params.flagged;
gFdGroup[grp].srchdat.unread = params.unread;
gFdGroup[grp].srchdat.text = params.text;
gFdGroup[grp].srchdat.textflags = params.textflags;
gFdGroup[grp].srchdat.startTime = params.startTime;
gFdGroup[grp].srchdat.endTime = params.endTime;
}
gFdGroup[grp].title = params.titlelist[grp];
var feedslist = params.lists[0];
for (i=0; i<feedslist.length; i++)
gFdGroup[0].list[i] = feedslist[i];
gFdGroup[0].list.length = feedslist.length;
var grplist = params.lists[1];
for (i=0; i<grplist.length; i++)
gFdGroup[grp].list[i] = grplist[i];
gFdGroup[grp].list.length = grplist.length;
mvGrp(grp,params.newGrp);
grp = (params.newGrp >= grp) ? params.newGrp-1 : params.newGrp;
if (gFdGroup[grp].list.length == 0) expgrp = false;
saveIndices();
saveGroupModel();
loadGroupModel();
}
else // !params.ok
{
if (isNew)
{
index = getGroupRow(grp);
refreshModelSelect(index);
deleteGroup(false);
}
}
if (exp0) feedtree.view.toggleOpenState(0);
index = getGroupRow(grp);
if (expgrp) feedtree.view.toggleOpenState(index);
refreshModelSelect(index);
}
/**
* Show options dialog for current feed.
*/
function showFeedOptions(index,isNew)
{
var checkFeed = false;
var curGrp = gIdx.fdgp[index];
var nFeed = gIdx.feed[index];
var feed = gFmodel.get(nFeed);
var namearray = new Array();
var membarray = new Array();
var membarray2 = new Array();
var tmp, j;
for (var i=0; i<gFdGroup.length; i++)
{
namearray.push(gFdGroup[i].title);
tmp = 0;
for (j=0; j<gFdGroup[i].list.length; j++)
if (gFdGroup[i].list[j] == nFeed) tmp = 1;
membarray2.push(tmp);
if (gFdGroup[i].search)
if (isNew)
tmp = 3;
else
tmp += 2;
membarray.push(tmp);
}
var groupstr = namearray.join();
var groupmemb = membarray.join();
var params = { ok:false, name:feed.getDisplayName(), iconsrc:feed.icon.src, homepage:feed.homepage, url:feed.url, style:feed.style, deleteOld:feed.deleteOld, dontDeleteUnread:feed.dontDeleteUnread, autoCheck:feed.autoCheck, groupstr:groupstr, groupmemb:groupmemb, isNew:isNew, checkFeed:checkFeed, uid:feed.uid, model:gFmodel, daysToKeep:feed.daysToKeep };
var win = window.openDialog("chrome://newsfox/content/feedOptions.xul",
"newsfox-dialog","chrome,centerscreen,modal", params);
if (params.ok)
{
var newmembarray = params.groupmemb.split(",");
for (i=0; i<membarray2.length; i++)
{
var diff = newmembarray[i] - membarray2[i];
if (diff == 1) // adding
{
gFdGroup[i].list.push(nFeed);
if (gFdGroup[i].expanded)
{
var top = getGroupRow(i+1);
gIdx.fdgp.splice(top,0,i);
gIdx.feed.splice(top,0,nFeed);
gIdx.catg.splice(top,0,0);
gIdx.open.splice(top,0,false);
}
}
else if (diff == -1) // deleting
{
for (var j=gFdGroup[i].list.length-1; j>=0; j--)
if (gFdGroup[i].list[j] == nFeed)
gFdGroup[i].list.splice(j,1);
if (gFdGroup[i].list.length == 0) gIdx.open[getGroupRow(i)] = gFdGroup[i].expanded = false;
var grprow = getGroupRow(i);
var top = getGroupRow(i+1);
for (j=top-1; j>=grprow; j--)
if (gIdx.feed[j] == nFeed)
{
gIdx.fdgp.splice(j,1);
gIdx.feed.splice(j,1);
gIdx.catg.splice(j,1);
gIdx.open.splice(j,1);
}
}
}
feed.url = params.url.trim();
feed.style = params.style;
feed.deleteOld = params.deleteOld;
feed.dontDeleteUnread = params.dontDeleteUnread;
feed.daysToKeep = params.daysToKeep;
feed.autoCheck = params.autoCheck;
if (isNew)
{
var uid = gFmodel.makeUniqueUid(feed.url);
feed.uid = uid;
deleteFeedFromDisk(feed);
feed.defaultName = uid;
feed.homepage = null; // TODO feed.homepage gets set via downloadicon?
}
else
{
var val = params.name.trim();
if (val == feed.defaultName) feed.customName = ""
else feed.customName = val;
if (params.iconsrc == "")
feed.icon.src = ICON_OK;
else
feed.icon.src = params.iconsrc.trim();
feed.homepage = params.homepage.trim();
downloadIcon(feed);
}
saveModels();
if (isNew) curGrp++; // prefer not FEEDS group
index = getGroupRow(curGrp); // index may have changed, recompute
while (gIdx.feed[index] != nFeed && index < gIdx.fdgp.length) index++;
if (gIdx.feed[index] != nFeed)
{
index=0;
while (gIdx.feed[index] != nFeed && index < gIdx.fdgp.length) index++;
if (gIdx.feed[index] != nFeed) // can't happen, feed still exists
{
refreshModelSelect(0);
return 0;
}
}
refreshModelSelect(index);
if (params.checkFeed) feedCheck(false);
}
else // !params.ok
{
if (isNew)
{
// refreshModelSelect(index);
deleteFeed(index,false);
}
}
return index;
}
/**
* Troubleshoot feed errors.
*/
function troubleshoot()
{
var tree = document.getElementById("newsfox.feedTree");
var nFeed = gIdx.feed[tree.currentIndex];
if (nFeed < 0) return;
var feed = gFmodel.get(nFeed);
resetIframe();
var iframe = document.getElementById("buildContent");
var doc = iframe.contentDocument;
var summary = getErrorSummary(feed.error);
var remedies = getErrorRemedies(feed.error);
var b = doc.createElement("b");
b.appendChild(doc.createTextNode(summary));
doc.body.appendChild(b);
doc.body.appendChild(doc.createElement("hr"));
var p = doc.createElement("p");
p.innerHTML = remedies;
doc.body.appendChild(p);
if (feed.error.substring(0,1) == ERROR_INVALID_FEED_URL)
{
var p1 = doc.createElement("p");
var a1 = doc.createElement("a");
a1.setAttribute("href",FEED_VALIDATOR + escape(feed.url));
const NF_SB = document.getElementById("newsfox-string-bundle");
var feedValidator = NF_SB.getString('remedy_checkFeedValidator');
a1.innerHTML = feedValidator;
p1.appendChild(a1);
doc.body.appendChild(p1);
}
var p2 = doc.createElement("p");
var a2 = doc.createElement("a");
a2.setAttribute("href",feed.url);
a2.innerHTML = feed.url;
p2.appendChild(a2);
doc.body.appendChild(p2);
var contentDeck = document.getElementById("contentDeck");
contentDeck.selectedIndex = 1;
frames["hrefContent"].location.href = "about:blank";
}
////////////////////////////////////////////////////////////////
// Selection
////////////////////////////////////////////////////////////////
/**
* Feed selected.
*/
function feedSelected()
{
var tree = document.getElementById("newsfox.feedTree");
var index = tree.currentIndex;
var arttree = document.getElementById("newsfox.articleTree");
if (index == -1)
{
gCollect = new EmptyCollection();
arttree.view = null;
return;
}
var nFeed = gIdx.feed[index];
if (nFeed < 0) // group
{
loadingTooltip(true);
var grpindex = gIdx.fdgp[index];
var grp = gFdGroup[grpindex];
for (var i=0; i<grp.list.length; i++)
{
loadFeed(gFmodel.get(grp.list[i]));
setPmeter((100*i)/grp.list.length);
}
gCollect = new GroupCollection(grpindex, grp.search);
setPmeter(0);
loadingTooltip(false);
}
else if (nFeed >= 0) // feed
{
var feed = gFmodel.get(nFeed);
downloadIcon(feed);
loadFeed(feed);
feed.flags.length = feed.size();
//RPdebug if (feed.flags.length != feed.size())
//RPdebug alert("feed flags length " + feed.flags.length + " feed.size " + feed.size());
gCollect = new NormalCollection(nFeed, gIdx.catg[index],true);
}
arttree.view = null;
arttree.view = new ArticleTreeModel();
// troubleshoot();
}
/**
* Article selected.
*/
function articleSelected()
{
if (!gDisplayArticle) return;
var tree = document.getElementById("newsfox.articleTree");
var index = tree.currentIndex;
if (index == -1) return;
var art = gCollect.get(index);
var read = gCollect.isRead(index);
if (!read)
{
gCollect.setRead(index, true);
tree.treeBoxObject.invalidateRow(index);
var tree = document.getElementById("newsfox.feedTree");
tree.treeBoxObject.invalidate();
setTitle();
}
// Stop any previous page loading
var nsIWebNav = Components.interfaces.nsIWebNavigation;
var iframe = document.getElementById("hrefContent");
var webnav = iframe.docShell.QueryInterface(nsIWebNav);
webnav.stop(nsIWebNav.STOP_NETWORK);
var iframe = document.getElementById("buildContent");
var webnav = iframe.docShell.QueryInterface(nsIWebNav);
webnav.stop(nsIWebNav.STOP_NETWORK);
// Display body in content
var contentDeck = document.getElementById("contentDeck");
var style = gCollect.getFeed(index).getStyle();
if (style == 2 && art.link)
{
// Display as webpage
frames["hrefContent"].location.href = art.link;
contentDeck.selectedIndex = 0;
}
else
{
// display using innerHTML to resolve security issues pointed out by Wladimir Palant
resetIframe();
getTextView(art);
contentDeck.selectedIndex = 1;
}
}
function articleTreeMClicked()
{
var tree = document.getElementById("newsfox.articleTree");
var index = tree.currentIndex;
if (index == -1) return; // in header
var article = gCollect.get(index);
openNewTab(article.link);
}
function articleTreeDblClicked()
{
this.articleTreeMClicked();
}
/**
* Select the next unread article.
*/
function selectNextUnreadArticle()
{
var feedtree = document.getElementById("newsfox.feedTree");
var arttree = document.getElementById("newsfox.articleTree");
var row = feedtree.currentIndex;
if (row < 0) return;
var curGrp = gIdx.fdgp[row];
var artIndex = arttree.currentIndex;
if (artIndex < 0) artIndex = 0;
if (gCollect.type != 1) // group or category
{
for (var j = artIndex; j < gCollect.size(); j++)
if (!gCollect.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
}
else // feed
{
// current row
var feed = gFmodel.get(gIdx.feed[row]);
feedtree.view.selection.select(row);
feedtree.treeBoxObject.ensureRowIsVisible(row);
for (var j = artIndex; j < feed.size(); j++)
if (!feed.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
// rest of folder
while (++row < gIdx.fdgp.length && gIdx.fdgp[row] == curGrp)
{
feed = gFmodel.get(gIdx.feed[row]);
feedtree.view.selection.select(row);
feedtree.treeBoxObject.ensureRowIsVisible(row);
for (var j = 0; j < feed.size(); j++)
if (!feed.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
}
}
const NF_SB = document.getElementById("newsfox-string-bundle");
alert(NF_SB.getString('noNextUnread'));
}
/**
* Select the previous unread article.
*/
function selectPrevUnreadArticle()
{
var feedtree = document.getElementById("newsfox.feedTree");
var arttree = document.getElementById("newsfox.articleTree");
var row = feedtree.currentIndex;
if (row < 0) return;
var curGrp = gIdx.fdgp[row];
var artIndex = arttree.currentIndex;
if (artIndex < 0)
{
artIndex = gCollect.size()-1;
if (artIndex < 0) artIndex = 0;
}
if (gCollect.type != 1) // group or category
{
for (var j = artIndex; j >= 0; j--)
if (!gCollect.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
}
else // feed
{
// current row
var feed = gFmodel.get(gIdx.feed[row]);
feedtree.view.selection.select(row);
feedtree.treeBoxObject.ensureRowIsVisible(row);
for (var j = artIndex; j >= 0; j--)
if (!feed.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
// rest of folder
while (gIdx.fdgp[--row] == curGrp && gIdx.feed[row] > -1)
{
var feed = gFmodel.get(gIdx.feed[row]);
feedtree.view.selection.select(row);
feedtree.treeBoxObject.ensureRowIsVisible(row);
for (var j = feed.size()-1; j >= 0; j--)
if (!feed.isRead(j))
{
arttree.view.selection.select(j);
arttree.treeBoxObject.ensureRowIsVisible(j);
return;
}
}
}
const NF_SB = document.getElementById("newsfox-string-bundle");
alert(NF_SB.getString('noPrevUnread'));
}
////////////////////////////////////////////////////////////////
// Event Handlers
////////////////////////////////////////////////////////////////
/**
* Route events.
*/
function handleEvent(e)
{
if (e.keyCode == 0) handleMouseEvent(e);
handleKeyEvent(e);
}
/**
* Handle mouse events.
*/
function handleMouseEvent(e)
{
}
/**
* Handle keyboard events.
*/
function handleKeyEvent(e)
{
var focus = 0;
var focusId = document.commandDispatcher.focusedElement.id;
if (focusId == "newsfox.feedTree") focus = 1;
else if (focusId == "newsfox.articleTree") focus = 2;
else return;
switch(e.keyCode)
{
case 39: // right-arrow
if (e.ctrlKey)
if (focus == 2)
{
var arttree = document.getElementById("newsfox.articleTree");
arttree.view.selection.select(arttree.currentIndex);
}
break;
case 40: // down-arrow
if (e.altKey)
{
e.stopPropagation();
e.preventDefault();
selectNextUnreadArticle();
}
else if (e.ctrlKey)
if (focus == 1) moveIt(false);
break;
case 38: // up-arrow
if (e.altKey)
{
e.stopPropagation();
e.preventDefault();
selectPrevUnreadArticle();
}
else if (e.ctrlKey)
if (focus == 1) moveIt(true);
break;
case 46: // delete
if (focus == 2) deleteArticle();
else if (focus == 1) deleteRow();
break;
}
}
////////////////////////////////////////////////////////////////
// Util
////////////////////////////////////////////////////////////////
function openNewTab(url)
{
if (url == NO_LINK) return;
if(!gKMeleon)
{
const kWindowMediatorContractID = "@mozilla.org/appshell/window-mediator;1";
const kWindowMediatorIID = Components.interfaces.nsIWindowMediator;
const kWindowMediator = Components.classes[kWindowMediatorContractID].getService(kWindowMediatorIID);
var browserWindow = kWindowMediator.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
var tab = browser.addTab(url);
}
else
{
window.open(url);
window.focus();
}
// ctrl-alt-tab to open in background on K-M
}
function onOptMenuShowing(menu)
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
var level = feedtree.view.getLevel(index);
if (index == -1) level = -1;
var children = menu.childNodes;
for (var i = 0; i < children.length; i++)
{
var id = children[i].getAttribute("id");
switch (id)
{
case "tool.group":
case "tool.groupExport":
if (level == 0) children[i].setAttribute("disabled",false)
else children[i].setAttribute("disabled",true);
break;
case "tool.feed":
if (level == 1) children[i].setAttribute("disabled",false)
else children[i].setAttribute("disabled",true);
break;
}
}
return true;
}
function onFeedMenuShowing(menu)
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
if (index == -1) return false;
var level = feedtree.view.getLevel(index);
var children = menu.childNodes;
for (var i = 0; i < children.length; i++)
{
var id = children[i].getAttribute("id");
switch (id)
{
case "home":
if (level == 0 || gFmodel.get(gIdx.feed[index]).homepage == "") children[i].setAttribute("disabled",true)
else children[i].setAttribute("disabled",false);
break;
case "checkFeed":
case "props":
if (level <= 1) children[i].setAttribute("disabled",false)
else children[i].setAttribute("disabled",true);
break;
}
}
return true;
}
function mvGrp(oldgrp, newgrp)
{
if (oldgrp == newgrp || oldgrp+1 == newgrp || oldgrp == 0 || newgrp == 0) return;
var up = 1*(newgrp > oldgrp);
var down = 1 - up;
var newrow = getGroupRow(newgrp);
var oldrow = getGroupRow(oldgrp);
var i = oldrow;
while (i < gIdx.fdgp.length && gIdx.fdgp[i] == oldgrp) i++;
var num = i - oldrow;
for (i=0; i<num; i++)
{
gIdx.fdgp.splice(newrow+i*down,0,gIdx.fdgp[oldrow+i*down]);
gIdx.fdgp.splice(oldrow+(i+1)*down,1);
gIdx.feed.splice(newrow+i*down,0,gIdx.feed[oldrow+i*down]);
gIdx.feed.splice(oldrow+(i+1)*down,1);
gIdx.catg.splice(newrow+i*down,0,gIdx.catg[oldrow+i*down]);
gIdx.catg.splice(oldrow+(i+1)*down,1);
gIdx.open.splice(newrow+i*down,0,gIdx.open[oldrow+i*down]);
gIdx.open.splice(oldrow+(i+1)*down,1);
}
var tmpGrp = gFdGroup[oldgrp];
gFdGroup.splice(oldgrp,1);
gFdGroup.splice(newgrp-up,0,tmpGrp);
grpChg(oldgrp,-2);
if (newgrp > oldgrp)
{
newgrp--;
for (var i=0; i<(newgrp-oldgrp); i++)
grpChg(oldgrp+i+1,oldgrp+i);
}
else
for (var i=0; i<(oldgrp-newgrp); i++)
grpChg(oldgrp-i-1,oldgrp-i);
grpChg(-2,newgrp);
saveGroupModel();
saveIndices();
refreshModelSelect(newrow - up*num);
}
function grpChg(oldgrp,newgrp)
{
for (var i=0; i<gIdx.fdgp.length; i++)
if (gIdx.fdgp[i] == oldgrp)
gIdx.fdgp[i] = newgrp;
}
function getGroupRow(grp)
{
var i = gIdx.fdgp.length - 1;
while (i >= 0 && gIdx.fdgp[i] >= grp) i--;
return ++i;
}
function getFeedRow(grp,nFeed)
{
var i = getGroupRow(grp);
while (i < gIdx.fdgp.length && gIdx.fdgp[i] == grp && gIdx.feed[i] != nFeed) i++;
return i; // returns row after last feed if not in group
}
function moveIt(movingUp)
{
var feedtree = document.getElementById("newsfox.feedTree");
var index = feedtree.currentIndex;
var curGrp = gIdx.fdgp[index];
var curFeed = gIdx.feed[index];
if (gIdx.catg[index] != 0) return; // on category
if (curFeed == -1) // on group
{
if (movingUp && curGrp <= 1) return;
if (!movingUp && curGrp == gFdGroup.length-1) return;
var newGrp = curGrp + 2;
if (movingUp) newGrp -= 3;
mvGrp(curGrp,newGrp);
}
else // on feed
{
var curPos = -1;
for (var i=0; i<gFdGroup[curGrp].list.length; i++)
if (gFdGroup[curGrp].list[i] == curFeed) curPos = i;
if (movingUp && curPos == 0) return;
if (!movingUp && curPos == gFdGroup[curGrp].list.length-1) return;
var newFeed;
if (movingUp) newFeed = gFdGroup[curGrp].list[curPos-1]
else if (curPos+2 == gFdGroup[curGrp].list.length) newFeed = -2
else newFeed = gFdGroup[curGrp].list[curPos+2];
mvFeed(curGrp,curFeed,newFeed);
}
}
function mvFeed(curGrp,curFeed,newFeed)
{
var feedtree = document.getElementById("newsfox.feedTree");
var curRow = getFeedRow(curGrp,curFeed);
var newRow = getFeedRow(curGrp,newFeed);
var curPos;
var newPos = gFdGroup[curGrp].list.length;
for (var i=0; i<gFdGroup[curGrp].list.length; i++)
{
if (gFdGroup[curGrp].list[i] == curFeed) curPos = i
else if (gFdGroup[curGrp].list[i] == newFeed) newPos = i;
}
var up = (newRow > curRow);
if (curPos == newPos || curPos+1 == newPos) return;
var curExpand = gIdx.open[curRow];
if (curExpand) feedtree.view.toggleOpenState(curRow);
gFdGroup[curGrp].list.splice(curPos,1);
gFdGroup[curGrp].list.splice(newPos-up,0,curFeed);
newRow = getFeedRow(curGrp,newFeed);
gIdx.feed.splice(curRow,1);
gIdx.feed.splice(newRow-up,0,curFeed);
gIdx.fdgp.splice(curRow,1);
gIdx.fdgp.splice(newRow-up,0,curGrp);
gIdx.catg.splice(curRow,1);
gIdx.catg.splice(newRow-up,0,0);
gIdx.open.splice(curRow,1);
gIdx.open.splice(newRow-up,0,false);
if (curExpand) feedtree.view.toggleOpenState(newRow-up);
saveGroupModel();
saveIndices();
refreshModelSelect(newRow-up);
}
function loadingTooltip(show)
{
var tooltip = document.getElementById("loadingTooltip");
if (show)
tooltip.showPopup();
else
tooltip.hidePopup();
}
function setPmeter(value)
{
var pmeter = document.getElementById("pmeter");
if (value == 0)
pmeter.hidden = true;
else
{
pmeter.hidden = false;
pmeter.setAttribute("value", value + "%");
}
}
function doHorizontal(horiz)
{
var hartBox = document.getElementById("hbox3pane");
var rightPane = document.getElementById("rightpane");
if(horiz)
{
var vartBox = document.getElementById("vbox3pane");
vartBox.setAttribute("orient","horizontal");
rightPane.appendChild(vartBox);
var vartsplitter = document.getElementById("vartsplitter");
var hartsplitter = document.getElementById("hartsplitter");
vartBox.replaceChild(hartsplitter,vartsplitter);
}
rightPane.removeChild(hartBox);
}