2006-09-14 05:58:52 +00:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* 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 mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Doron Rosenberg (doronr@naboonline.com)
|
|
|
|
*/
|
|
|
|
|
2006-09-14 05:57:50 +00:00
|
|
|
var gBrowser = null;
|
2006-09-14 05:49:26 +00:00
|
|
|
var appCore = null;
|
|
|
|
|
2006-09-14 05:49:25 +00:00
|
|
|
function onLoadViewSource()
|
|
|
|
{
|
2006-09-14 05:54:56 +00:00
|
|
|
viewSource(window.arguments[0]);
|
2006-09-14 05:58:52 +00:00
|
|
|
window._content.focus();
|
2006-09-14 05:54:56 +00:00
|
|
|
}
|
1999-09-02 04:08:22 +00:00
|
|
|
|
2006-09-14 05:57:50 +00:00
|
|
|
function getBrowser()
|
|
|
|
{
|
|
|
|
if (!gBrowser)
|
|
|
|
gBrowser = document.getElementById("content");
|
|
|
|
return gBrowser;
|
|
|
|
}
|
|
|
|
|
2006-09-14 05:54:56 +00:00
|
|
|
function viewSource(url)
|
|
|
|
{
|
|
|
|
if (!url)
|
2006-09-14 05:55:24 +00:00
|
|
|
return false; // throw Components.results.NS_ERROR_FAILURE;
|
2006-09-14 05:55:55 +00:00
|
|
|
|
2006-09-14 05:54:56 +00:00
|
|
|
try {
|
2006-09-14 05:55:55 +00:00
|
|
|
appCore = Components.classes["@mozilla.org/appshell/component/browser/instance;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIBrowserInstance);
|
2006-09-14 05:55:50 +00:00
|
|
|
|
|
|
|
// Initialize browser instance..
|
|
|
|
appCore.setWebShellWindow(window);
|
2006-09-14 05:55:55 +00:00
|
|
|
} catch(ex) {
|
|
|
|
// Give up.
|
|
|
|
window.close();
|
|
|
|
return false;
|
2006-09-14 05:54:56 +00:00
|
|
|
}
|
2006-09-14 05:49:26 +00:00
|
|
|
|
2006-09-14 05:54:56 +00:00
|
|
|
try {
|
2006-09-14 05:55:55 +00:00
|
|
|
if ("arguments" in window && window.arguments.length >= 2) {
|
|
|
|
if (window.arguments[1].indexOf('charset=') != -1) {
|
|
|
|
var arrayArgComponents = window.arguments[1].split('=');
|
|
|
|
if (arrayArgComponents) {
|
2006-09-14 05:56:36 +00:00
|
|
|
appCore.setDefaultCharacterSet(arrayArgComponents[1]); //XXXjag see bug 67442
|
2006-09-14 05:55:55 +00:00
|
|
|
}
|
2006-09-14 05:54:56 +00:00
|
|
|
}
|
2006-09-14 05:55:55 +00:00
|
|
|
}
|
|
|
|
} catch(ex) {
|
2006-09-14 05:54:56 +00:00
|
|
|
}
|
2006-09-14 05:49:26 +00:00
|
|
|
|
2006-09-14 05:54:56 +00:00
|
|
|
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
2006-09-14 05:56:46 +00:00
|
|
|
var viewSrcUrl = "view-source:" + url;
|
2006-09-14 05:57:50 +00:00
|
|
|
getBrowser().webNavigation.loadURI(viewSrcUrl, loadFlags);
|
2006-09-14 05:58:51 +00:00
|
|
|
window._content.focus();
|
2006-09-14 05:54:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
2006-09-14 05:49:26 +00:00
|
|
|
|
2006-09-14 05:55:55 +00:00
|
|
|
function getMarkupDocumentViewer()
|
2006-09-14 05:51:57 +00:00
|
|
|
{
|
2006-09-14 05:57:50 +00:00
|
|
|
return getBrowser().markupDocumentViewer;
|
2006-09-14 05:51:57 +00:00
|
|
|
}
|
|
|
|
|
2006-09-14 05:58:52 +00:00
|
|
|
// Strips the |view-source:| for editPage()
|
|
|
|
function ViewSourceEditPage()
|
2006-09-14 05:57:50 +00:00
|
|
|
{
|
2006-09-14 05:58:52 +00:00
|
|
|
var url = window._content.location.href;
|
|
|
|
url = url.substring(12,url.length);
|
|
|
|
editPage(url,window, false);
|
2006-09-14 05:57:50 +00:00
|
|
|
}
|