mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Page info implementation, courtesy smorrison@gte.com
This commit is contained in:
parent
ca40fc6994
commit
779e213090
164
xpfe/browser/resources/content/pageInfo.js
Normal file
164
xpfe/browser/resources/content/pageInfo.js
Normal file
@ -0,0 +1,164 @@
|
||||
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): smorrison@gte.com
|
||||
*/
|
||||
|
||||
function onLoadPageInfo() {
|
||||
var page = window.opener.frames[0].document;
|
||||
//var page = window.frames.content.document;
|
||||
var root = document.getElementById("cont");
|
||||
|
||||
makeDocument(page, root);
|
||||
var hasimages = makeImageTree(page, root);
|
||||
makeFormTree(page, root);
|
||||
|
||||
if(hasimages) {
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("name", "view");
|
||||
iframe.setAttribute("src", "about:blank");
|
||||
iframe.setAttribute("flex", "4");
|
||||
root.appendChild(iframe);
|
||||
}
|
||||
}
|
||||
|
||||
function makeDocument(page, root) {
|
||||
var title = page.title;
|
||||
var url = page.URL;
|
||||
var lastmodified;
|
||||
var lastmod = page.lastModified // get string of last modified date
|
||||
var lastmoddate = Date.parse(lastmod) // convert modified string to date
|
||||
if(lastmoddate == 0){ // unknown date (or January 1, 1970 GMT)
|
||||
lastmodified = "Unknown";
|
||||
} else {
|
||||
lastmodified = lastmod;
|
||||
}
|
||||
|
||||
document.getElementById("titletext").appendChild(document.createTextNode(title));
|
||||
document.getElementById("urltext").appendChild(document.createTextNode(url));
|
||||
document.getElementById("lastmodifiedtext").appendChild(document.createTextNode(lastmodified));
|
||||
}
|
||||
|
||||
function makeFormTree(page, root) {
|
||||
var form_list = page.forms;
|
||||
for(i=0; i < form_list.length; i++) {
|
||||
if(i == 0) {
|
||||
var tree = document.createElement("tree");
|
||||
tree.setAttribute("flex", "4");
|
||||
var treehead = tree.appendChild(document.createElement("treehead"));
|
||||
var treerow = treehead.appendChild(document.createElement("treerow"));
|
||||
|
||||
var treecolgroup = tree.appendChild(document.createElement("treecolgroup"));
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "2");
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "1");
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "1");
|
||||
|
||||
var treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Form Action");
|
||||
treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Method");
|
||||
treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Name");
|
||||
|
||||
var treechildren = document.createElement("treechildren");
|
||||
tree.appendChild(treechildren);
|
||||
|
||||
root.appendChild(tree);
|
||||
}
|
||||
var treeitem = treechildren.appendChild(document.createElement("treeitem"));
|
||||
var treerow_elem = treeitem.appendChild(document.createElement("treerow"));
|
||||
|
||||
var treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", form_list[i].action);
|
||||
|
||||
treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", form_list[i].method);
|
||||
|
||||
treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", form_list[i].name);
|
||||
tree.appendChild(treechildren);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function makeImageTree(page, root) {
|
||||
var img_list = page.images;
|
||||
var ret = false;
|
||||
|
||||
for(i=0; i < img_list.length; i++) {
|
||||
if(i == 0) {
|
||||
var tree = document.createElement("tree");
|
||||
tree.setAttribute("flex", "1");
|
||||
|
||||
var treehead = tree.appendChild(document.createElement("treehead"));
|
||||
var treerow = treehead.appendChild(document.createElement("treerow"));
|
||||
|
||||
var treecolgroup = tree.appendChild(document.createElement("treecolgroup"));
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "8");
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "2");
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "2");
|
||||
var treecol = treecolgroup.appendChild(document.createElement("treecol"));
|
||||
treecol.setAttribute("width", "4");
|
||||
|
||||
var treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Image URLs");
|
||||
treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Width");
|
||||
treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Height");
|
||||
treecell = treerow.appendChild(document.createElement("treecell"));
|
||||
treecell.setAttribute("value", "Alt Text");
|
||||
|
||||
var treechildren = document.createElement("treechildren");
|
||||
tree.appendChild(treechildren);
|
||||
|
||||
root.appendChild(tree);
|
||||
}
|
||||
var treeitem = treechildren.appendChild(document.createElement("treeitem"));
|
||||
var treerow_elem = treeitem.appendChild(document.createElement("treerow"));
|
||||
|
||||
var treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", img_list[i].src);
|
||||
treecell_elem.addEventListener("click", openImage, true);
|
||||
|
||||
treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", img_list[i].width);
|
||||
|
||||
treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", img_list[i].height);
|
||||
|
||||
treecell_elem = treerow_elem.appendChild(document.createElement("treecell"));
|
||||
treecell_elem.setAttribute("value", img_list[i].alt);
|
||||
|
||||
tree.appendChild(treechildren);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function openImage(e) { window.frames.view.document.location.href = e.target.getAttribute("value"); }
|
||||
|
||||
|
54
xpfe/browser/resources/content/pageInfo.xul
Normal file
54
xpfe/browser/resources/content/pageInfo.xul
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Simeon Morrison <smorrison@gte.com>
|
||||
Chris McAfee <mcafee@netscape.com>
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://navigator/skin/navigator.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://navigator/locale/viewSource.dtd" >
|
||||
<window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&mainWindow.title;"
|
||||
titlemodifier="&mainWindow.titlemodifier;"
|
||||
titlepreface="&mainWindow.preface;"
|
||||
titlemenuseparator ="&mainWindow.titlemodifierseperator;"
|
||||
windowtype="Browser:view-source"
|
||||
onload="onLoadPageInfo()"
|
||||
align="vertical" width="600" height="480">
|
||||
|
||||
<html:script src="chrome://navigator/content/pageInfo.js"></html:script>
|
||||
|
||||
<box id="cont" orient="vertical" flex="1" style="margin: 1em; min-width: 1px; min-height: 1px;">
|
||||
<html:div class="title">The document has the following structure:</html:div>
|
||||
<box orient="vertical" id="documentinfo">
|
||||
<html:div id="titletext">Title: </html:div>
|
||||
<html:div id="urltext">URL: </html:div>
|
||||
<html:div id="lastmodifiedtext">Last Modified: </html:div>
|
||||
</box>
|
||||
<!-- trees are appended here -->
|
||||
</box>
|
||||
<!-- for testing, use this iframe, and change the page access point in pageInfo.js
|
||||
<html:iframe src="file:///tmp/so.html" name="content" width="0" height="0"/>
|
||||
-->
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user