home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 February
/
Chip_2004-02_cd1.bin
/
software
/
del
/
regetdx.exe
/
RCDATA
/
CABINET
/
reget.jar
/
content
/
reget
/
rgt-ovr.xul
< prev
Wrap
Extensible Markup Language
|
2003-06-17
|
8KB
|
213 lines
<?xml version="1.0"?>
<!-- ***** 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 ReGet Mozilla Plugin.
-
- The Initial Developer of the Original Code is Marek Wawoczny.
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Marek Wawoczny (GmbH@MozillaPL.org)
-
- 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 ***** -->
<overlay id="regetOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://navigator/content/contentAreaUtils.js"/>
<script type="application/x-javascript" src="chrome://navigator/content/utilityOverlay.js"/>
<script type="application/x-javascript">
<![CDATA[
/**
* Converts Cyrillic letters in JavaScript string to cp1251.
* @author Peter B. Shalimoff (vshalim@home.ru).
* @param str - JavaScript string to be converted.
* @return converted string.
*/
function JS2CP1251(str) {
var rc = "";
const len = str.length;
var c, cc;
for (var i=0; i<len; i++) {
cc = (c = str[i]).charCodeAt(0);
if ( cc >> 8 == 4 ) { // a cyrillic letter
if ( cc == 0x0401 ) { // capital letter Io
rc += String.fromCharCode(168)
} else if ( cc == 0x0451 ) { // small letter Io
rc += String.fromCharCode(184);
} else { // other cyrillic letters
rc += String.fromCharCode(cc - 848);
}
} else { // not a cyrillic letter, leave it as is.
rc += c;
}
}
return rc;
}
cmn = Components.classes["RgCommon"].createInstance(Components.interfaces.nsIRgCommon);
function DownloadBy() {
var url = Components.classes["RgUrl"].createInstance(Components.interfaces.nsIRgUrl);
url.url = gContextMenu.linkURL();
url.info = JS2CP1251(gContextMenu.linkText());
url.referer = window._content.location.href;
url.add();
}
function DownloadAll() {
var list = Components.classes["RgUrlList"].createInstance(Components.interfaces.nsIRgUrlList);
var doc = gContextMenu.target.ownerDocument;
var links = doc.links
for (i = 0; i < links.length; i++)
{
var url = Components.classes["RgUrl"].createInstance(Components.interfaces.nsIRgUrl);
url.url = links[i].href;
url.info = JS2CP1251(links[i].text);
url.referer = window._content.location.href;
list.add(url);
}
list.list();
}
function initReGetContextMenuItems(aEvent)
{
if (cmn.menu1 != null)
{
var s=cmn.menu1;
r=s.search("&");
if (r!=-1)
{
document.getElementById("download-by-catcher").setAttribute("accesskey", s.charAt(r+1).toLowerCase( ));
} else
{
document.getElementById("download-by-catcher").setAttribute("accesskey", "");
}
s=s.replace("&","");
document.getElementById("download-by-catcher").setAttribute("label", s);
}
if (cmn.menu2 != null)
{
var s=cmn.menu2;
r=s.search("&");
if (r!=-1)
{
document.getElementById("download-all-by-catcher").setAttribute("accesskey", s.charAt(r+1).toLowerCase( ));
} else
{
document.getElementById("download-all-by-catcher").setAttribute("accesskey", "");
}
s=s.replace("&","");
document.getElementById("download-all-by-catcher").setAttribute("label", s);
}
gContextMenu.showItem("download-by-catcher", gContextMenu.onSaveableLink);
gContextMenu.showItem("context-sep-reget-start", gContextMenu.onSaveableLink);
}
function initReGetContextMenuListener(aEvent)
{
// document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", initReGetContextMenuItems, false);
var contentAreaContextMenu = window.document.getElementById("contentAreaContextMenu");
if (contentAreaContextMenu)
contentAreaContextMenu.addEventListener("popupshowing", initReGetContextMenuItems, false);
window.removeEventListener("load", initReGetContextMenuListener, true);
}
function altKeyDownloadBy(aEvent)
{
if (cmn.catchLinks) {
if (aEvent.button == 0 && (aEvent.altKey || !cmn.useAlt)) {
var linkNode;
var localName = aEvent.target.localName;
if (localName) {
localName = localName.toLowerCase();
}
switch (localName) {
case "a":
case "area":
case "link":
if (aEvent.target.hasAttribute("href"))
linkNode = aEvent.target;
break;
default:
linkNode = findParentNode(aEvent.originalTarget, "a");
if (linkNode && !linkNode.hasAttribute("href"))
linkNode = null;
break;
}
if (linkNode) {
var text = gatherTextUnder(linkNode);
if (!text || !text.match(/\S/)) {
text = linkNode.getAttribute("title");
if (!text || !text.match(/\S/)) {
text = linkNode.getAttribute("alt");
if (!text || !text.match(/\S/)) {
text = linkNode.href;
}
}
}
var url = Components.classes["RgUrl"].createInstance(Components.interfaces.nsIRgUrl);
url.url = linkNode.href;
url.info = JS2CP1251(text);
url.referer = window._content.location.href;
url.add();
}
}
}
}
window.addEventListener("load", initReGetContextMenuListener, true);
getBrowser().addEventListener("click", altKeyDownloadBy, true);
]]>
</script>
<popup id="contentAreaContextMenu">
<menuseparator id="context-sep-reget-end" insertafter="context-savelink"/>
<menuitem id="download-all-by-catcher" label="Download all with ReGet" oncommand="DownloadAll();" insertafter="context-savelink"/>
<menuitem id="download-by-catcher" label="Download with ReGet" oncommand="DownloadBy();" insertafter="context-savelink"/>
<menuseparator id="context-sep-reget-start" insertafter="context-savelink"/>
</popup>
</overlay>