Use Zotero.debug() instead of dump() in WPD
This commit is contained in:
parent
ff692392c9
commit
39c86a791e
|
@ -95,11 +95,11 @@ function wpdWindowLoaded()
|
||||||
try {
|
try {
|
||||||
// this will be called multiple times if the page contains more than one document (frames, flash,...)
|
// this will be called multiple times if the page contains more than one document (frames, flash,...)
|
||||||
//var browser=this.document.getElementById("content");
|
//var browser=this.document.getElementById("content");
|
||||||
dump("[wpdWindowLoaded] ... \n");
|
Zotero.debug("[wpdWindowLoaded] ... ");
|
||||||
var browser = this.top.getBrowser();
|
var browser = this.top.getBrowser();
|
||||||
// each time we have to check if the page is fully loaded...
|
// each time we have to check if the page is fully loaded...
|
||||||
if (!(browser.webProgress.isLoadingDocument || browser.contentDocument.location == gExceptLocation)) {
|
if (!(browser.webProgress.isLoadingDocument || browser.contentDocument.location == gExceptLocation)) {
|
||||||
dump("[wpdWindowLoaded] window finally loaded\n");
|
Zotero.debug("[wpdWindowLoaded] window finally loaded");
|
||||||
gBrowserWindow.clearTimeout(gTimeOutID);
|
gBrowserWindow.clearTimeout(gTimeOutID);
|
||||||
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
|
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
|
||||||
//dump("[wpdWindowLoaded] calling "+gCallback+"\n");
|
//dump("[wpdWindowLoaded] calling "+gCallback+"\n");
|
||||||
|
@ -112,13 +112,13 @@ function wpdWindowLoaded()
|
||||||
gBrowserWindow.setTimeout(gCallback, w);
|
gBrowserWindow.setTimeout(gCallback, w);
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
dump("[wpdWindowLoaded] EXCEPTION: "+ex+"\n");
|
Zotero.debug("[wpdWindowLoaded] EXCEPTION: "+ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wpdTimeOut()
|
function wpdTimeOut()
|
||||||
{
|
{
|
||||||
dump("[wpdTimeOut] timeout triggered!\n");
|
Zotero.debug("[wpdTimeOut] timeout triggered!");
|
||||||
gTimedOut=true;
|
gTimedOut=true;
|
||||||
gBrowserWindow.clearTimeout(gTimeOutID);
|
gBrowserWindow.clearTimeout(gTimeOutID);
|
||||||
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
|
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
|
||||||
|
@ -134,7 +134,7 @@ function wpdLoadURL(aURI,aCallback)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
gTimedOut=false;
|
gTimedOut=false;
|
||||||
dump("\n[wpdLoadURL] aURI: "+aURI+"\n");
|
Zotero.debug("[wpdLoadURL] aURI: "+aURI);
|
||||||
if (aURI=="") return;
|
if (aURI=="") return;
|
||||||
gBrowserWindow = wpdGetTopBrowserWindow();
|
gBrowserWindow = wpdGetTopBrowserWindow();
|
||||||
gBrowserWindow.loadURI(aURI);
|
gBrowserWindow.loadURI(aURI);
|
||||||
|
@ -143,7 +143,7 @@ function wpdLoadURL(aURI,aCallback)
|
||||||
gTimeOutID=gBrowserWindow.setTimeout(wpdTimeOut, 60000);
|
gTimeOutID=gBrowserWindow.setTimeout(wpdTimeOut, 60000);
|
||||||
gBrowserWindow.addEventListener("load",wpdWindowLoaded, true);
|
gBrowserWindow.addEventListener("load",wpdWindowLoaded, true);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
dump("[wpdLoadURL] EXCEPTION: "+ex+"\n");
|
Zotero.debug("[wpdLoadURL] EXCEPTION: "+ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ var wpdCommon = {
|
||||||
var gUnicodeConverter = Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].getService(Components.interfaces.nsIScriptableUnicodeConverter);
|
var gUnicodeConverter = Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].getService(Components.interfaces.nsIScriptableUnicodeConverter);
|
||||||
gUnicodeConverter.charset = charset;
|
gUnicodeConverter.charset = charset;
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
dump ("gUnicodeConverter EXCEPTION:"+ex+"\n");
|
Zotero.debug ("gUnicodeConverter EXCEPTION:"+ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ var wpdCommon = {
|
||||||
try {
|
try {
|
||||||
var gEntityConverter = Components.classes["@mozilla.org/intl/entityconverter;1"].createInstance(Components.interfaces.nsIEntityConverter);
|
var gEntityConverter = Components.classes["@mozilla.org/intl/entityconverter;1"].createInstance(Components.interfaces.nsIEntityConverter);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
dump ("gEntityConverter EXCEPTION:"+ex+"\n");
|
Zotero.debug ("gEntityConverter EXCEPTION:"+ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ var wpdCommon = {
|
||||||
// add a line to the error list (displays a maximum of 15 errors)
|
// add a line to the error list (displays a maximum of 15 errors)
|
||||||
addError : function(aError)
|
addError : function(aError)
|
||||||
{
|
{
|
||||||
dump('ERROR: '+aError+"\n");
|
Zotero.debug('ERROR: '+aError);
|
||||||
if (this.errCount<WPD_MAXUIERRORCOUNT) {
|
if (this.errCount<WPD_MAXUIERRORCOUNT) {
|
||||||
if (this.errList.indexOf(aError)>-1) return; // is the same
|
if (this.errList.indexOf(aError)>-1) return; // is the same
|
||||||
this.errList = this.errList+aError+"\n";
|
this.errList = this.errList+aError+"\n";
|
||||||
|
@ -337,7 +337,7 @@ var wpdCommon = {
|
||||||
},
|
},
|
||||||
|
|
||||||
saveWebPage : function(aDestFile) {
|
saveWebPage : function(aDestFile) {
|
||||||
dump("[saveWebPage] "+aDestFile+"\n");
|
Zotero.debug("[saveWebPage] "+aDestFile);
|
||||||
var nsIWBP = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
|
var nsIWBP = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Components.interfaces.nsIWebBrowserPersist);
|
||||||
var doc = window.content.document;
|
var doc = window.content.document;
|
||||||
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||||
|
|
|
@ -147,7 +147,7 @@ var wpdDOMSaver = {
|
||||||
// initialize the properties (set document, URL, Directory, ...)
|
// initialize the properties (set document, URL, Directory, ...)
|
||||||
init : function(fileName, document)
|
init : function(fileName, document)
|
||||||
{
|
{
|
||||||
dump("[wpdDOMSaver.init] ...\n");
|
Zotero.debug("[wpdDOMSaver.init] ...");
|
||||||
|
|
||||||
this.name = "";
|
this.name = "";
|
||||||
this.document = null;
|
this.document = null;
|
||||||
|
@ -653,7 +653,7 @@ var wpdDOMSaver = {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
var msg = "Unable to access cssRules property of " + aCSS.href
|
var msg = "Unable to access cssRules property of " + aCSS.href
|
||||||
+ " in wpdDOMSaver.processCSSRecursively()";
|
+ " in wpdDOMSaver.processCSSRecursively()";
|
||||||
dump("WebPageDump: "+msg+"\n\n", 2);
|
Zotero.debug("WebPageDump: "+msg, 2);
|
||||||
Components.utils.reportError(msg);
|
Components.utils.reportError(msg);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -928,7 +928,7 @@ var wpdDOMSaver = {
|
||||||
// ("aFileName" is the filename without(!) extension)
|
// ("aFileName" is the filename without(!) extension)
|
||||||
saveDocumentFile : function(aDocument,aFileName)
|
saveDocumentFile : function(aDocument,aFileName)
|
||||||
{
|
{
|
||||||
dump("[wpdDOMSaver.saveDocumentFile]: "+aFileName+"\n");
|
Zotero.debug("[wpdDOMSaver.saveDocumentFile]: "+aFileName);
|
||||||
|
|
||||||
return this.download(this.currentURL,true)
|
return this.download(this.currentURL,true)
|
||||||
/* Wrapper file disabled by Dan S. for Zotero
|
/* Wrapper file disabled by Dan S. for Zotero
|
||||||
|
@ -973,7 +973,7 @@ var wpdDOMSaver = {
|
||||||
} else {
|
} else {
|
||||||
CSSText = wpdCommon.ConvertFromUnicode16(CSSText,this.curCharacterSet);
|
CSSText = wpdCommon.ConvertFromUnicode16(CSSText,this.curCharacterSet);
|
||||||
}
|
}
|
||||||
dump("[wpdDOMSaver.saveDocumentCSS]: "+this.currentDir+aFileName+".css\n");
|
Zotero.debug("[wpdDOMSaver.saveDocumentCSS]: "+this.currentDir+aFileName+".css");
|
||||||
// write css file
|
// write css file
|
||||||
var CSSFile = this.currentDir + aFileName + ".css";
|
var CSSFile = this.currentDir + aFileName + ".css";
|
||||||
if (!wpdCommon.writeFile(CSSText, CSSFile))
|
if (!wpdCommon.writeFile(CSSText, CSSFile))
|
||||||
|
@ -990,7 +990,7 @@ var wpdDOMSaver = {
|
||||||
// (".html" will be added)
|
// (".html" will be added)
|
||||||
saveDocumentHTML: function(aDocument,aFileName)
|
saveDocumentHTML: function(aDocument,aFileName)
|
||||||
{
|
{
|
||||||
dump("[wpdDOMSaver.saveDocumentHTML]: "+this.currentDir+aFileName+".html\n");
|
Zotero.debug("[wpdDOMSaver.saveDocumentHTML]: "+this.currentDir+aFileName+".html");
|
||||||
this.curDocument = aDocument;
|
this.curDocument = aDocument;
|
||||||
this.curCharacterSet = aDocument.characterSet;
|
this.curCharacterSet = aDocument.characterSet;
|
||||||
var charset=this.curCharacterSet;
|
var charset=this.curCharacterSet;
|
||||||
|
|
|
@ -567,17 +567,8 @@ Zotero.Attachments = new function(){
|
||||||
if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
|
if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
|
||||||
var sync = true;
|
var sync = true;
|
||||||
|
|
||||||
// Load WebPageDump code
|
Zotero.WebPageDump.wpdDOMSaver.init(file.path, document);
|
||||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
Zotero.WebPageDump.wpdDOMSaver.saveHTMLDocument();
|
||||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
|
||||||
.loadSubScript("chrome://zotero/content/webpagedump/common.js");
|
|
||||||
|
|
||||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
|
||||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
|
||||||
.loadSubScript("chrome://zotero/content/webpagedump/domsaver.js");
|
|
||||||
|
|
||||||
wpdDOMSaver.init(file.path, document);
|
|
||||||
wpdDOMSaver.saveHTMLDocument();
|
|
||||||
|
|
||||||
attachmentItem.attachmentPath = this.getPath(
|
attachmentItem.attachmentPath = this.getPath(
|
||||||
file, Zotero.Attachments.LINK_MODE_IMPORTED_URL
|
file, Zotero.Attachments.LINK_MODE_IMPORTED_URL
|
||||||
|
|
|
@ -206,6 +206,15 @@ function makeZoteroContext(isConnector) {
|
||||||
.getService(Ci.mozIJSSubScriptLoader)
|
.getService(Ci.mozIJSSubScriptLoader)
|
||||||
.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
|
.loadSubScript("chrome://zotero/content/xpcom/citeproc.js", zContext.Zotero.CiteProc);
|
||||||
|
|
||||||
|
// Load WPD into Zotero.WebPageDump namespace
|
||||||
|
zContext.Zotero.WebPageDump = {"Zotero":zContext.Zotero};
|
||||||
|
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||||
|
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||||
|
.loadSubScript("chrome://zotero/content/webpagedump/common.js", zContext.Zotero.WebPageDump);
|
||||||
|
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||||
|
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||||
|
.loadSubScript("chrome://zotero/content/webpagedump/domsaver.js", zContext.Zotero.WebPageDump);
|
||||||
|
|
||||||
// Load remaining xpcomFiles
|
// Load remaining xpcomFiles
|
||||||
for (var i=1; i<xpcomFilesAll.length; i++) {
|
for (var i=1; i<xpcomFilesAll.length; i++) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user