PK
N=5 defaults/PK
N=5 defaults/preferences/PK
Z4/\ $ defaults/preferences/browseimages.jspref("browseimages.autoBack",false);
pref("browseimages.autoScan",true);
pref("browseimages.back_history_menu_backToIndex",2);
pref("browseimages.back_history_menu_prevImg",2);
pref("browseimages.centerImages",true);
pref("browseimages.domainsList", " 0000 java.sun.com/* <|2|> \n");
pref("browseimages.forward_history_menu_nextImg",2);
pref("browseimages.goMenu",true);
pref("browseimages.iconset","Flip-Flap");
pref("browseimages.largeNumberOfLinksDefaultAction",0);
pref("browseimages.max_history_menu_items",35);
pref("browseimages.statusbarMenu",true);
pref("browseimages.statusbarMenuitems","14,0,6,7,5,0,8,9,10,0,11,15,");
pref("browseimages.regExpRules", " 0000 /\\.jpg$|\\.jpg[&;]/ <|0|> \n0001 /\\.gif$|\\.gif[&;]/ <|0|> \n0002 /\\.png$|\\.png[&;]/ <|0|> \n0003 /\\.jpeg$|\\.jpeg[&;]/ <|0|> \n0004 /\\.bmp$|\\.bmp[&;]/ <|0|> \n0005 /\\/\\d\\d?\\.html?/ <|0|> \n0006 /\\/full\\.php\\?.*ima?ge?=/ <|0|> \n0007 /\\/preview\\.php\\?.*ima?ge?=/ <|0|> \n0008 /\\/view\\.php\\?.*ima?ge?=/ <|0|> \n0009 /\\/view\\.php\\?.*pic=/ <|0|> \n0010 /\\/view\\.showImage\\.php/ <|0|> \n");
pref("browseimages.toolsMenu",true);
pref("browseimages.largeNumberOfLinksLimit", 1000);PK
Y>5nҲ chrome.manifest
overlay chrome://browser/content/browser.xul chrome://browseimages/content/browseImagesOverlay.xul
content browseimages chrome/content/browseimages/
skin browseimages classic/1.0 chrome/skin/classic/browseimages/
style chrome://browser/content/browser.xul chrome://browseimages/skin/browseimages.css
locale browseimages en-US chrome/locale/en-US/browseimages/
locale browseimages de-DE chrome/locale/de-DE/browseimages/
PK
Q>5}a install.rdf
{62b958b4-9962-4fc2-9983-01a9a42d6f2d}0.3.42{ec8030f7-c20a-464f-9b0e-13a3a9e97384}1.52.0.0.*Browse ImagesJuergen BinderBrowses all image links of a page.chrome://browseimages/content/browseImagesOptions.xulhttp://browseimages.mozdev.org/chrome://browseimages/skin/BrowseImages-Logo.png
PK
N=5 chrome/PK
N=5 chrome/content/PK
N=5 chrome/content/browseimages/PK
& 24<8 8 3 chrome/content/browseimages/browseImagesOverlay.xul
PK
p2Qɍ? ? 1 chrome/content/browseimages/sophisticatedTree.xml
= 0) {
textbox.value = document.getAnonymousNodes(this)[0]
.childNodes[1].childNodes[1]
.childNodes[tree.view.selection.currentIndex]
.firstChild.childNodes[1].getAttribute("label");
}
]]>
\\t", "gmi"), "\t" + radios[i] + "\t");
}
string = string.slice(1);
this.fromString(string, "0,1,2,");
}
]]>
\t");
}
prefService.getBranch(this.getAttribute("pref")).setCharPref("", string);
]]>
PK
h23Ѻ$ $ 5 chrome/content/browseimages/browseImagesFunctions.rdf
&browseImages.menuitems.separator;separator0&browseImages.menuitems.sortList;sortImgList();1chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.centerImages;togglePref("centerImages");2chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.autoBack;togglePref("autoBack");3chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.autoScan;togglePref("autoScan");4chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.backToIndex;backToIndex();5chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.nextImage;nextImage();6chrome://browseimages/skin/Flip-Flap-Next-Image.png&browseImages.menuitems.prevImage;prevImage();7chrome://browseimages/skin/Flip-Flap-Prev-Image.png&browseImages.menuitems.incrementUrl;incrementURL();8chrome://browseimages/skin/Flip-Flap-Increment.png&browseImages.menuitems.decrementUrl;decrementURL();9chrome://browseimages/skin/Flip-Flap-Decrement.png&browseImages.menuitems.incDecDia;incDecDialog(content.document.URL);10chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.openInTab;showImgListInTab(false);11chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.openInNewTab;showImgListInTab(true);12chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.searchLinkedImages;searchLinkedImages();13chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.imageList;imageList14chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.options;showBIOptions();15chrome://browseimages/skin/classic-colored.png&browseImages.menuitems.openInTabs;showImgListInTabs();16&browseImages.menuitems.saveImages;saveImages();17
PK
`2w w 3 chrome/content/browseimages/browseImagesOptions.csssophisticatedTree {
-moz-binding: url('chrome://browseimages/content/sophisticatedTree.xml#sophisticatedTree');
}PK
`
2mf f 7 chrome/content/browseimages/browseImagesIncDecDialog.js/* * * * * * * * * * * * * 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 Juergen Binder's Browse Images Code
*
* The Initial Developer of the Original Code is Juergen Binder.
* Portions created by Juergen Binder are Copyright (C) 2005
* Juergen Binder. All Rights Reserved.
*
* Contributor(s): Juergen Binder.
*
* Please see also the licensing notes of the FillHistoryMenu function at the
* end of this file.
*
* 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 radiogroup;
function IDDinit() {
//urlbox = document.getElementById("browseimages.incDecDialog.urlbox");
//urlbox.value = window.arguments[0];
var hbox = document.getElementById("browseimages.incDecDialog.hbox");
radiogroup =
document.getElementById("browseimages.incDecDialog.box.radiogroup");
/*:) *** (:*/
var url = window.arguments[0];
var positions = window.arguments[1];
var flipDirection = window.arguments[2];
if(flipDirection == -1) {
radiogroup.selectedIndex = 1;
} else {
radiogroup.selectedIndex = 0;
}
positions.push(url.length);
var i = 0;
var lastPos = 0;
var label;
var toolbarbutton;
var tbblabel;
while(i < positions.length) {
/* letters between the digits */
label = document.createElement("toolbarbutton");
label.setAttribute("label", url.substring(lastPos, positions[i]));
label.setAttribute("disabled", "true");
hbox.appendChild(label);
/* * * Digit portions * * */
var oldi = i;
toolbarbutton = document.createElement("toolbarbutton");
while(((i + 1) < positions.length) && positions[i+1] == positions[i] + 1) {
i++
}
tbblabel = url.substring(positions[oldi],positions[i] + 1);
if(tbblabel != "") {
toolbarbutton.setAttribute("label", tbblabel);
toolbarbutton.setAttribute("oncommand", "IDDdoIt(" +
(positions[i] + 1) + ");");
hbox.appendChild(toolbarbutton);
}
lastPos = positions[i] + 1;
i++;
}
sizeToContent();
}
function IDDdoIt(flipPosition) {
var flipDirection = radiogroup.selectedItem.value;
window.arguments[3].flipDirection = flipDirection;
window.arguments[3].flipPosition = flipPosition;
document.getElementById("browseimages.incDecDialog").acceptDialog();
}
function IDDchangeURL() {
var textbox =
document.getElementById("browseimages.incDecDialog.urltextbox");
var urlbox = document.getElementById("browseimages.incDecDialog.urlbox")
urlbox.removeChild(document.getElementById("browseimages.incDecDialog.qbox"));
textbox.value = window.arguments[0];
textbox.removeAttribute("hidden");
var changeUrlButton =
document.getElementById("browseimages.incDecDialog.changeURL");
changeUrlButton.removeAttribute("oncommand");
changeUrlButton.setAttribute("oncommand", "IDDcloseAndReload();");
var props = document.getElementById("string-tanga");
changeUrlButton.setAttribute("label", props.getString("confirmUrlChange"));
document.getElementById("browseimages.incDecDialog.box.label").setAttribute("value", props.getString("enterNewUrl"));
document.getElementById("browseimages.incDecDialog.box.radiogroup").setAttribute("hidden", "true");
document.getElementById("browseimages.incDecDialog.box.label2").setAttribute("hidden", "true");
window.resizeBy(100,0);
}
function IDDcloseAndReload() {
var textbox =
document.getElementById("browseimages.incDecDialog.urltextbox");
window.arguments[3].newURL = textbox.value;
var flipDirection = radiogroup.selectedItem.value;
window.arguments[3].flipDirection = flipDirection;
document.getElementById("browseimages.incDecDialog").cancelDialog();
}PK
12X A chrome/content/browseimages/browseImagesConfirmScanningDialog.xul
PK
`2KW 8 chrome/content/browseimages/browseImagesIncDecDialog.xul
PK
Yf3q\ \ ( chrome/content/browseimages/contents.rdf
chrome://browseimages/content/browseImagesOverlay.xulPK
4 2 chrome/content/browseimages/browseImagesOverlay.js/* * * * * * * * * * * * * 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 Juergen Binder's Browse Images Code
*
* The Initial Developer of the Original Code is Juergen Binder.
* Portions created by Juergen Binder are Copyright (C) 2005
* Juergen Binder. All Rights Reserved.
*
* Contributor(s): Juergen Binder.
*
* Please see also the licensing notes of the FillHistoryMenu function at the
* end of this file.
*
* 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 imgListArray = new Array();
var referrerArray = new Array();
//var index = -1;
var frameIndexPages = new Array();
var autoBackToIndex = new Boolean();
var max_history_menu_items_browseimages = 35;
var back_prevImg = 1;
var back_backToIndex = 1;
var forward_nextImg = 1;
var historyMenuMore = new Boolean();
var blackList = new Array();
var whiteList = new Array();
var scanList = new Array();
var dontScanList = new Array();
var askList = new Array();
var iconPrefix = new String();
var ourReferrer;
var prefBranch;
var largeNumberOfLinksLimit;
var largeNumberOfLinksDefaultAction;
var imgListStatusText = "noImageLinksFound";
var defaultSaveDir = "";
var promptForSaveDir = false;
var lastSaveDir = "";
var biNumberOfLinks = -1;
var props;
try{
ourReferrer = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
prefBranch = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService)
.getBranch("browseimages.");
} catch (e) {
//alert(69 + "\n\n" + e);
}
// *NOTE* this makes sure the window is done loading before we initialize anything to do with "document", as per Mozilla's recommendations for extensions
window.addEventListener("load", browseImagesInitialize, false);
// *NOTE* this function gets called when the main Firefox window is done loading.
function browseImagesInitialize()
{
window.removeEventListener("load", browseImagesInitialize, false);
props = document.getElementById("gstrings");
//getBrowser().tabContainer.setAttribute("onselect", getBrowser().tabContainer.getAttribute("onselect") + "copyImgListToNewTab(this);");
getBrowser().tabContainer.addEventListener("DOMNodeInserted",
copyImgListToNewTab, true);
document.getElementById("content").mTabBox.addEventListener("select", aTabHasBeenSelected, true);
applySettings();
}
/******************************************************************************
* *
* Saves the last time the tab was selected to an attribute of the tab. *
* Needed for copyImgListToNewTab(). It's an idea of Daniel Lindkvist, author *
* of the extension "FLST" *
* *
******************************************************************************/
function aTabHasBeenSelected() {
getBrowser().tabContainer.selectedItem.setAttribute("lastSelectedTime", new Date().getTime());
}
/******************************************************************************
* *
* Copies the image list of the tab a new window was opened from to the new *
* tab *
* *
******************************************************************************/
function copyImgListToNewWindow(event) {
if(!event || !event.target)
return;
var winIDs = document.getElementById("browseImages.window-mediator").childNodes;
var windowManager =
Components.classes["@mozilla.org/rdf/datasource;1?name=window-mediator"]
.getService(Components.interfaces.nsIWindowDataSource)
var tabs = new Array();
var winFromTab = new Array();
for(var i = 1; i < winIDs.length; i++) {
var win = windowManager.getWindowForResource(winIDs[i].id);
if(win && win.getBrowser && win.getBrowser().tabContainer) {
var moreTabs = win.getBrowser().tabContainer.childNodes;
for(var j = 0; j < moreTabs.length; j++) {
tabs[tabs.length] = moreTabs[j];
winFromTab[winFromTab.length] = win;
}
}
}
var lastTabIndex = getLastSelectedTabIndex(tabs);
if(tabs[lastTabIndex] && event.target && event.target.tabContainer && event.target.tabContainer.selectedItem) {
copyImgListFromOldTabToNewTab(tabs[lastTabIndex],
event.target.tabContainer.selectedItem);
}
}
/******************************************************************************
* *
* Copies the image list of the tab a new tab was opened from to the new tab *
* *
******************************************************************************/
function copyImgListToNewTab(event) {
var oldTab = getLastSelectedTab(getBrowser().tabContainer.childNodes);
copyImgListFromOldTabToNewTab(oldTab, event.target);
}
/******************************************************************************
* *
* Copies the image list from a old tab to a new tab *
* *
******************************************************************************/
function copyImgListFromOldTabToNewTab(oldTab, newTab) {
if(!oldTab || !newTab)
return;
var root = oldTab;
while(root.parentNode != null)
root = root.parentNode;
var conWin = root.getElementById("content").contentWindow;
newTab.imgListArray = oldTab.imgListArray;
newTab.indexXOffset = conWin.pageXOffset;
newTab.indexYOffset = conWin.pageYOffset;
newTab.offsetsPage = conWin.document.URL;
saveIndexPageWithFramesToTabProperties(oldTab, newTab);
saveOffsetsFromWindowToTabProperties(conWin, newTab)
}
/******************************************************************************
* *
* Returns the index of the last selected tab of a array of tabs *
* *
******************************************************************************/
function getLastSelectedTabIndex(tabs) {
var lastTabIndex = 0;
for(var i = 1; i < tabs.length; i++) {
if(tabs[i] && tabs[i].getAttribute &&
tabs[i].getAttribute("lastSelectedTime") > tabs[lastTabIndex].getAttribute("lastSelectedTime"))
lastTabIndex = i;
}
return lastTabIndex;
}
/******************************************************************************
* *
* Returns the last selected tab of a array of tabs *
* *
******************************************************************************/
function getLastSelectedTab(tabs) {
return tabs[getLastSelectedTabIndex(tabs)];
}
/******************************************************************************
* *
* The BrowseImagesObserver calls the applySettings() function when the *
* browseimages preferences changed, so the changes take place in every window*
* *
* It is based on the example observer object from the Knowledge Base: *
* http://kb.mozillazine.org/Using_observers#Observer_object *
* *
******************************************************************************/
function browseImagesObserver() {
this.register();
}
browseImagesObserver.prototype = {
observe: function(subject, topic, data) {
applySettings();
},
register: function() {
var prefService;
prefService = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService);
prefBranch = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService)
.getBranch("browseimages.");
var pbi =
prefBranch.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver("", this, false);
}
}
var observer = new browseImagesObserver();
observer.register();
/*******************************************************************************
http://kb.mozillazine.org/Progress_listeners
*******************************************************************************/
//const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START;
//const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP;
var browseImagesListener =
{
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onStateChange: function(aProgress, aRequest, aFlag, aStatus)
{
//dump("StateChange: " + aProgress +" <> " + aRequest+" <> " + aFlag+" <> " + aStatus + "\n");
//alert("StateChange: " + aProgress +" <> " + aRequest+" <> " + aFlag+" <> " + aStatus + "\n");
return 0;
},
onLocationChange: function(aProgress, aRequest, aURI)
{ initBrowseImages();
// This fires when the location bar changes i.e load event is confirmed
// or when the user switches tabs
return 0;
},
// For definitions of the remaining functions see XulPlanet.com
onProgressChange: function(aProgress, aRequest, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
//dump("progressChange");
//dump("aProgress="+aProgress+"\naRequest="+aRequest+"\ncurSelfProgress="+ curSelfProgress+"\nmaxSelfProgress="+maxSelfProgress+"\ncurTotalProgress=" +curTotalProgress+"\n---\n\n");
initBrowseImages();
//dump("cdll="+content.document.links.length + " : ilal=" + imgListArray.length + "\n");
return 0;
},
onStatusChange: function(webProgress , request , status , message ) {
//dump("StatusChange:" + webProgress +" <> " + request +" <> " + status +" <> " + message +"\n\n");
return 0;
},
onSecurityChange: function() {return 0;},
onLinkIconAvailable: function() {return 0;}
}
/*****************************************************************************/
var centerImagesListener =
{
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},
onStateChange: function(aProgress, aRequest, aFlag, aStatus)
{
return 0;
},
onLocationChange: function(aProgress, aRequest, aURI) {
// This fires when the location bar changes i.e load event is confirmed
// or when the user switches tabs
return 0;
},
// For definitions of the remaining functions see XulPlanet.com
onProgressChange: function(aProgress, aRequest, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
//dump("progressChange");
//dump("aProgress="+aProgress+"\naRequest="+aRequest+"\ncurSelfProgress="+ curSelfProgress+"\nmaxSelfProgress="+maxSelfProgress+"\ncurTotalProgress=" +curTotalProgress+"\n---\n\n");
centerThisImage();
return 0;
},
onStatusChange: function() {return 0;},
onSecurityChange: function() {return 0;},
onLinkIconAvailable: function() {return 0;}
}
/******************************************************************************
* *
* This function applies changes in the settings. *
* *
/*****************************************************************************/
function applySettings() {
//copyImgListToNewWindow(event); // *NOTE* this needs to be fixed -Ian Weiner
autoBackToIndex = prefBranch.getBoolPref("autoBack");
centerImages();
if(prefBranch.getBoolPref("goMenu")) {
document.getElementById("browseImagesGoMenu").removeAttribute("hidden");
} else {
document.getElementById("browseImagesGoMenu").setAttribute("hidden",
"true");
}
if(prefBranch.getBoolPref("toolsMenu")) {
document.getElementById("browseImagesToolsMenu")
.removeAttribute("hidden");
} else {
document.getElementById("browseImagesToolsMenu").setAttribute("hidden",
"true");
}
if(prefBranch.getBoolPref("statusbarMenu")) {
document.getElementById("browseimages-button").removeAttribute("hidden");
} else {
document.getElementById("browseimages-button").setAttribute("hidden",
"true");
}
max_history_menu_items_browseimages =
prefBranch.getIntPref("max_history_menu_items");
back_prevImg = prefBranch.getIntPref("back_history_menu_prevImg");
back_backToIndex = prefBranch.getIntPref("back_history_menu_backToIndex");
forward_nextImg = prefBranch.getIntPref("forward_history_menu_nextImg");
if(prefBranch.getBoolPref("autoScan")) {
getBrowser().addProgressListener(browseImagesListener,
Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS);
document.addEventListener("load", finishDocumentScanning, true);
document.addEventListener("unload", saveOffsets, true);
document.addEventListener("load", restoreOffsets, true);
document.getElementById("browseimages-button").setAttribute("activated", "true");
} else {
try {
getBrowser().removeProgressListener(browseImagesListener,
Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS);
} catch(exc) {
}
document.removeEventListener("load", finishDocumentScanning, true);
document.removeEventListener("unload", saveOffsets, true);
document.removeEventListener("load", restoreOffsets, true);
document.getElementById("browseimages-button").setAttribute("activated", "false");
imgListStatusText = "autoScanDisabled";
}
iconPrefix = prefBranch.getCharPref("iconset");
setStatusbarIcon();
var regExpRulesArray = generateLists(prefBranch.getCharPref("regExpRules").slice(1));
whiteList = regExpRulesArray[0];
blackList = regExpRulesArray[1];
largeNumberOfLinksLimit = prefBranch.getIntPref("largeNumberOfLinksLimit");
largeNumberOfLinksDefaultAction = prefBranch.getIntPref("largeNumberOfLinksDefaultAction");
var domainsList = generateLists(prefBranch.getCharPref("domainsList").slice(1));
dontScanList = domainsList[0];
scanList = domainsList[1];
askList = domainsList[2];
window.addEventListener("focus", aTabHasBeenSelected, true);
lastSaveDir = prefBranch.getCharPref("saveDirectory")
//promptForSaveDir = (prefBranch.getIntPref("saveBehaviour") == 1) ? false : true;
}
/******************************************************************************
* *
* This function creates RegExp Lists out of a string. *
* *
/*****************************************************************************/
function generateLists(string) {
var rules = string.split("\n");
var rule;
var status;
var tempArray;
var list1 = new Array();
var list2 = new Array();
var list3 = new Array();
for(var i = 0; i < rules.length - 1; i++) {
tempArray = rules[i].split("\t");
rule = tempArray[1];
status = tempArray[2];
if(status == "<|0|>") {
list1.push(createRegExp(rule));
} else if(status == "<|1|>") {
list2.push(createRegExp(rule));
} else if(status == "<|2|>") {
list3.push(createRegExp(rule));
}
}
return new Array(list1, list2, list3);
}
/******************************************************************************
* *
* This function creates an RegExp object with some standard flags out of a *
* string *
* *
/*****************************************************************************/
function createRegExp(string) {
if(string.charAt(0) == "/" && string.charAt(string.length - 1) == "/") {
return new RegExp(string.substring(1, string.length - 1), "i");
} else if(string.charAt(0) == "/" && string.substring(string.length - 2, string.length) == "/!") {
return new RegExp(string.substring(1, string.length - 2));
} else {
string = string.replace(/\*/g, ".*");
string = string.replace(/\\/g, "\\\\");
string = string.replace(/\//g, "\\/");
string = string.replace(/\./g, "\\.");
string = string.replace(/\+/g, "\\+");
string = string.replace(/\?/g, "\\?");
string = string.replace(/\^/g, "\\^");
string = string.replace(/\$/g, "\\$");
string = string.replace(/\|/g, "\\|");
string = string.replace(/\(/g, "\\(");
string = string.replace(/\)/g, "\\)");
string = string.replace(/\[/g, "\\[");
string = string.replace(/\]/g, "\\]");
string = string.replace(/\{/g, "\\{");
string = string.replace(/\}/g, "\\}");
return new RegExp(string, "i");
}
}
/******************************************************************************
* *
* This function saves the index page offsets when it has unloaded. *
* *
******************************************************************************/
function saveOffsets() {
//alert("save??");
if(content && content.document.URL &&
content.document.URL == imgListArray[imgListArray.length - 1] &&
imgListArray.length > 1 && content.document.URL != "" &&
content.document.URL != "about:blank") {
// alert("save!");
saveOffsetsFromWindowToTabProperties(content,
gBrowser.tabContainer.selectedItem);
}
}
/******************************************************************************
* *
* This function saves the page offsets of a window's document to a tab's *
* properties *
* *
******************************************************************************/
function saveOffsetsFromWindowToTabProperties(win, tab) {
tab.indexXOffset = win.pageXOffset;
tab.indexYOffset = win.pageYOffset;
tab.offsetsPage = win.document.URL;
if(win.frames.length > 1) {
var frameXOffset = new Array();
var frameYOffset = new Array();
for(var i = 0; i < win.frames.length; i++) {
frameXOffset[i] = win.frames[i].pageXOffset;
frameYOffset[i] = win.frames[i].pageYOffset;
}
tab.frameXOffset = frameXOffset;
tab.frameYOffset = frameYOffset;
}
}
/******************************************************************************
* *
* This function restores the page offsets when the document has loaded. *
* *
******************************************************************************/
function restoreOffsets(event) {
if(imgListArray.length > 1 && event.originalTarget &&
event.originalTarget.baseURI == content.document.URL &&
gBrowser.tabContainer.selectedItem.offsetsPage == content.document.URL &&
content.document.URL == imgListArray[imgListArray.length - 1]) {
/*alert(gBrowser.tabContainer.selectedItem.indexXOffset + ", " +
gBrowser.tabContainer.selectedItem.indexYOffset);*/
content.scrollTo(gBrowser.tabContainer.selectedItem.indexXOffset,
gBrowser.tabContainer.selectedItem.indexYOffset);
if(gBrowser.tabContainer.selectedItem.frameIndexPages &&
gBrowser.tabContainer.selectedItem.frameIndexPages.length > 1 &&
gBrowser.tabContainer.selectedItem.frameIndexPages.length ==
content.frames.length) {
var frameXOffset = gBrowser.tabContainer.selectedItem.frameXOffset;
var frameYOffset = gBrowser.tabContainer.selectedItem.frameYOffset;
if(frameXOffset && frameYOffset) {
for(var i = 0; i < frameIndexPages.length; i++) {
content.frames[i].scrollTo(frameXOffset[i],frameYOffset[i]);
}
}
}
}
}
/******************************************************************************
* *
* Saves the index page of each frame if necessary. *
* *
******************************************************************************/
function saveIndexPageWithFrames() {
if(gBrowser.tabContainer.selectedItem)
return;
saveIndexPageWithFramesToTabProperties(gBrowser.tabContainer.selectedItem,
gBrowser.tabContainer.selectedItem);
}
/******************************************************************************
* *
* Saves the index page of each frame to a tab's properties *
* *
******************************************************************************/
function saveIndexPageWithFramesToTabProperties(originTab,saveToTab) {
saveToTab.frameIndexPagesToRestore = new Array();
if(originTab.frameIndexPages) {
for(var q = 0; q < originTab.frameIndexPages.length; q++) {
saveToTab.frameIndexPagesToRestore[q] =
originTab.frameIndexPages[q];
}
}
}
/******************************************************************************
* *
* Restores an index page with frames *
* *
******************************************************************************/
function restoreIndexPageWithFrames() {
if(!gBrowser.tabContainer.selectedItem.frameIndexPagesToRestore) {
gBrowser.tabContainer.selectedItem.frameIndexPagesToRestore =
new Array();
return;
}
gBrowser.tabContainer.selectedItem.whileRestoringFrames = true;
var frameIndexPagesToRestore = gBrowser.tabContainer.selectedItem.
frameIndexPagesToRestore;
if(frameIndexPagesToRestore.length == content.frames.length) {
for(var i = 0; i < frameIndexPagesToRestore.length; i++) {
if(content.document.URL != "about:blank" &&
content.frames[i].location.href) {
content.frames[i].location.href = frameIndexPagesToRestore[i];
} else {
restoreIndexPageWithFrames();
}
}
gBrowser.tabContainer.selectedItem.frameIndexPagesToRestore = null;
}
gBrowser.tabContainer.selectedItem.whileRestoringFrames = false;
}
/******************************************************************************
* *
* This function is called when a page has a lot of links. It returns whether *
* the scanning for image links should be stopped or not. *
* *
/*****************************************************************************/
function stopScanningBecauseOfTooManyLinks() {
if(isInDontScanList(content.document.URL))
return true;
else if(isInScanList(content.document.URL))
return false;
else if(isInAskList(content.document.URL))
return askUserDialog();
if(largeNumberOfLinksDefaultAction == 0)
return true;
else if(largeNumberOfLinksDefaultAction == 1)
return false;
else if(largeNumberOfLinksDefaultAction == 2) {
return askUserDialog();
}
}
/******************************************************************************
* *
* Shows an Ask-Dialog with which the user can determine whether image link *
* scanning should be stopped due to a large number of them or not. *
* *
/*****************************************************************************/
function askUserDialog() {
if(gBrowser.tabContainer.selectedItem.alreadyAsking)
return true;
gBrowser.tabContainer.selectedItem.alreadyAsking = true;
if(gBrowser.tabContainer.selectedItem.lastAskedURL
== content.document.URL)
return gBrowser.tabContainer.selectedItem.lastAskedURLDecision;
var answer = largeNumberOfLinksLimit;
var returnValue = new Array(1);
window.openDialog("chrome://browseimages/content/browseImagesConfirmScanningDialog.xul",
"BrowseImagesConfirmScanning" + new Date().getTime(), "chrome,resizable,modal,centerScreen",
answer, content.document.URL, returnValue);
gBrowser.tabContainer.selectedItem.lastAskedURL = content.document.URL;
gBrowser.tabContainer.selectedItem.lastAskedURLDecision = !returnValue.bool;
gBrowser.tabContainer.selectedItem.alreadyAsking = false;
if(returnValue.remember && returnValue.selectedIndex > -1) {
var index = (scanList.length + dontScanList.length + askList.length).toString();
var domain = "";
var status;
var startlength = index.length;
for(var i = 0; i < 4 - startlength; i++) {
index = "0" + index;
}
if(returnValue.selectedIndex == 0) {
domain = content.document.URL
} else if(returnValue.selectedIndex == 1) {
var uriparts = content.document.URL.split("/");
domain = uriparts[0] + "/" + uriparts[1] + "/" + uriparts[2] + "/*";
}
if(returnValue.bool) {
status = "<|1|>";
} else {
status = "<|0|>";
}
prefBranch.setCharPref("domainsList", prefBranch.getCharPref("domainsList") + index + "\t" + domain + "\t" + status + "\t\n");
}
return (!returnValue.bool);
}
/******************************************************************************
* *
* One of the main functions. It controls the creating of the image list and *
* takes care about tab changes. *
* *
******************************************************************************/
function createImgList(reSearch) {
if(!gBrowser.tabContainer.selectedItem) {
return;
}
/********* Loads the correct variables for the current tab *********/
if(gBrowser.tabContainer.selectedItem.imgListArray != null) {
imgListArray = gBrowser.tabContainer.selectedItem.imgListArray;
} else {
imgListArray = new Array();
}
if(gBrowser.tabContainer.selectedItem.referrerArray != null) {
referrerArray = gBrowser.tabContainer.selectedItem.referrerArray;
} else {
referrerArray = new Array();
}
if(gBrowser.tabContainer.selectedItem.frameIndexPages != null) {
frameIndexPages = gBrowser.tabContainer.selectedItem.frameIndexPages;
} else {
frameIndexPages = new Array();
}
if(gBrowser.tabContainer.selectedItem.whileRestoringFrames != null &&
gBrowser.tabContainer.selectedItem.whileRestoringFrames == true) {
return;
}
if(reSearch) {
imgListArray.pop();
}
/*********************** Creating the image List ***********************/
var framesIndices = 0;
if(content.frames.length > 0 && imgListArray[imgListArray.length - 1] ==
content.document.URL && !compareArrays(content.frames, frameIndexPages,
true)) {
framesIndices = -1;
}
//dump(biNumberOfLinks+"\n\n");
//dump("nol="+biNumberOfLinks + "cdll=" + content.document.links.length + " nol"+content.document.URL + "<\n");
//dump(numberOfLinks < content.document.links.length+"\n");
//dump(!isInImgList(content.document.URL)+"\n");
if((content.document.URL && content.document.URL != "" && content.document.URL != "about:blank" && (!isInImgList(content.document.URL) || (content.document.URL == imgListArray[imgListArray.length - 1] && (biNumberOfLinks < content.document.links.length)))) || framesIndices == -1) {
//dump("ici\n");
//imgListArray.pop();
//referrerArray.pop();
//alert("kj");
biNumberOfLinks = content.document.links.length;
//index = -1;
imgListArray = new Array();
referrerArray = new Array();
frameIndexPages = new Array();
if(content.document.links) {
var numberOfLinks = content.document.links.length;
numberOfLinks += content.document.getElementsByTagName("area").length;
for(var q = 0; q < content.frames.length; q++) {
numberOfLinks += content.frames[q].document.links.length;
}
if(numberOfLinks >= largeNumberOfLinksLimit && !reSearch) {
if(stopScanningBecauseOfTooManyLinks()) {
imgListStatusText = "notScanned";
return;
}
}
}
createImgListForFrame(content.document.links, content.document.URL);
createAreaHrefArray(content.document.getElementsByTagName("area"),
content.document.URL);
if(content.frames.length > 0) { /* frames */
for(var f = 0; f < content.frames.length; f++) {
frameIndexPages[f] = content.frames[f].document.URL;
if(content.frames[f].document.links.length > 0) {
createImgListForFrame(content.frames[f].document.links,
frameIndexPages[f]);
createAreaHrefArray(content.frames[f].document.
getElementsByTagName("area"),
frameIndexPages[f]);
}
}
}
imgListArray.push(content.document.URL);
referrerArray.push(content.document.referrer);
try{
manageListAdding()
} catch(anError) {
//alert(561 + "\n\n" + anError);
/** Don't complain! ;-) **/
}
}
gBrowser.tabContainer.selectedItem.referrerArray = referrerArray;
gBrowser.tabContainer.selectedItem.imgListArray = imgListArray;
gBrowser.tabContainer.selectedItem.frameIndexPages = frameIndexPages;
if(imgListArray.length <= 1) {
imgListStatusText = "noImageLinksFound";
}
setStatusbarIcon();
setToolbarbuttonsMenusStatus();
}
/******************************************************************************
* *
* This function manages the attribute which is used for setting the icon *
* *
******************************************************************************/
function setStatusbarIcon() {
if(props == null) {
props = document.getElementById("gstrings");
}
if(document.getElementById("browseimages-button").getAttribute("activated") == "true") {
if(imgListArray.length > 1) {
document.getElementById("browseimages-button").setAttribute("icon", iconPrefix + "-true");
document.getElementById("browseimages-button").tooltipText =
(imgListArray.length - 1) + " " + props.getString("imageLinksFound");
} else {
document.getElementById("browseimages-button").setAttribute("icon", iconPrefix + "-false");
document.getElementById("browseimages-button").tooltipText =
props.getString("noImageLinksFound");
}
} else {
document.getElementById("browseimages-button").setAttribute("icon", iconPrefix + "-deactivated");
document.getElementById("browseimages-button").tooltipText =
props.getString("autoScanDisabled");
}
}
/******************************************************************************
* *
* This function adds a range of the imgListArray to the session history in *
* order to enable the forward extra mouse button, so you can go with it to *
* the next image. *
* *
******************************************************************************/
function manageListAdding() {
var flipList = createFlipList();
var imgListIndex = positionInList(content.document.URL, imgListArray);
var SHInternal;
if(imgListIndex == (imgListArray.length - 1) &&
getBrowser().tabContainer.selectedItem.indexPage != content.document.URL) {
gBrowser.tabContainer.selectedItem.indexPage = content.document.URL;
try {
if(getWebNavigation && getWebNavigation().sessionHistory && getWebNavigation().sessionHistory.index)
gBrowser.tabContainer.selectedItem.indexPageIndex =
getWebNavigation().sessionHistory.index;
} catch (exception) {
/** Don't complain! ;-) **/
}
}
try {
SHInternal = Components.classes
['@mozilla.org/browser/shistory-internal;1'].
createInstance(Components.interfaces.nsISHistoryInternal);
} catch (exception) {
//alert(630 + "\n\n" + exception);
/** Don't complain! ;-) **/
}
try {
SHInternal = getWebNavigation().sessionHistory.QueryInterface(Components.
interfaces.nsISHistoryInternal);
} catch (exception) {
//alert(638 + "\n\n" + exception);
/** Don't complain! ;-) **/
}
try{
if(!gBrowser.canGoForward && imgListArray.length > 1) {
addImgListToSessionHistory(imgListIndex < imgListArray.length - 1 ? imgListIndex + 1 : 0);
} else if(!gBrowser.canGoForward && flipList.length > 0) {
addFlipListToSessionHistory(flipList.slice(1));
} else {
var isForwardHistoryPartOfFlipList = isForwardHistoryPartOf(flipList);
if(imgListArray.length > 1 &&
(isForwardHistoryPartOf(imgListArray) ||
isForwardHistoryPartOfFlipList)) {
addImgListToSessionHistory(imgListIndex < imgListArray.length - 1 ? imgListIndex + 1 : 0);
} else if(flipList.length > 0 && isForwardHistoryPartOfFlipList) {
addFlipListToSessionHistory(flipList.slice(1));
}
}
} catch(exception) {
/** Don't complain! ;-) **/
}
}
/******************************************************************************
* *
* Checks whether the forward history is part of a list *
* *
/*****************************************************************************/
function isForwardHistoryPartOf(aList, bool) {
if(!aList || aList.length == 0) {
return false;
}
var i = 0;
var index = positionInList(content.document.URL, aList);
var SHInternal = Components.classes
['@mozilla.org/browser/shistory-internal;1'].
createInstance(Components.interfaces.nsISHistoryInternal);
SHInternal = getWebNavigation().sessionHistory.QueryInterface(Components.
interfaces.nsISHistoryInternal);
/** imgList **/
if(index == aList.length - 1 && aList.length > 1) {
i = 1;
index = -1;
}
while(i < aList.length && SHInternal.index + i < SHInternal.count &&
aList[index + i] ==
SHInternal.getEntryAtIndex(SHInternal.index + i, false).URI.spec) {
i++;
}
if(i == (SHInternal.count - SHInternal.index)) { /* Flip List */
return true;
} else if(aList.length > 1 && i < aList.length && (SHInternal.getEntryAtIndex(SHInternal.index + i, false)).URI.spec == aList[aList.length - 1] ) { /* ImgList */
return true;
} else {
return false;
}
}
/******************************************************************************
* *
* Adds the image list to the session history . *
* *
/*****************************************************************************/
function addImgListToSessionHistory(theStartIndex) {
addListToSessionHistory(imgListArray, referrerArray, theStartIndex, "");
}
/******************************************************************************
* *
* Adds the flip list to the session history . *
* *
/*****************************************************************************/
function addFlipListToSessionHistory(flipList) {
var flipReferrerArray = new Array(flipList.length);
for(var i = 0; i < flipList.length; i++) {
flipReferrerArray[i] = content.document.URL;
}
var prefix = new String();
if(gBrowser.tabContainer.selectedItem.flipDirection < 0) {
prefix = "- ";
} else {
prefix = "+ ";
}
addListToSessionHistory(flipList, flipReferrerArray, 0, prefix);
}
/******************************************************************************
* *
* This function adds a list to the session history *
* *
******************************************************************************/
function addListToSessionHistory(theArray, theReferrerArray,theFirstIndex,
prefix) {
var SHInternal = Components.classes
['@mozilla.org/browser/shistory-internal;1'].
createInstance(Components.interfaces.nsISHistoryInternal);
SHInternal = getWebNavigation().sessionHistory.QueryInterface(Components.
interfaces.nsISHistoryInternal);
var SHindexbefore = SHInternal.index;
for(var k = theFirstIndex; k < theArray.length; k++) {
var uriParts = theArray[k].split("/");
var label = "\u203A\u203A " + uriParts[uriParts.length - 1]
+ " (" + theArray[k]+")";
label = prefix + label
addEntryToSessionHistory(theArray[k], label, theReferrerArray[k]);
}
if(SHindexbefore >= 0) {
SHInternal.getEntryAtIndex(SHindexbefore, true);
}
}
/******************************************************************************
* *
* This function generates an array of links of map area links and calls *
* createImgListForFrame function to process this array *
* *
******************************************************************************/
function createAreaHrefArray(areaArray, theReferrer) {
if(areaArray.length == 0)
return;
var areaLinks = new Array();
for(var i = 0; i < areaArray.length; i++) {
areaLinks[i] = areaArray[i].href;
}
createImgListForFrame(areaLinks, theReferrer);
}
/******************************************************************************
* *
* This function parses link arrays for image links and adds these to the *
* imgList and their referrer to the referrer array. *
* *
******************************************************************************/
function createImgListForFrame(linksArray, theReferrer) {
if(!linksArray || !theReferrer)
return;
var jpgIndex = -1;
var gifIndex = -1;
var pngIndex = -1;
var jpegIndex = -1;
var bmpIndex = -1;
for(var i = 0; i < linksArray.length; i++) {
if(isInWhiteList(linksArray[i]) && !isInBlackList(linksArray[i])
&& !isInImgList(linksArray[i])) {
imgListArray.push(linksArray[i].toString());
referrerArray.push(theReferrer.toString());
}
}
}
function testRegExpArrayOnString(array, string) {
for(var i = 0; i < array.length; i++) {
if(array[i].test(string))
return true;
}
return false;
}
/******************************************************************************
* *
* Generic function that returns the position of an object in a list. *
* *
******************************************************************************/
function positionInList(object, list) {
if(!list || !object)
return -1;
for(var i = 0; i < list.length; i++) {
if(list[i] == object)
return i;
}
return -1;
}
/******************************************************************************
* *
* Returns whether an url is in the Image List or not. *
* *
******************************************************************************/
function isInImgList(url) {
return (positionInList(url, imgListArray) > -1 ? true : false);
}
/******************************************************************************
* *
* Returns whether an url matches one rule of the WhiteList or not. *
* *
******************************************************************************/
function isInWhiteList(url) {
return testRegExpArrayOnString(whiteList, url);
}
/******************************************************************************
* *
* Returns whether an url matches one rule of the BlackList or not. *
* *
******************************************************************************/
function isInBlackList(url) {
return testRegExpArrayOnString(blackList, url);
}
/******************************************************************************
* *
* Returns whether an url matches one rule of the Don't Scan List or not. *
* *
******************************************************************************/
function isInDontScanList(url) {
return testRegExpArrayOnString(dontScanList, url);
}
/******************************************************************************
* *
* Returns whether an url matches one rule of the Scan Anyway List or not. *
* *
******************************************************************************/
function isInScanList(url) {
return testRegExpArrayOnString(scanList, url);
}
/******************************************************************************
* *
* Returns whether an url matches one rule of the Ask Me List or not. *
* *
******************************************************************************/
function isInAskList(url) {
return testRegExpArrayOnString(askList, url);
}
/******************************************************************************
* *
* This function adds an entry to the session history with given url, title *
* and referrer *
* *
******************************************************************************/
function addEntryToSessionHistory(theURI, theTitle, theReferrer) {
try{
var theNSURI = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
theNSURI.spec = theURI;
var theReferrerURI = Components.classes
["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
theReferrerURI.spec = theReferrer;
var SHInternal = Components.classes
['@mozilla.org/browser/shistory-internal;1']
.createInstance(
Components.interfaces.nsISHistoryInternal);
SHInternal = getWebNavigation().sessionHistory.
QueryInterface(Components.interfaces.nsISHistoryInternal);
getWebNavigation().sessionHistory.maxLength = 999999;
SHInternal.maxLength = 999999;
var SHEntry = Components.classes
['@mozilla.org/browser/session-history-entry;1']
.createInstance(Components.interfaces.nsISHEntry);
if(SHEntry.SetTitle)
SHEntry.SetTitle(theTitle); /* Firefox 1.0 */
else
SHEntry.setTitle(theTitle); /* Deer Park Alpha 1.1 */
if(SHEntry.SetURI)
SHEntry.SetURI(theNSURI); /* Firefox 1.0 */
else
SHEntry.setURI(theNSURI); /* Deer Park Alpha 1.1 */
SHEntry.referrerURI = theReferrerURI;
SHInternal.addEntry(SHEntry, true);
var bf = document.getElementById("Browser:Forward");
bf.removeAttribute("disabled");
} catch (exception) {
//alert(977 + "\n\n" + exception);
/** Don't complain! ;-) **/
}
}
/******************************************************************************
* *
* This function opens the Browse Images Options dialog window. *
* *
******************************************************************************/
function showBIOptions() {
window.openDialog("chrome://browseimages/content/browseImagesOptions.xul",
"BrowseImagesOptions", "chrome,resizable");
}
/******************************************************************************
* *
* This function inits a re-scan for linked images. *
* *
******************************************************************************/
function searchLinkedImages() {
createImgList(true);
}
/******************************************************************************
* *
* This function sorts the Image List. *
* *
******************************************************************************/
function sortImgList() {
//imgListArray.sort();
window.open("chrome://browseimages/content/browseFiles.xul",
"BrowseFiles", "chrome,resizable");
}
/******************************************************************************
* *
* Shows the Image List in a tab *
* *
******************************************************************************/
function showImgListInTab(inNewTab) {
createImgList();
showListInTab(imgListArray, inNewTab)
}
/******************************************************************************
* *
* Shows a list in a tab *
* *
******************************************************************************/
function showListInTab(list, inNewTab) {
if(list.length < 2)
return;
var browser;
var tabbrowser = document.getElementById("content");
if(inNewTab) {
var newTab = tabbrowser.addTab("");
browser = tabbrowser.getBrowserForTab(newTab);
} else {
browser = tabbrowser.selectedBrowser;
}
var contentDocument = browser.contentDocument;
contentDocument.close();
contentDocument.open();
if(props == null) {
props = document.getElementById("gstrings");
}
contentDocument.writeln("\n \n " +
props.getString("picturesLinkedFrom") + " " +
list[list.length - 1] +
"\n \n \n
");
for(var i = 0; i < list.length - 1; i++) {
contentDocument.writeln("
");
}
contentDocument.writeln("
\n \n");
contentDocument.close();
}
/******************************************************************************
* *
* Shows each Images of the Image List in separate tab *
* *
******************************************************************************/
function showImgListInTabs() {
createImgList();
showListInTabs(imgListArray)
}
/******************************************************************************
* *
* Shows a list in tabs *
* *
******************************************************************************/
function showListInTabs(list) {
if(list.length < 2)
return;
var browser;
var tabbrowser = document.getElementById("content");
for(var i = 0; i < list.length - 1; i++) {
var newTab = tabbrowser.addTab("");
browser = tabbrowser.getBrowserForTab(newTab);
ourReferrer.spec = referrerArray[i]
browser.loadURI(list[i], ourReferrer, null);
}
}
/******************************************************************************
* *
* Generic funtion for going on to the next (dir > 0) or previous (dir < 0) *
* image *
* *
******************************************************************************/
function goon(dir) {
createImgList();
var index = positionInList(content.document.URL, imgListArray);
if(imgListArray.length > 1) {
if(index >= imgListArray.length - 1 && dir > 0) {
index = -1;
} else if(index <= 0 && dir < 0) {
index = imgListArray.length;
}
index += dir;
ourReferrer.spec = referrerArray[index];
loadURI(imgListArray[index], ourReferrer, null);
}
}
/******************************************************************************
* *
* For going to the next image *
* *
******************************************************************************/
function nextImg() {
goon(1);
}
function nextImage() {
goon(1);
}
/******************************************************************************
* *
* For going to the previous image *
* *
******************************************************************************/
function prevImg() {
goon(-1);
}
function prevImage() {
goon(-1);
}
/******************************************************************************
* *
* Loads the image whose menuitem has been clicked *
* *
******************************************************************************/
function gotoImage(menuitem) {
ourReferrer.spec = menuitem.getAttribute("referrer");
loadURI(menuitem.getAttribute("value"), ourReferrer, null);
}
var timeistickingaway = 0;
/******************************************************************************
* *
* One of the main functions. It is called when a DOMNOde is inserted (and *
* AutoScan is enabled). It manages saving and restoring of index pages with *
* frames, initializing the creating of the image list and the (not always) *
* fast adding to the session history *
* *
******************************************************************************/
function initBrowseImages() {
if(gBrowser.tabContainer.selectedItem.frameIndexPages &&
imgListArray.length > 1 &&
imgListArray[imgListArray.length - 1] != content.document.URL) {
saveIndexPageWithFrames();
}
if(gBrowser.tabContainer.selectedItem.frameIndexPagesToRestore != null &&
content.document.URL == imgListArray[imgListArray.length - 1] &&
imgListArray.length > 1) {
restoreIndexPageWithFrames();
}
createImgList();
manageListAdding();
/*if(gBrowser.tabContainer.selectedItem.browseImagesloading == "true") {
setTimeout(initBrowseImages, 500);
}*/
}
/*function timeoutsetter() {
setTimeout(initBrowseImages, 500);
setTimeout(initBrowseImages, 1000);
setTimeout(initBrowseImages, 1500);
}*/
/******************************************************************************
* *
* In addition to the initBrowseImages() function this method is called when *
* the page has loaded completely. It rescans the document, so no link can be *
* overlooked. Furthermore it handles the auto Back to begin after cycling *
* all the images. *
* *
******************************************************************************/
function finishDocumentScanning() {
//getBrowser().tabContainer.selectedItem.browseImagesloading = "false";
if(imgListArray[imgListArray.length - 1] == content.document.URL) {
gBrowser.tabContainer.selectedItem.imgListArray = new Array();
//dump("");
initBrowseImages();
//imgListArray.push(content.document.URL);
//referrerArray.push(content.document.referrer);
//biNumberOfLinks = 0;
//dump("biNumberOfLinks="+biNumberOfLinks);
if(imgListArray.length > 1 && autoBackToIndex) {
backToIndex();
}
}
manageListAdding();
}
/******************************************************************************
* *
* This function builds the Browse Images Menus. *
* *
******************************************************************************/
function buildBrowseImagesMenu(menu) {
var order = prefBranch.getCharPref("statusbarMenuitems").split(",");
var masterMenu = document.getElementById("BrowseImagesMasterMenu");
var menuItem = masterMenu.childNodes;
clearMenu(menu);
for(var i = 0; i < order.length; i++) {
var number = parseInt(order[i]) + 1;
if(isNaN(number) || number >= menuItem.length)
continue;
var masterItem = menuItem[number];
var thisItem = document.createElement("menuitem");
thisItem.setAttribute("oncommand",masterItem.getAttribute("oncommand"));
thisItem.setAttribute("label", masterItem.getAttribute("label"));
if(thisItem.getAttribute("oncommand").indexOf("toggle") > -1) {
thisItem.setAttribute("type", "checkbox");
if(prefBranch.getBoolPref(thisItem.getAttribute("oncommand")
.slice(12,-3))) {
thisItem.setAttribute("checked", "true");
}
} else if(thisItem.getAttribute("oncommand") == "imageList") {
addImageListToMenu(menu);
continue;
} else if(thisItem.getAttribute("oncommand") == "separator") {
thisItem = document.createElement("menuseparator");
}
menu.appendChild(thisItem);
}
}
/******************************************************************************
* *
* Clears a menus . *
* *
******************************************************************************/
function clearMenu(menu) {
while(menu.childNodes.length > 0)
menu.removeChild(menu.firstChild);
}
/******************************************************************************
* *
* This function adds the image list to the menu *
* *
******************************************************************************/
function addImageListToMenu(menu) {
if(!imgListArray)
return;
if(imgListArray.length > 1) {// && isInImgList(content.document.URL)) {
// outcommented to see whether it is necessary
for(var i = 0; i < imgListArray.length; i++) {
var menuitem = document.createElement("menuitem");
var uriParts = imgListArray[i].split("/");
var label = uriParts[uriParts.length - 1] + " (" +
imgListArray[i]+")";
menuitem.setAttribute("label", label);
menuitem.setAttribute("value", imgListArray[i]);
menuitem.setAttribute("tooltiptext", imgListArray[i]);
menuitem.setAttribute("oncommand", "gotoImage(this);");
if(referrerArray && referrerArray[i])
menuitem.setAttribute("referrer", referrerArray[i]);
menu.appendChild(menuitem);
}
if(content.document.URL && content.document.URL != "");
markCurrentImage(menu);
} else {
if(props == null) {
props = document.getElementById("gstrings");
}
menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", props.getString(imgListStatusText));
menu.appendChild(menuitem);
}
}
/******************************************************************************
* *
* This function marks the current image in the image list of the menu. *
* *
******************************************************************************/
function markCurrentImage(menu) {
var menuitem = menu.getElementsByTagName("menuitem");
var i = 0;
while(i < menuitem.length && menuitem[i].getAttribute("value")
!= content.document.URL) {
i++;
}
if(i < menuitem.length) {
menuitem[i].setAttribute("label", "\u203A\u203A " +
menuitem[i].getAttribute("label"));
}
}
/******************************************************************************
* *
* This function toggles the value of a BoolPref *
* *
******************************************************************************/
function togglePref(pref, menuitem) {
if(prefBranch.getBoolPref(pref)) {
prefBranch.setBoolPref(pref, 0);
} else {
prefBranch.setBoolPref(pref, 1);
}
}
/******************************************************************************
* *
* This function manages going back to the index page. *
* *
******************************************************************************/
function backToIndex() {
//positionInList(content.document.URL, imgListArray);
var jump = gBrowser.tabContainer.selectedItem.indexPageIndex
- getWebNavigation().sessionHistory.index;
if(jump < 0) {
content.history.go(jump);
}
}
/******************************************************************************
* *
* This function is handles activating and deactivating of the centering of *
* images. *
* *
******************************************************************************/
function centerImages() {
if(prefBranch.getBoolPref("centerImages")) {
centerThisImage();
//document.addEventListener("DOMNodeInserted", centerThisImage, true);
getBrowser().addProgressListener(centerImagesListener,
Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS);
} else {
uncenterThisImage();
//document.removeEventListener("DOMNodeInserted", centerThisImage, true);
try {
getBrowser().removeProgressListener(centerImagesListener,
Components.interfaces.nsIWebProgress.NOTIFY_PROGRESS);
} catch(e) {}
}
}
/******************************************************************************
* *
* This function centers the current image. * * *
******************************************************************************/
function centerThisImage() {
//alert(content +"\n\n" + content.document +"\n\n" + content.document == "[object ImageDocument]" +"\n\n" + content.document.getElementsByTagName("img")[0].parentNode
// == content.document.body);
if(content && content.document && (content.document == "[object XPCNativeWrapper [object ImageDocument]]" || content.document == "[object ImageDocument]") && content.document.getElementsByTagName("img")[0].parentNode == content.document.body) {
var table = content.document.createElement("table");
table.setAttribute("height", "100%");
table.setAttribute("width", "100%");
var tr = content.document.createElement("tr");
var td = content.document.createElement("td");
//td.setAttribute("style","vertical-align:middle; text-align:center");
td.setAttribute("style","text-align:center");
td.appendChild(content.document.getElementsByTagName("img")[0]);
tr.appendChild(td);
table.appendChild(tr);
content.document.body.appendChild(table);
}
}
/******************************************************************************
* *
* This function uncenters the current image. *
* *
******************************************************************************/
function uncenterThisImage() {
if(content.document.URL != "about:blank" && content.document.URL != "" && content.document.body && content.document.body.childNodes &&
content.document.body.childNodes.length == 1 &&
content.document.getElementsByTagName("img")[0].src == content.document.URL && content.document.getElementsByTagName("img")[0].parentNode != content.document.body ) {
content.document.body.appendChild(content.document.
getElementsByTagName("img")[0]);
content.document.body.removeChild(content.document.body.firstChild);
}
}
/******************************************************************************
* *
* This function compares two arrays. *
* If the docUrlA bool is true, arrayA is an array of windows or frames and *
* their document.URLs are comparred with arrayB. *
* *
******************************************************************************/
function compareArrays(arrayA, arrayB, docUrlA) {
if(arrayA == null || arrayB == null);
return false;
if(arrayA.length > 0 && arrayB.length > 0 &&
arrayA.length == arrayB.length) {
var a;
var b;
for(var i = 0; i < arrayA.length; i++) {
if(docUrlA) {
a = arrayA[i].document.URL;
} else {
a = arrayA[i];
}
b = arrayB[i];
if(a != b) {
return false;
}
}
return true;
} else {
return false;
}
}
/******************************************************************************
* *
* This function creates a menuitem whose label is determinate by a string *
* property and adds this menuitem to a menu. *
* *
******************************************************************************/
function createSpecialMenuItem(menu, string, tooltipurl) {
if(props == null) {
props = document.getElementById("gstrings");
}
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("index", -1);//necessary for deleteHistoryItems(aMenu)
menuitem.setAttribute("oncommand", string + "();");
var label;
try {
label = props.getString(string);
} catch(exception) {
label = string;
}
menuitem.setAttribute("label", label);
menuitem.setAttribute("tooltiptext", label + ": " + tooltipurl);
menu.appendChild(menuitem);
}
/******************************************************************************
* *
* This function adds an menuseparator to a menu. *
* *
******************************************************************************/
function addSeparator(menu) {
var sep = document.createElement("menuseparator");
sep.setAttribute("index", -1); // necessary for deleteHistoryItems(aMenu)
menu.appendChild(sep);
}
/******************************************************************************
* *
* Flips an URL in the specified direction *
* *
******************************************************************************/
function flipURL(dir, url) {
if(!url)
url = content.document.URL;
var position;
gBrowser.tabContainer.selectedItem.flipDirection = dir;
ourReferrer.spec = url;
loadURI(flipStringAtPosition(url, null, dir),
ourReferrer, null);
}
/******************************************************************************
* *
* Creates a list of URLs created by flipping the given url multiple times *
* in the specified direction *
* *
******************************************************************************/
function createFlipList(url, position, dir) {
if(!dir && gBrowser.tabContainer.selectedItem.flipDirection) {
dir = gBrowser.tabContainer.selectedItem.flipDirection;
} else if(!dir) {
dir = + 1;
}
var sgn = Math.abs(dir)/dir;
gBrowser.tabContainer.selectedItem.flipDirection = sgn;
var flipArray = new Array();
var referrerFlipArray = new Array();
if(!url) {
url = content.document.URL;
}
flipArray[0] = url;
for(var i = 1; i < max_history_menu_items_browseimages + 1; i++) {
/*** + 1 as the flipped items start at 1, item 0 is the given url ***/
//dump("flip-position="+position+"\n");
flipArray[i] = flipStringAtPosition(flipArray[i-1], position, sgn);
//dump(flipArray[i]+"<--\n");
if(flipArray[i] == null) {
flipArray.pop();
break;
}
//dump(flipArray[i]+"<\n");
if(dir < 0) {
if(!position) {
position = getFlipPosition(flipArray[i]);
}
//dump("position="+position+"\n");
//dump("char@position="+flipArray[i].charAt(position)+"\n");
var zeros = 0;
/* determine the number of leading zeros */
while(flipArray[i].charAt(position - zeros) == "0")
zeros++;
//dump("zeros="+zeros+"\n");
//dump("char@pos-zeros-1:"+flipArray[i].charAt(position - zeros - 1)+"\n");
/* if the flipping number is just zeros, stop flipping as we don't
need negative numbers */
if(zeros > 0 && isNaN(parseInt(flipArray[i].charAt(position - zeros )))) {
//flipArray.pop()
break;
}
}
//dump(flipArray[i]+">>\n");
if(flipArray[i].length > flipArray[i-1].length) {
position++;
}
referrerFlipArray[i] = url;
}
//dump("end: " + flipArray.join("\n") + "^^\n");
return flipArray;
}
/******************************************************************************
* *
* Increments the URL *
* *
******************************************************************************/
function incrementURL(url) {
flipURL(+1, url);
}
/******************************************************************************
* *
* Decrements the URL *
* *
******************************************************************************/
function decrementURL(url) {
flipURL(-1, url);
}
/******************************************************************************
* *
* Gets the position at which the url should be flipped *
* *
******************************************************************************/
function getFlipPosition(string) {
if(!string)
return null;
var position = -1;
if(gBrowser.tabContainer.selectedItem.position) {
position = gBrowser.tabContainer.selectedItem.position;
if(position < string.length &&
!isNaN(parseInt(string.charAt(position)))) {
gBrowser.tabContainer.selectedItem.position = position;
return position;
}
}
var positions = getDigitPositions(string);
if(positions.length == 0) {
return null;
}
position = positions[positions.length - 1];
gBrowser.tabContainer.selectedItem.position = position;
return position;
}
/******************************************************************************
* *
* Flips an string at the given position *
* *
******************************************************************************/
function flipStringAtPosition(string, position, by, isRecursive) {
if(!position || position >= string.length ||
(isNaN(parseInt(string.charAt(position))) && !isRecursive) ) {
position = getFlipPosition(string);
if(position == null) {
return null;
}
}
var digit = parseInt(string.charAt(position));
if(!isNaN(digit)) {
digit += by;
}
if(digit >= 0 && digit <= 9) {
string = string.substring(0, position ) + digit + string.substring(position + 1, string.length);
return string;
} else if(digit < 0) {
string = string.substring(0, position) + 9 + string.substring(position + 1, string.length);
return flipStringAtPosition(string, position - 1, by, true);
} else if(digit > 9) {
string = string.substring(0, position) + 0 + string.substring(position + 1, string.length);
return flipStringAtPosition(string, position - 1, by, true);
} else if(isNaN(digit) && by > 0) {
string = string.substring(0, position + 1) + "1" + string.substring(position + 1, string.length);
gBrowser.tabContainer.selectedItem.position++;
return string;
}
return string;
}
/******************************************************************************
* *
* Returns an Array with all image positions of a string *
* *
******************************************************************************/
function getDigitPositions(string) {
var findPos = 0;
var startPos = 0;
var positions = new Array();
while(string && (findPos = string.substring(
startPos, string.length).search(/\d/)) != -1) {
startPos += findPos;
positions.push(startPos++);
}
return positions;
}
/******************************************************************************
* *
* Shows the IncDecDialog in which the user specifies the flipping direction *
* and position *
* *
******************************************************************************/
function incDecDialog(url) {
var positions = getDigitPositions(url);
var returnValue = new Array(2);
var flipDirection = gBrowser.tabContainer.selectedItem.flipDirection;
window.openDialog("chrome://browseimages/content/browseImagesIncDecDialog.xul",
"BrowseImagesIncDecDia" + new Date().getTime(), "chrome,resizable,modal,centerScreen",
url, positions, flipDirection, returnValue);
if("flipPosition" in returnValue) {
ourReferrer.spec = url;
gBrowser.tabContainer.selectedItem.position
= returnValue.flipPosition - 1;
if(returnValue.flipDirection == "decrement") {
flipDirection = - 1;
} else {
flipDirection = + 1;
}
gBrowser.tabContainer.selectedItem.flipDirection = flipDirection;
if(flipDirection < 0) {
decrementURL(url);
} else {
incrementURL(url);
}
} else if("newURL" in returnValue) {
if(returnValue.flipDirection == "decrement") {
flipDirection = - 1;
} else {
flipDirection = + 1;
}
gBrowser.tabContainer.selectedItem.flipDirection = flipDirection;
incDecDialog(returnValue.newURL);
}
}
/******************************************************************************
* *
* Creates the Next Image Toolbarbutton Menu *
* *
******************************************************************************/
function fillNextImageMenu(menupopup) {
createImgList();
var startindex = positionInList(content.document.URL, imgListArray) + 1
if(startindex == imgListArray.length)
startindex = 0;
fillMenuPopup(menupopup, imgListArray, startindex, imgListArray.length - 1);
}
/******************************************************************************
* *
* Creates the Prev Image Toolbarbutton Menu *
* *
******************************************************************************/
function fillPrevImageMenu(menupopup) {
createImgList();
var startindex = positionInList(content.document.URL, imgListArray) - 1
if(startindex == - 1)
startindex = imgListArray.length - 1;
fillMenuPopup(menupopup, imgListArray, startindex, 0);
var indexIndex = imgListArray.length - 1;
var uriParts = imgListArray[indexIndex].split("/");
var label = uriParts[uriParts.length - 1] + " (" +
imgListArray[indexIndex] + ")";
createMenuItem(menupopup, indexIndex, label, imgListArray[indexIndex]);
}
/******************************************************************************
* *
* Creates the Increment URL Toolbarbutton Menu *
* *
******************************************************************************/
function fillIncrementListMenu(menupopup) {
var flipList = createFlipList(null, null, +1).slice(1);
fillMenuPopup(menupopup, flipList, 0, flipList.length - 1);
}
/******************************************************************************
* *
* Creates the Decrement URL Toolbarbutton Menu *
* *
******************************************************************************/
function fillDecrementListMenu(menupopup) {
var flipList = createFlipList(null, null, -1).slice(1);
fillMenuPopup(menupopup, flipList, 0, flipList.length - 1);
}
/******************************************************************************
* *
* Generic Function for creating a Toolbarbutton Menu *
* *
******************************************************************************/
function fillMenuPopup(menupopup, list, startindex, endindex) {
deleteHistoryItems(menupopup);
var by;
if(startindex > endindex)
by = -1;
else
by = +1;
for(var i = startindex; i != endindex + by; i += by) {
var uriParts = list[i].split("/");
var label = uriParts[uriParts.length - 1] + " (" + list[i] + ")";
createMenuItem(menupopup, i, label, list[i]);
}
}
/******************************************************************************
* *
* Manages Toolbarbutton status *
* *
******************************************************************************/
function setToolbarbuttonsMenusStatus() {
if(!content || !content.document || !content.document.URL)
return;
if(imgListArray.length <= 1) {
if(document.getElementById("browseimages-toolbarbuttons-saveImages"))
document.getElementById("browseimages-toolbarbuttons-saveImages")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-backToIndex"))
document.getElementById("browseimages-toolbarbuttons-backToIndex")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-prevImage"))
document.getElementById("browseimages-toolbarbuttons-prevImage")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-nextImage"))
document.getElementById("browseimages-toolbarbuttons-nextImage")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-backToIndex-classic"))
document.getElementById("browseimages-toolbarbuttons-backToIndex-classic")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-prevImage-classic"))
document.getElementById("browseimages-toolbarbuttons-prevImage-classic")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-nextImage-classic"))
document.getElementById("browseimages-toolbarbuttons-nextImage-classic")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-openInNewTab"))
document.getElementById("browseimages-toolbarbuttons-openInNewTab")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-openInTab"))
document.getElementById("browseimages-toolbarbuttons-openInTab")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-openInTabs"))
document.getElementById("browseimages-toolbarbuttons-openInTabs")
.setAttribute("disabled", "true");
} else {
if(document.getElementById("browseimages-toolbarbuttons-backToIndex"))
document.getElementById("browseimages-toolbarbuttons-backToIndex")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-nextImage"))
document.getElementById("browseimages-toolbarbuttons-nextImage")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-prevImage"))
document.getElementById("browseimages-toolbarbuttons-prevImage")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-backToIndex-classic"))
document.getElementById("browseimages-toolbarbuttons-backToIndex-classic")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-nextImage-classic"))
document.getElementById("browseimages-toolbarbuttons-nextImage-classic")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-prevImage-classic"))
document.getElementById("browseimages-toolbarbuttons-prevImage-classic")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-openInNewTab"))
document.getElementById("browseimages-toolbarbuttons-openInNewTab")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-openInTab"))
document.getElementById("browseimages-toolbarbuttons-openInTab")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-openInTabs"))
document.getElementById("browseimages-toolbarbuttons-openInTabs")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-saveImages"))
document.getElementById("browseimages-toolbarbuttons-saveImages")
.removeAttribute("disabled");
}
if(content.document.URL.toString().search(/\d/) == -1) {
if(document.getElementById("browseimages-toolbarbuttons-incrementURL"))
document.getElementById("browseimages-toolbarbuttons-incrementURL")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-decrementURL"))
document.getElementById("browseimages-toolbarbuttons-decrementURL")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-incrementURL-classic"))
document.getElementById("browseimages-toolbarbuttons-incrementURL-classic")
.setAttribute("disabled", "true");
if(document.getElementById("browseimages-toolbarbuttons-decrementURL-classic"))
document.getElementById("browseimages-toolbarbuttons-decrementURL-classic")
.setAttribute("disabled", "true");
} else {
if(document.getElementById("browseimages-toolbarbuttons-incrementURL"))
document.getElementById("browseimages-toolbarbuttons-incrementURL")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-decrementURL"))
document.getElementById("browseimages-toolbarbuttons-decrementURL")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-incrementURL-classic"))
document.getElementById("browseimages-toolbarbuttons-incrementURL-classic")
.removeAttribute("disabled");
if(document.getElementById("browseimages-toolbarbuttons-decrementURL-classic"))
document.getElementById("browseimages-toolbarbuttons-decrementURL-classic")
.removeAttribute("disabled");
}
}
/******************************************************************************
* *
* Called by clicking the next image or prev image toolbarbutton menu for *
* going to the desired image *
* *
******************************************************************************/
function fromToolbarbuttonMenuGotoImage(event) {
var index = parseInt(event.target.getAttribute("index"));
ourReferrer.spec = referrerArray[index];
loadURI(imgListArray[index], ourReferrer, null);
}
/******************************************************************************
* *
* Called by clicking the increment url toolbarbutton menu for going to the *
* desired url *
* *
******************************************************************************/
function fromToolbarbuttonMenuGotoIncrementedURL(event) {
fromToolbarbuttonMenuGotoFlippedURL(event, +1);
}
/******************************************************************************
* *
* Called by clicking the decrement url toolbarbutton menu for going to the *
* desired url *
* *
******************************************************************************/
function fromToolbarbuttonMenuGotoDecrementedURL(event) {
fromToolbarbuttonMenuGotoFlippedURL(event, -1);
}
/******************************************************************************
* *
* Generic function for going to a url of a flip list *
* *
******************************************************************************/
function fromToolbarbuttonMenuGotoFlippedURL(event, dir) {
var index = parseInt(event.target.getAttribute("index"));
ourReferrer.spec = content.document.URL;
loadURI(createFlipList(null, null, dir).slice(1)[index], ourReferrer, null);
}
function saveImages() {
// try {
var directory = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
//var dir = lastSaveDir;
// if(promptForSaveDir) {
var filepicker = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(Components.interfaces.nsIFilePicker);
if(lastSaveDir != "") {
/* for Things like C:, D: in Win */
if(lastSaveDir.length == "2" && lastSaveDir.charAt(1) == ":")
lastSaveDir += "\\\\";
directory.initWithPath(lastSaveDir);
}
filepicker.displayDirectory = directory;
if(props == null)
props = document.getElementById("gstrings");
filepicker.init(window, props.getString("filepickerTitle"), filepicker.modeGetFolder);
if(filepicker.show() == filepicker.returnOK) {
lastSaveDir = filepicker.file.path;
//dir = filepicker.file.path;
} else {
return;
}
//}
prefBranch.setCharPref("saveDirectory", lastSaveDir);
//dir += getPathSeparator() + getSaveDirName();
//directory.initWithPath(dir);
//if(!directory.exists()) {
// try {
// directory.create(directory.DIRECTORY_TYPE, 511);
// } catch(exc) {
// alert(">>>>Creating of the target directory failed.\n\n" + exc);
// }
//} else {
// /* overwrite or rename? */
//}
for(var i = 0; i < imgListArray.length - 1; i++) {
saveImageFile(i, lastSaveDir);
}
// } catch(excep) {
// alert(excep);
// }
}
function getSaveDirName() {
var name = encodeURIComponent(imgListArray[imgListArray.length - 1].replace(/http:\/\/www\./, "").replace(/http:\/\//, ""));
return name;
}
function saveImageFile(index, directory) {
var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
.createInstance(Components.interfaces.nsIWebBrowserPersist);
var uri = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURI);
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
ourReferrer.spec = imgListArray[imgListArray.length - 1];
uri.spec = imgListArray[index];
var uriparts = imgListArray[index].toString().split("/");
file.initWithPath(directory + getPathSeparator() + encodeURIComponent(uriparts[uriparts.length - 1]));
persist.saveURI(uri, null, ourReferrer, null, null, file);
}
function getPathSeparator() {
return navigator.platform.search(/win/i) == -1 ? "/" : "\\";
}
/*******************************************************************************
* The following two methods were copied and licensed under the MPL/GPL/LPGL *
* tri-license from the original firefox file "browser.js" by me, Juergen *
* Binder, In Firefox you can view the "browser.js" with the URL *
* "chrome://browser/content/browser.js". The current version of the *
* browser.js file can be found on *
http://lxr.mozilla.org/aviary101branch/source/browser/base/content/browser.js
* At the moment (March 10, 2005) starts the FillHistoryMenu function at line *
* #2427 and the createMenuItem function starts at line #2501 *
* *
* The Original Browser.js Code of this function is mozilla.org code. *
* The code of the extended function is Juergen Binder's Browse Image code *
* *
* The Initial Developer of the Original Browser.js Code of this function is *
* Netscape Communications Corporation. *
* Portions created by the Initial Developer are Copyright (C) 1998 *
* the Initial Developer. All Rights Reserved. *
* *
* The Initial Developer of the extended function's Code is Juergen Binder. *
* Portions created by Juergen Binder are Copyright (C) 2005 *
* Juergen Binder. All Rights Reserved. *
* *
* *
* Contributor(s) of the orginal code: *
* Blake Ross *
* David Hyatt *
* Peter Annema *
* Dean Tessman *
* Kevin Puetz (puetzk@iastate.edu) *
* Ben Goodger *
* Pierre Chanial *
* Jason Eager *
* Joe Hewitt *
* Alec Flett *
* *
* Contributor of the function extending code: *
* Juergen Binder *
* *
* *
* *
* I, Juergen Binder, have done the following changes: *
* - The constant MAX_HISTORY_MENU_ITEMS was replaced by the variable *
* max_history_menu_items_browseimages, marked with comment tags /**/ /*
* - 5 code blocks were added. They are marked with Browse Image Addition #i *
* Tags *
* - In the forward block in line 2136 I inserted a "+ 1" between ? and : *
* to fix a bug, I marked this with /*!*/ /*
* *
* No line of the original code was deleted or changed otherwise than *
* mentioned above. *
* *
********************************************************************************
* *
* If I have made a mistake licensing the code, please just email me at *
* juergenbinder@quantentunnel.de and I'll correct it immediatly so suing *
* won't be necessary and just wasting of time and money :-) *
* *
********************************************************************************
* *
* This function creates the dropdownlist of the forward and back buttons. *
* Some lines are added to add Browse Images' next Image, previous Image and *
* backtoIndex functionality. *
* *
*******************************************************************************/
function FillHistoryMenu (aParent, aMenu) {
// Remove old entries if any
deleteHistoryItems(aParent);
var sessionHistory = getWebNavigation().sessionHistory;
if(!sessionHistory)
return false;
var count = sessionHistory.count;
var index = sessionHistory.index;
var end;
var j;
var entry;
switch (aMenu)
{
case "back":
/****************** Begin Browse Images Addition 1 ******************/
if(imgListArray.length > 1) {
if(back_prevImg == 2) {
createSpecialMenuItem(aParent, "prevImage", sessionHistory.getEntryAtIndex(index - 1, false).URI.spec);
}
if(back_backToIndex == 2) {
createSpecialMenuItem(aParent, "backToIndex", imgListArray[imgListArray.length - 1]);
}
if(back_prevImg == 2 || back_backToIndex == 2) {
addSeparator(aParent);
}
}
/******************* End Browse Images Addition 1 *******************/
end = (index > /**/ max_history_menu_items_browseimages /**/ ) ? index - /**/ max_history_menu_items_browseimages /**/ : 0;
if ((index - 1) < end) return false;
for (j = index - 1; j >= end; j--)
{
entry = sessionHistory.getEntryAtIndex(j, false);
if (entry)
createMenuItem(aParent, j, entry.title, entry.URI.spec);
}
/****************** Begin Browse Images Addition 2 ******************/
if(imgListArray.length > 1) {
if(back_prevImg == 1 || back_backToIndex == 1) {
addSeparator(aParent);
}
if(back_prevImg == 1) {
createSpecialMenuItem(aParent, "prevImage", sessionHistory.getEntryAtIndex(index - 1, false).URI.spec);
}
if(back_backToIndex == 1) {
createSpecialMenuItem(aParent, "backToIndex", imgListArray[imgListArray.length - 1]);
}
}
/******************* End Browse Images Addition 2 *******************/
break;
case "forward":
/****************** Begin Browse Images Addition 3 ******************/
if(imgListArray.length > 1 && forward_nextImg == 2) {
createSpecialMenuItem(aParent, "nextImage", sessionHistory.getEntryAtIndex(index + 1, false).URI.spec);
addSeparator(aParent);
}
/******************* End Browse Images Addition 3 *******************/
end = ((count-index) > /**/ max_history_menu_items_browseimages /**/ ) ? index + /**/ max_history_menu_items_browseimages + 1/*!*/ : count;
if ((index + 1) >= end) return false;
for (j = index + 1; j < end; j++)
{
entry = sessionHistory.getEntryAtIndex(j, false);
if (entry)
createMenuItem(aParent, j, entry.title, entry.URI.spec);
}
/****************** Begin Browse Images Addition 4 ******************/
if(index + end < count) {
}
if(imgListArray.length > 1 && forward_nextImg == 1) {
addSeparator(aParent);
createSpecialMenuItem(aParent, "nextImage", sessionHistory.getEntryAtIndex(index + 1, false).URI.spec);
}
/******************* End Browse Images Addition 4 *******************/
break;
case "go":
aParent.lastChild.hidden = (count == 0);
end = count > /**/ max_history_menu_items_browseimages /**/ ? count - /**/ max_history_menu_items_browseimages /**/ : 0;
for (j = count - 1; j >= end; j--)
{
entry = sessionHistory.getEntryAtIndex(j, false);
if (entry)
createRadioMenuItem(aParent, j, entry.title, j==index);
}
break;
}
return true;
}
function createMenuItem( aParent, aIndex, aLabel, aTooltiptext) {
var menuitem = document.createElement( "menuitem" );
menuitem.setAttribute( "label", aLabel );
menuitem.setAttribute( "index", aIndex );
/********************* Begin Browse Images Addition 5 *********************/
menuitem.setAttribute("tooltiptext", aTooltiptext);
/*********************** End Browse Images Addition 5 *********************/
aParent.appendChild( menuitem );
}
PK
>5 fRR\ R\ 3 chrome/content/browseimages/browseImagesOptions.xul
PK
>5!p p 2 chrome/content/browseimages/browseImagesOptions.js/* * * * * * * * * * * * * 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 Juergen Binder's Browse Images Code
*
* The Initial Developer of the Original Code is Juergen Binder.
* Portions created by Juergen Binder are Copyright (C) 2005
* Juergen Binder. All Rights Reserved.
*
* Contributor(s): Juergen Binder.
*
* 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 prefBranch = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch("browseimages.");
var props = document.getElementById("g-strings");
var availableList = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
var enabledList = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
var addButton = document.getElementById("browseimages.options.statusbar.menuitems.buttons.add");
var removeButton = document.getElementById("browseimages.options.statusbar.menuitems.buttons.remove");
function BIOinit() {
if(addButton == null) {
addButton = document.getElementById("browseimages.options.statusbar.menuitems.buttons.add");
}
if(removeButton == null) {
removeButton = document.getElementById("browseimages.options.statusbar.menuitems.buttons.remove");
}
if(prefBranch.getBoolPref("centerImages")) {
document.getElementById("browseimages.options.centerimages").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.centerimages").setAttribute("checked","false");
}
if(prefBranch.getBoolPref("autoBack")) {
document.getElementById("browseimages.options.autoBack").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.autoBack").setAttribute("checked","false");
}
if(prefBranch.getBoolPref("statusbarMenu")) {
document.getElementById("browseimages.options.statusbarMenu").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.statusbarMenu").setAttribute("checked","false");
}
if(prefBranch.getBoolPref("toolsMenu")) {
document.getElementById("browseimages.options.toolsMenu").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.toolsMenu").setAttribute("checked","false");
}
if(prefBranch.getBoolPref("autoScan")) {
document.getElementById("browseimages.options.autoScan").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.autoScan").setAttribute("checked","false");
}
if(prefBranch.getBoolPref("goMenu")) {
document.getElementById("browseimages.options.goMenu").setAttribute("checked","true");
} else {
document.getElementById("browseimages.options.goMenu").setAttribute("checked","false");
}
/*document.getElementById("browseimages.options.background.color.value").value = prefBranch.getCharPref("backgroundcolor");
document.getElementById("browseimages.options.background.image.value").value = prefBranch.getCharPref("backgroundimage");*/
document.getElementById("browseimages.options.historyMenuOptions.index.group")
.selectedIndex = 2 - prefBranch.getIntPref("back_history_menu_backToIndex");
document.getElementById("browseimages.options.historyMenuOptions.back.group")
.selectedIndex = 2 - prefBranch.getIntPref("back_history_menu_prevImg");
document.getElementById("browseimages.options.historyMenuOptions.forward.group")
.selectedIndex = 2 - prefBranch.getIntPref("forward_history_menu_nextImg");
document.getElementById("browseimages.options.historyMenuOptions.count")
.value = prefBranch.getIntPref("max_history_menu_items");
/*document.getElementById("browseimages.save.directory.radiogroup")
.selectedIndex = prefBranch.getIntPref("saveBehaviour");
document.getElementById("browseimages.save.directory.textbox").value = prefBranch.getCharPref("saveDirectory");*/
var txtbx = document.getElementById(
"browseimages.options.historyMenuOptions.count")
.inputField;
txtbx.setAttribute("style", "text-align:right;");
BIOloadMenuitems(prefBranch.getCharPref("statusbarMenuitems").split(","));
switch(prefBranch.getCharPref("iconset")) {
case "Flip-Flap" :
document.getElementById("browseimages.options.iconset.Flip-Flap")
.setAttribute("selected", "true");
break;
case "classic" :
document.getElementById("browseimages.options.iconset.classic")
.setAttribute("selected", "true");
break;
}
BIOiconPreview();
/*
var theList = prefBranch.getCharPref("theList");
var theListArray = theList.split("\t");
var rule;
var status;
for(var i = 0; i < theListArray.length - 1; i += 2) {
rule = theListArray[i];
status = theListArray[i + 1];
BIOaddToList(rule, status);
}*/
document.getElementById("browseimages.options.largeNumberOfLinks.textbox")
.value = prefBranch.getIntPref("largeNumberOfLinksLimit");
document.getElementById("browseimages.options.largeNumberOfLinks.defaultAction").selectedIndex = prefBranch.getIntPref("largeNumberOfLinksDefaultAction");
}
function BIOremoveAllChildNodes(list) {
while(list.hasChildNodes()) {
list.removeChild(list.firstChild);
}
}
function BIOloadMenuitems(order) {
var availableList = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
var enabledList = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
var masterItem = document.getElementById("browseimages.options.statusbar.menuitems.master.list").childNodes;
BIOremoveAllChildNodes(availableList);
BIOremoveAllChildNodes(enabledList);
var availableListItems = new Array(masterItem.length);
availableList.appendItem(masterItem[1].label, masterItem[1].value);
for(var i = 0; i < order.length; i++) {
var number = parseInt(order[i]) + 1;
if(isNaN(number)){
continue;
}
enabledList.appendItem(masterItem[number].label, masterItem[number].value);
availableListItems[number] = true;
//availableList.
}
for(var j = 1; j < availableListItems.length; j++) {
if(!availableListItems[j]) {
availableList.appendItem(masterItem[j].label, masterItem[j].value);
}
}
if(availableList.getRowCount() > 0) {
availableList.selectedIndex = 0;
BIOclick(true);
} else {
enabledList.selectedIndex = 0;
BIOclick(false);
}
}
function BIOreset() {
var mi = prefBranch.getCharPref("statusbarMenuitems");
if(prefBranch.prefHasUserValue("statusbarMenuitems"))
prefBranch.clearUserPref("statusbarMenuitems");
BIOloadMenuitems(prefBranch.getCharPref("statusbarMenuitems"));
prefBranch.setCharPref("statusbarMenuitems", mi);
}
function BIOsave() {
if(document.getElementById("browseimages.options.statusbarMenu").getAttribute("checked") == "true") {
prefBranch.setBoolPref("statusbarMenu", 1);
} else {
prefBranch.setBoolPref("statusbarMenu", 0);
}
if(document.getElementById("browseimages.options.goMenu").getAttribute("checked") == "true") {
prefBranch.setBoolPref("goMenu", 1);
} else {
prefBranch.setBoolPref("goMenu", 0);
}
if(document.getElementById("browseimages.options.toolsMenu").getAttribute("checked") == "true") {
prefBranch.setBoolPref("toolsMenu", 1);
} else {
prefBranch.setBoolPref("toolsMenu", 0);
}
if(document.getElementById("browseimages.options.centerimages").getAttribute("checked") == "true") {
prefBranch.setBoolPref("centerImages", 1);
} else {
prefBranch.setBoolPref("centerImages", 0);
}
if(document.getElementById("browseimages.options.autoBack").getAttribute("checked") == "true") {
prefBranch.setBoolPref("autoBack", 1);
} else {
prefBranch.setBoolPref("autoBack", 0);
}
if(document.getElementById("browseimages.options.autoScan").getAttribute("checked") == "true") {
prefBranch.setBoolPref("autoScan", 1);
} else {
prefBranch.setBoolPref("autoScan", 0);
}
prefBranch.setIntPref("back_history_menu_backToIndex",
2 - document.getElementById(
"browseimages.options.historyMenuOptions.index.group")
.selectedIndex);
prefBranch.setIntPref("back_history_menu_prevImg",
2 - document.getElementById(
"browseimages.options.historyMenuOptions.back.group")
.selectedIndex);
prefBranch.setIntPref("forward_history_menu_nextImg",
2 - document.getElementById(
"browseimages.options.historyMenuOptions.forward.group")
.selectedIndex);
prefBranch.setIntPref("max_history_menu_items", document.getElementById(
"browseimages.options.historyMenuOptions.count").value);
/*prefBranch.setCharPref("backgroundcolor", document.getElementById("browseimages.options.background.color.value").value);
prefBranch.setCharPref("backgroundimage", document.getElementById("browseimages.options.background.image.value").value);*/
var availableList = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
var enabledList = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
var menuitemlist = new String();
for(var i = 0; i < enabledList.getRowCount(); i++) {
menuitemlist += enabledList.getItemAtIndex(i).value + ",";
}
prefBranch.setCharPref("statusbarMenuitems", menuitemlist);
var iconradiogroup = document.getElementById("browseimages.options.iconset.radiogroup");
prefBranch.setCharPref("iconset", iconradiogroup.selectedItem.value);
document.getElementById("browseimages.options.theList.tree").save();
document.getElementById("browseimages.options.largeNumberOfLinks.tree").save();
prefBranch.setIntPref("largeNumberOfLinksLimit", parseInt(
document.getElementById(
"browseimages.options.largeNumberOfLinks.textbox").value));
prefBranch.setIntPref("largeNumberOfLinksDefaultAction", document.getElementById("browseimages.options.largeNumberOfLinks.defaultAction").selectedIndex);
/*
prefBranch.setIntPref("saveBehaviour",
document.getElementById("browseimages.save.directory.radiogroup")
.selectedIndex);
prefBranch.setCharPref("saveDirectory",
document.getElementById("browseimages.save.directory.textbox").value);
*/
return true;
}
function BIOclick(bool) {
if(bool) {
addButton.setAttribute("disabled", "false");
removeButton.setAttribute("disabled", "true");
} else {
addButton.setAttribute("disabled","true");
removeButton.setAttribute("disabled","false");
}
}
/*
* true => add
* false => remove
*/
function BIOaddMenuItem(bool) {
var sourceList = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
var targetList = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
if(!bool) {
var tempList = sourceList;
sourceList = targetList;
targetList = tempList;
}
var listitem;
for(var i = 0; i < sourceList.getRowCount(); i++) {
listitem = sourceList.getItemAtIndex(i);
if(listitem.selected) {
try{
var removeIndex = i;
if(listitem.getAttribute("value") != "0" || bool) {
if(targetList.selectedIndex > -1) {
targetList.insertItemAt(targetList.selectedIndex, listitem.label, listitem.value);
} else {
targetList.appendItem(listitem.label, listitem.value);
}
if(listitem.getAttribute("value") != "0") {
i--;
}
} else if(!bool) {
i--;
}
if(listitem.getAttribute("value") != "0" || !bool) {
listitem = sourceList.removeItemAt(removeIndex);
}
/*
alert(listitem.getAttribute("label")+ "\n" +
listitem.getAttribute("oncommand")+ "\n" +
listitem.getAttribute("value")+ "\n");*/
} catch(ex) {
alert(ex);
}
}
}
}
/* true => moveup
* false => movedown
*/
function BIOmove(dir) {
var delta;
var list;
var listitem;
var moveFirstIndex;
var moveLastIndex;
var dontForgetToSelect = new Array();
if(addButton.getAttribute("disabled") == "true") {
list = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
} else {
list = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
}
if(dir) {
moveFirstIndex = 1;
moveLastIndex = list.getRowCount();
delta = +1;
} else {
moveFirstIndex = list.getRowCount() - 2;
moveLastIndex = -1;
delta = -1;
}
for(var i = moveFirstIndex; i != moveLastIndex; i += delta) {
listitem = list.getItemAtIndex(i)
if(listitem.selected) {
listitem = list.removeItemAt(i);
i -= delta;
if(i == list.getRowCount()) {
listitem = list.appendItem(listitem.label, listitem.value);
} else {
listitem = list.insertItemAt(i, listitem.label, listitem.value);
}
dontForgetToSelect.push(listitem);
}
}
for(var j in dontForgetToSelect) {
list.addItemToSelection(dontForgetToSelect[j]);
}
}
function BIOselectAll() {
var availableList = document.getElementById("browseimages.options.statusbar.menuitems.available.list");
var enabledList = document.getElementById("browseimages.options.statusbar.menuitems.enabled.list");
if(addButton.getAttribute("disabled") == "true") {
try {
enabledList.selectAll();
} catch (e) {
availableList.selectAll();
}
} else {
/* could not be emtpy as separator always remains there */
availableList.selectAll();
}
}
/*
function BIOaddToList(rule, status) {
if(props == null) {
props = document.getElementById("g-strings");
}
try {
status = props.getString(status);
} catch(e) {}
var treechildren = document.getElementById("browseimages.options.theliststree.children");
if(rule == null) {
rule = document.getElementById("browseimages.options.liststextbox").value;
}
if(rule == "") {
return;
}
//alert(rule + "\n\n\\/\n\n" + createRegExp(rule));
var ruleCol = document.getElementById("browseimages.options.theliststree.ruleCol");
var statusCol = document.getElementById("browseimages.options.theliststree.statusCol");
var index = getIndexForRule(rule)
if(index > -1) {
BIOsetStatusOfSelection(status);
statusCol.setAttribute("sortDirection", "natural");
return;
}
var item = document.createElement("treeitem");
var row = document.createElement("treerow");
var ruleCell = document.createElement("treecell");
var statusCell = document.createElement("treecell");
ruleCell.setAttribute("label", rule);
statusCell.setAttribute("label", status);
row.appendChild(ruleCell);
row.appendChild(statusCell);
item.appendChild(row);
treechildren.appendChild(item);
ruleCol.setAttribute("sortDirection", "natural");
statusCol.setAttribute("sortDirection", "natural");
}
function BIOsetStatusOfSelection(status) {
var tree = document.getElementById("browseimages.options.theliststree");
var treechildren = document.getElementById("browseimages.options.theliststree.children");
var nodes = treechildren.childNodes;
for(var i = 0; i < nodes.length; i++) {
if(tree.view.selection.isSelected(i)) {
nodes[i].firstChild.lastChild.setAttribute("label", status);
}
}
}
function BIOeditSelectedRule() {
var index = document.getElementById("browseimages.options.theliststree").currentIndex
if(index == -1)
return;
var rule = document.getElementById("browseimages.options.liststextbox").value;
if(getIndexForRule(rule) == -1) {
document.getElementById("browseimages.options.theliststree.children")
.childNodes[index].firstChild.firstChild.setAttribute("label",
rule);
} else {
if(props == null) {
props = document.getElementById("g-strings");
}
try {
alert(props.getString("alreadyInList"));
} catch (ex) {
alert(ex);
}
}
}
function getIndexForRule(rule) {
// var nodes = document.getElementById("browseimages.options.theliststree.children").childNodes;
for(var i = 0; i < nodes.length; i++) {
if(nodes[i].firstChild.firstChild.getAttribute("label") == rule) {
return i;
}
}
return -1;
}
function BIOtreeSelect(tree) {
var index = document.getElementById("browseimages.options.theliststree")
.currentIndex;
if(index > -1) {
document.getElementById("browseimages.options.liststextbox").value =
document.getElementById("browseimages.options.theliststree.children")
.childNodes[index].firstChild.firstChild.getAttribute("label");
}
}
function BIOremoveItemAtIndex(index) {
var treechildren = document.getElementById("browseimages.options.theliststree.children");
var childNodes = treechildren.childNodes;
treechildren.removeChild(childNodes[index]);
}
function BIOremove(mode) {
var index = document.getElementById("browseimages.options.theliststree").currentIndex;
var treechildren = document.getElementById("browseimages.options.theliststree.children");
var nodes = treechildren.childNodes;
var tree = document.getElementById("browseimages.options.theliststree");
switch (mode) {
case "all" :
while(treechildren.hasChildNodes()) {
treechildren.removeChild(treechildren.firstChild);
}
break;
case "selected" :
for(var i = 0; i < nodes.length; i++) {
if(tree.view.selection.isSelected(i)) {
BIOremoveItemAtIndex(i);
i--;
}
}
break;
}
}
function BIOtreeSort(colName) {
var col;
var dir;
var rule;
var status;
var rulesArray = new Array();
var splitter;
var newSortDirection;
var nodes = document.getElementById(
"browseimages.options.theliststree.children").childNodes;
if(colName == "ruleCol") {
dir = true;
col = document.getElementById(
"browseimages.options.theliststree.ruleCol");
} else {
dir = false;
col = document.getElementById(
"browseimages.options.theliststree.statusCol");
}
for(var i = 0; i < nodes.length; i++) {
rule = nodes[i].firstChild.firstChild.getAttribute("label");
status = nodes[i].firstChild.lastChild.getAttribute("label");
if(dir) {
rulesArray.push(rule + "\t" + status);
} else {
rulesArray.push(status + "\t" + rule);
}
}
switch (col.getAttribute("sortDirection")) {
case "ascending":
newSortDirection = "descending";
rulesArray.reverse();
break;
case "descending":
newSortDirection = "ascending";
rulesArray.reverse();
break;
case "natural":
default:
newSortDirection = "descending";
rulesArray.sort();
break;
}
BIOremove("all");
for(var j = 0; j < rulesArray.length; j++) {
splitter = rulesArray[j].split("\t");
if(dir) {
BIOaddToList(splitter[0], splitter[1]);
} else {
BIOaddToList(splitter[1], splitter[0]);
}
}
col.setAttribute("sortDirection", newSortDirection);
}
*/
function BIOtoggleExplanation() {
if(props == null) {
props = document.getElementById("g-strings");
}
var box = document.getElementById(
"browseimages.options.theliststree.description.box");
var button = document.getElementById(
"browseimages.options.theliststree.description.button");
if(box.getAttribute("hidden") == "true") {
box.setAttribute("hidden", "false");
button.setAttribute("label", props.getString("hideExplanation"));
} else {
box.setAttribute("hidden", "true");
button.setAttribute("label", props.getString("showExplanation"));
}
}
function BIOiconPreview() {
var iconset = document.getElementById(
"browseimages.options.iconset.radiogroup")
.selectedItem.value;
switch(iconset) {
case "Flip-Flap" :
document.getElementById(
"browseimages.options.iconset.preview.imagelinksfound")
.setAttribute("src","chrome://browseimages/skin/Flip-Flap.png");
document.getElementById(
"browseimages.options.iconset.preview.imagelinksfound")
.setAttribute("maxwidth","36");
document.getElementById(
"browseimages.options.iconset.preview.noimagelinksfound")
.setAttribute("src","chrome://browseimages/skin/Flip-Flap-grey.png");
document.getElementById(
"browseimages.options.iconset.preview.noimagelinksfound")
.setAttribute("maxwidth","36");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("src","chrome://browseimages/skin/Flip-Flap-sleep.png");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("maxwidth","36");
break;
case "classic" :
document.getElementById(
"browseimages.options.iconset.preview.imagelinksfound")
.setAttribute("maxwidth","36");
document.getElementById(
"browseimages.options.iconset.preview.imagelinksfound")
.setAttribute("src","chrome://browseimages/skin/classic-colored.png");
document.getElementById(
"browseimages.options.iconset.preview.noimagelinksfound")
.setAttribute("maxwidth","36");
document.getElementById(
"browseimages.options.iconset.preview.noimagelinksfound")
.setAttribute("src","chrome://browseimages/skin/classic-grey.png");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("src","chrome://browseimages/skin/classic-sleep.png");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("width","36");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("minwidth","36");
document.getElementById(
"browseimages.options.iconset.preview.deactivated")
.setAttribute("maxwidth","36");
break;
}
}
function BIOnumberCheck() {
var textbox = document.getElementById("browseimages.options.largeNumberOfLinks.textbox");
if(isNaN(parseInt(textbox.value))) {
textbox.value = "";
} else {
textbox.value = parseInt(textbox.value);
}
}
function BIObackgroundimageChooseFile() {
var txtbox = document.getElementById("browseimages.options.background.image.value");
var filepicker = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(Components.interfaces.nsIFilePicker);
var localfile = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
try {
var initDir = txtbox.value;
if(initDir.length == "2" && initDir.charAt(1) == ":")
initDir += "\\\\";
localfile.initWithPath(initDir);
} catch (exception) {
/* Don't complaine ;-) */
}
filepicker.displayDirectory = localfile;
if(props == null)
props = document.getElementById("g-strings");
filepicker.init(window, props.getString("filepickerTitle"), filepicker.modeOpen);
if(filepicker.show() == filepicker.returnOK) {
txtbox.value = filepicker.file.path;
}
}
PK
N=5 chrome/locale/PK
N=5 chrome/locale/de-DE/PK
N=5 ! chrome/locale/de-DE/browseimages/PK
h2p p - chrome/locale/de-DE/browseimages/contents.rdf
PK
2! = chrome/locale/de-DE/browseimages/browseImagesIncDecDialog.dtd
PK
rcf3 8 chrome/locale/de-DE/browseimages/browseimages.properties# Localized text used by JavaScript
nextImage = Nächstes Bild >>
prevImage = << Vorheriges Bild
backToIndex = |<< Zurück zum Index
imageLinksFound = Bilderlinks auf dieser Seite gefunden
noImageLinksFound = Keine Bilderlinks auf dieser Seite gefunden
autoScanDisabled = AutoScan deaktiviert.
notScanned = Die Seite wurde nicht nach Bilderlinks durchsucht.
confirmUrlChange = URL-Änderung bestätigen
enterNewUrl = Geben Sie die neue URL ein:
confirmScanningDialog = Diese Seite enthält !number! oder mehr Links. Ihr PC kann für eine kurze Zeit einfrieren, wenn sie diese Seite nach Bilderlinks durchsuchen lassen. Wählen sie 'OK' wenn sie die Seite trotzdem nach Bilderlinks durchsuchen lassen wollen oder 'Abbrechen' wenn sie das nicht wollen.
forAllSitesFrom = für alle Seiten von
picturesLinkedFrom = Verlinkte Bilder von
filepickerTitle = Wählen Sie den Ordner aus, in dem die Bilder gespeichert werden sollen
PK
idf39E E 8 chrome/locale/de-DE/browseimages/browseimagesOverlay.dtd
PK
df3 F chrome/locale/de-DE/browseimages/browseImagesConfirmScanningDialog.dtd
PK
P42! ! 8 chrome/locale/de-DE/browseimages/browseimagesOptions.dtd
PK
N=5 chrome/locale/en-US/PK
N=5 ! chrome/locale/en-US/browseimages/PK
2| = chrome/locale/en-US/browseimages/browseImagesIncDecDialog.dtd
PK
h2X8p p - chrome/locale/en-US/browseimages/contents.rdf
PK
= 2Sy 8 chrome/locale/en-US/browseimages/browseimagesOverlay.dtd
PK
kcf35y; ; 8 chrome/locale/en-US/browseimages/browseimages.properties# Localized text used by JavaScript
nextImage = Next Image >>
prevImage = << Previous Image
backToIndex = |<< Back to Index
imageLinksFound = Image Links found on this Page
noImageLinksFound = No Image Links found on this Page
autoScanDisabled = AutoScan is disabled.
notScanned = The Page wasn't scanned since it contains many links.
confirmUrlChange = Confirm URL Change
enterNewUrl = Enter the URL which you want to flip:
confirmScanningDialog = This site contains !number! or more links. Scanning this page for image links can freeze your computer for a while. Press 'OK' to scan anyway or 'Cancel' to continue without scanning for image links.
forAllSitesFrom = for all sites from
picturesLinkedFrom = Pictures linked from
filepickerTitle = Choose the folder in which the images should be saved
PK
W4/" " 8 chrome/locale/en-US/browseimages/browseimagesOptions.dtd
PK
df34 F chrome/locale/en-US/browseimages/browseImagesConfirmScanningDialog.dtd
PK
N=5 chrome/skin/PK
N=5 chrome/skin/classic/PK
N=5 ! chrome/skin/classic/browseimages/PK
2}4 4 3 chrome/skin/classic/browseimages/openInTab-grey.pngPNG
IHDR 7 bKGD ̿ pHYs tIME>U1 WtEXtComment (c) 2005, Juergen Binder (juergenbinder@quantentunnel.de). All Rights Reserved.WyU bIDAT(cd9F D@HbLh`=M
tV , S?mPP$b~#!Vd8
V`aq$ IENDB`PK
~2Nd| | 7 chrome/skin/classic/browseimages/openInNewTab-Large.pngPNG
IHDR w= bKGD pHYs tIME&0kc WtEXtComment (c) 2005, Juergen Binder (juergenbinder@quantentunnel.de). All Rights Reserved.WyU IDATHS1 ,뚗vZː*#,v;[0(B0-o):0pI5Y Xi "pZͫ`*+5LD"^H?0E = ۮ)Aism;S~>!3⁝ɣ2(QЂ IENDB`PK
2,o o 1 chrome/skin/classic/browseimages/openInNewTab.pngPNG
IHDR _ bKGD pHYs tIME\ WtEXtComment (c) 2005, Juergen Binder (juergenbinder@quantentunnel.de). All Rights Reserved.WyU IDAT8˥10C嗋X]BxAXγB|cZPA pW3/IMub=FuNpsk[