1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 07:58:00 +01:00

add liberator.dump() to prefix dump() messages with our extension name

This commit is contained in:
Doug Kearns
2008-09-08 04:41:23 +00:00
parent b9f71d1bd9
commit f12f956e41
6 changed files with 25 additions and 19 deletions

View File

@@ -509,7 +509,7 @@ liberator.History = function () //{{{
for (var i = 0; i < rootNode.childCount; i++) for (var i = 0; i < rootNode.childCount; i++)
{ {
var node = rootNode.getChild(i); var node = rootNode.getChild(i);
// dump("History child " + node.itemId + ": " + node.title + " - " + node.type + "\n"); //liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type + "\n");
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
history.push([node.uri, node.title || "[No title]"]); history.push([node.uri, node.title || "[No title]"]);
} }

View File

@@ -427,7 +427,7 @@ liberator.Commands = function () //{{{
} }
var sub = str.substr(i); var sub = str.substr(i);
// dump(i + ": " + sub + " - " + onlyArgumentsRemaining + "\n"); //liberator.dump(i + ": " + sub + " - " + onlyArgumentsRemaining + "\n");
if ((!onlyArgumentsRemaining) && /^--(\s|$)/.test(sub)) if ((!onlyArgumentsRemaining) && /^--(\s|$)/.test(sub))
{ {
onlyArgumentsRemaining = true; onlyArgumentsRemaining = true;

View File

@@ -488,7 +488,7 @@ liberator.Events = function () //{{{
// return true when load successful, or false otherwise // return true when load successful, or false otherwise
function waitForPageLoaded() function waitForPageLoaded()
{ {
dump("start waiting in loaded state: " + liberator.buffer.loaded + "\n"); liberator.dump("start waiting in loaded state: " + liberator.buffer.loaded + "\n");
var mainThread = Components.classes["@mozilla.org/thread-manager;1"] var mainThread = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager).mainThread; .getService(Components.interfaces.nsIThreadManager).mainThread;
while (mainThread.hasPendingEvents()) // clear queue while (mainThread.hasPendingEvents()) // clear queue
@@ -503,7 +503,7 @@ liberator.Events = function () //{{{
{ {
mainThread.processNextEvent(true); mainThread.processNextEvent(true);
if ((now - then) % 1000 < 10) if ((now - then) % 1000 < 10)
dump("waited: " + (now - then) + " ms\n"); liberator.dump("waited: " + (now - then) + " ms\n");
if (liberator.buffer.loaded > 0) if (liberator.buffer.loaded > 0)
{ {
@@ -519,7 +519,7 @@ liberator.Events = function () //{{{
var ret = (liberator.buffer.loaded == 1); var ret = (liberator.buffer.loaded == 1);
if (!ret) if (!ret)
liberator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped."); liberator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped.");
dump("done waiting: " + ret + "\n"); liberator.dump("done waiting: " + ret + "\n");
// sometimes the input widget had focus when replaying a macro // sometimes the input widget had focus when replaying a macro
// maybe this call should be moved somewhere else? // maybe this call should be moved somewhere else?
@@ -661,7 +661,7 @@ liberator.Events = function () //{{{
destroy: function () destroy: function ()
{ {
// removeEventListeners() to avoid mem leaks // removeEventListeners() to avoid mem leaks
window.dump("TODO: remove all eventlisteners\n"); liberator.dump("TODO: remove all eventlisteners\n");
if (typeof(getBrowser) != "undefined") if (typeof(getBrowser) != "undefined")
getBrowser().removeProgressListener(this.progressListener); getBrowser().removeProgressListener(this.progressListener);
@@ -957,9 +957,9 @@ liberator.Events = function () //{{{
if (elem && elem.readOnly) if (elem && elem.readOnly)
return; return;
// liberator.log("onFocusChange: " + elem); //liberator.log("onFocusChange: " + elem);
// dump("=+++++++++=\n" + liberator.util.objectToString(event.target) + "\n") //liberator.dump("=+++++++++=\n" + liberator.util.objectToString(event.target) + "\n")
// dump (elem + ": " + win + "\n");//" - target: " + event.target + " - origtarget: " + event.originalTarget + " - expltarget: " + event.explicitOriginalTarget + "\n"); //liberator.dump (elem + ": " + win + "\n");//" - target: " + event.target + " - origtarget: " + event.originalTarget + " - expltarget: " + event.explicitOriginalTarget + "\n");
if (elem && ( if (elem && (
(elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) || (elem instanceof HTMLInputElement && (elem.type.toLowerCase() == "text" || elem.type.toLowerCase() == "password")) ||
@@ -993,7 +993,7 @@ liberator.Events = function () //{{{
{ {
if (liberator.config.isComposeWindow) if (liberator.config.isComposeWindow)
{ {
dump("Compose editor got focus\n"); liberator.dump("Compose editor got focus\n");
liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA); liberator.modes.set(liberator.modes.INSERT, liberator.modes.TEXTAREA);
} }
else if (liberator.mode != liberator.modes.MESSAGE) else if (liberator.mode != liberator.modes.MESSAGE)
@@ -1011,7 +1011,7 @@ liberator.Events = function () //{{{
// this.wantsModeReset = true; // this.wantsModeReset = true;
// setTimeout(function () // setTimeout(function ()
// { // {
// dump("cur: " + liberator.mode + "\n"); // liberator.dump("cur: " + liberator.mode + "\n");
// if (liberator.events.wantsModeReset) // if (liberator.events.wantsModeReset)
// { // {
// liberator.events.wantsModeReset = false; // liberator.events.wantsModeReset = false;
@@ -1115,8 +1115,8 @@ liberator.Events = function () //{{{
if (!key) if (!key)
return true; return true;
// liberator.log(key + " in mode: " + liberator.mode); //liberator.log(key + " in mode: " + liberator.mode);
// dump(key + " in mode: " + liberator.mode + "\n"); //liberator.dump(key + " in mode: " + liberator.mode + "\n");
if (liberator.modes.isRecording) if (liberator.modes.isRecording)
{ {

View File

@@ -564,7 +564,7 @@ const liberator = (function () //{{{
triggerCallback: function (type, mode, data) triggerCallback: function (type, mode, data)
{ {
//dump("type: " + type + " mode: " + mode + "data: " + data + "\n"); //liberator.dump("type: " + type + " mode: " + mode + "data: " + data + "\n");
for (let i = 0; i < callbacks.length; i++) for (let i = 0; i < callbacks.length; i++)
{ {
var [thistype, thismode, thisfunc] = callbacks[i]; var [thistype, thismode, thisfunc] = callbacks[i];
@@ -602,6 +602,12 @@ const liberator = (function () //{{{
return false; // so you can do: if (...) return liberator.beep(); return false; // so you can do: if (...) return liberator.beep();
}, },
// NOTE: "browser.dom.window.dump.enabled" preference needs to be set
dump: function (message)
{
dump(liberator.config.name.toLowerCase() + ": " + message);
},
// with (liberator) means, liberator is the default namespace "inside" eval // with (liberator) means, liberator is the default namespace "inside" eval
eval: function (str) eval: function (str)
{ {
@@ -782,7 +788,7 @@ const liberator = (function () //{{{
if (elem) if (elem)
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
else else
dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' ); liberator.dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' );
}, 500); }, 500);
} }
@@ -1069,7 +1075,7 @@ const liberator = (function () //{{{
if (liberator.has("quickmarks")) if (liberator.has("quickmarks"))
liberator.quickmarks.destroy(); liberator.quickmarks.destroy();
window.dump("All liberator modules destroyed\n"); liberator.dump("All liberator modules destroyed\n");
liberator.autocommands.trigger("Quit", ""); liberator.autocommands.trigger("Quit", "");
}, },

View File

@@ -1007,7 +1007,7 @@ liberator.Mail = function () //{{{
} }
catch (e) catch (e)
{ {
dump("ERROR: " + folder.prettyName + " failed to getMessages\n"); liberator.dump("ERROR: " + folder.prettyName + " failed to getMessages\n");
continue; continue;
} }

View File

@@ -98,8 +98,8 @@ liberator.modes = (function () //{{{
function handleModeChange(oldMode, newMode) function handleModeChange(oldMode, newMode)
{ {
// TODO: fix v.log() to work with verbosity level // TODO: fix v.log() to work with verbosity level
// liberator.log("switching from mode " + oldMode + " to mode " + newMode, 7); //liberator.log("switching from mode " + oldMode + " to mode " + newMode, 7);
// dump("switching from mode " + oldMode + " to mode " + newMode + "\n"); //liberator.dump("switching from mode " + oldMode + " to mode " + newMode + "\n");
switch (oldMode) switch (oldMode)
{ {