Use Zotero.debug() instead of dump() in WPD

This commit is contained in:
Simon Kornblith 2012-02-05 18:46:49 -05:00
parent ff692392c9
commit 39c86a791e
4 changed files with 26 additions and 26 deletions

View file

@ -95,11 +95,11 @@ function wpdWindowLoaded()
try {
// this will be called multiple times if the page contains more than one document (frames, flash,...)
//var browser=this.document.getElementById("content");
dump("[wpdWindowLoaded] ... \n");
Zotero.debug("[wpdWindowLoaded] ... ");
var browser = this.top.getBrowser();
// each time we have to check if the page is fully loaded...
if (!(browser.webProgress.isLoadingDocument || browser.contentDocument.location == gExceptLocation)) {
dump("[wpdWindowLoaded] window finally loaded\n");
Zotero.debug("[wpdWindowLoaded] window finally loaded");
gBrowserWindow.clearTimeout(gTimeOutID);
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
//dump("[wpdWindowLoaded] calling "+gCallback+"\n");
@ -112,13 +112,13 @@ function wpdWindowLoaded()
gBrowserWindow.setTimeout(gCallback, w);
}
} catch (ex) {
dump("[wpdWindowLoaded] EXCEPTION: "+ex+"\n");
Zotero.debug("[wpdWindowLoaded] EXCEPTION: "+ex);
}
}
function wpdTimeOut()
{
dump("[wpdTimeOut] timeout triggered!\n");
Zotero.debug("[wpdTimeOut] timeout triggered!");
gTimedOut=true;
gBrowserWindow.clearTimeout(gTimeOutID);
gBrowserWindow.removeEventListener("load",wpdWindowLoaded,true);
@ -134,7 +134,7 @@ function wpdLoadURL(aURI,aCallback)
{
try {
gTimedOut=false;
dump("\n[wpdLoadURL] aURI: "+aURI+"\n");
Zotero.debug("[wpdLoadURL] aURI: "+aURI);
if (aURI=="") return;
gBrowserWindow = wpdGetTopBrowserWindow();
gBrowserWindow.loadURI(aURI);
@ -143,7 +143,7 @@ function wpdLoadURL(aURI,aCallback)
gTimeOutID=gBrowserWindow.setTimeout(wpdTimeOut, 60000);
gBrowserWindow.addEventListener("load",wpdWindowLoaded, true);
} 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);
gUnicodeConverter.charset = charset;
} catch(ex) {
dump ("gUnicodeConverter EXCEPTION:"+ex+"\n");
Zotero.debug ("gUnicodeConverter EXCEPTION:"+ex);
}
}
@ -270,7 +270,7 @@ var wpdCommon = {
try {
var gEntityConverter = Components.classes["@mozilla.org/intl/entityconverter;1"].createInstance(Components.interfaces.nsIEntityConverter);
} 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)
addError : function(aError)
{
dump('ERROR: '+aError+"\n");
Zotero.debug('ERROR: '+aError);
if (this.errCount<WPD_MAXUIERRORCOUNT) {
if (this.errList.indexOf(aError)>-1) return; // is the same
this.errList = this.errList+aError+"\n";
@ -337,7 +337,7 @@ var wpdCommon = {
},
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 doc = window.content.document;
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);

View file

@ -147,7 +147,7 @@ var wpdDOMSaver = {
// initialize the properties (set document, URL, Directory, ...)
init : function(fileName, document)
{
dump("[wpdDOMSaver.init] ...\n");
Zotero.debug("[wpdDOMSaver.init] ...");
this.name = "";
this.document = null;
@ -653,7 +653,7 @@ var wpdDOMSaver = {
catch (e) {
var msg = "Unable to access cssRules property of " + aCSS.href
+ " in wpdDOMSaver.processCSSRecursively()";
dump("WebPageDump: "+msg+"\n\n", 2);
Zotero.debug("WebPageDump: "+msg, 2);
Components.utils.reportError(msg);
return "";
}
@ -928,7 +928,7 @@ var wpdDOMSaver = {
// ("aFileName" is the filename without(!) extension)
saveDocumentFile : function(aDocument,aFileName)
{
dump("[wpdDOMSaver.saveDocumentFile]: "+aFileName+"\n");
Zotero.debug("[wpdDOMSaver.saveDocumentFile]: "+aFileName);
return this.download(this.currentURL,true)
/* Wrapper file disabled by Dan S. for Zotero
@ -973,7 +973,7 @@ var wpdDOMSaver = {
} else {
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
var CSSFile = this.currentDir + aFileName + ".css";
if (!wpdCommon.writeFile(CSSText, CSSFile))
@ -990,7 +990,7 @@ var wpdDOMSaver = {
// (".html" will be added)
saveDocumentHTML: function(aDocument,aFileName)
{
dump("[wpdDOMSaver.saveDocumentHTML]: "+this.currentDir+aFileName+".html\n");
Zotero.debug("[wpdDOMSaver.saveDocumentHTML]: "+this.currentDir+aFileName+".html");
this.curDocument = aDocument;
this.curCharacterSet = aDocument.characterSet;
var charset=this.curCharacterSet;

View file

@ -567,17 +567,8 @@ Zotero.Attachments = new function(){
if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
var sync = true;
// Load WebPageDump code
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.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();
Zotero.WebPageDump.wpdDOMSaver.init(file.path, document);
Zotero.WebPageDump.wpdDOMSaver.saveHTMLDocument();
attachmentItem.attachmentPath = this.getPath(
file, Zotero.Attachments.LINK_MODE_IMPORTED_URL

View file

@ -206,6 +206,15 @@ function makeZoteroContext(isConnector) {
.getService(Ci.mozIJSSubScriptLoader)
.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
for (var i=1; i<xpcomFilesAll.length; i++) {
try {