2006-09-14 09:49:26 +04:00
|
|
|
|
|
|
|
var appCore = null;
|
|
|
|
|
|
|
|
|
2006-09-14 09:49:25 +04:00
|
|
|
function onLoadViewSource()
|
|
|
|
{
|
2006-09-14 09:54:56 +04:00
|
|
|
viewSource(window.arguments[0]);
|
|
|
|
}
|
1999-09-02 08:08:22 +04:00
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
function viewSource(url)
|
|
|
|
{
|
|
|
|
if (!url)
|
|
|
|
return; // throw Components.results.NS_ERROR_FAILURE;
|
|
|
|
try {
|
|
|
|
createBrowserInstance();
|
|
|
|
if (appCore == null) {
|
|
|
|
// Give up.
|
|
|
|
dump("Giving up...\n");
|
|
|
|
window.close();
|
|
|
|
return false;
|
2006-09-14 09:49:26 +04:00
|
|
|
}
|
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
// Initialize browser instance..
|
|
|
|
appCore.setWebShellWindow(window);
|
|
|
|
if ( window._content ) {
|
|
|
|
dump("Setting content window\n");
|
|
|
|
appCore.setContentWindow( window._content );
|
2006-09-14 09:49:26 +04:00
|
|
|
}
|
2006-09-14 09:54:56 +04:00
|
|
|
}
|
2006-09-14 09:49:26 +04:00
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
catch(ex) {
|
|
|
|
dump("Failed to create and initialiaze the AppCore...\n");
|
|
|
|
}
|
2006-09-14 09:49:26 +04:00
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
var docShellElement = document.getElementById("content-frame");
|
|
|
|
var docShell = docShellElement.docShell;
|
|
|
|
docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
|
|
|
|
var webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (window.arguments && window.arguments[1]) {
|
|
|
|
if (window.arguments[1].indexOf('charset=') != -1) {
|
|
|
|
var arrayArgComponents = window.arguments[1].split('=');
|
|
|
|
if (arrayArgComponents) {
|
|
|
|
dump("*** SetDocumentCharset(" + arrayArgComponents[1] + ")\n");
|
|
|
|
appCore.SetDocumentCharset(arrayArgComponents[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-09-14 09:49:26 +04:00
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
catch(ex) {
|
|
|
|
dump("*** Failed to SetDocumentCharset...\n");
|
|
|
|
}
|
2006-09-14 09:49:26 +04:00
|
|
|
|
2006-09-14 09:54:56 +04:00
|
|
|
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
|
|
|
webNav.loadURI(url, loadFlags);
|
|
|
|
return true;
|
|
|
|
}
|
2006-09-14 09:49:26 +04:00
|
|
|
|
|
|
|
function createBrowserInstance()
|
|
|
|
{
|
2006-09-14 09:51:57 +04:00
|
|
|
appCore = Components
|
2006-09-14 09:53:31 +04:00
|
|
|
.classes[ "@mozilla.org/appshell/component/browser/instance;1" ]
|
2006-09-14 09:51:57 +04:00
|
|
|
.createInstance( Components.interfaces.nsIBrowserInstance );
|
|
|
|
if ( !appCore ) {
|
|
|
|
dump("Error creating browser instance\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserClose()
|
|
|
|
{
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function BrowserFind()
|
|
|
|
{
|
|
|
|
if (appCore) {
|
|
|
|
appCore.find();
|
|
|
|
} else {
|
|
|
|
dump("BrowserAppCore has not been created!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function BrowserFindAgain()
|
|
|
|
{
|
|
|
|
if (appCore) {
|
|
|
|
appCore.findNext();
|
|
|
|
} else {
|
|
|
|
dump("BrowserAppCore has not been created!\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|