diff options
author | Andrew Dolgov <[email protected]> | 2006-05-23 07:03:08 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2006-05-23 07:03:08 +0100 |
commit | ac378ad4ec0b870931b16daebcf0c1f22f9fa303 (patch) | |
tree | 92c4b6efedaa0f9d2b421d71be0935788e3ba504 /functions.js | |
parent | 131b01b336850c574d3b518927a4910065fc4cb6 (diff) |
getMainContext() and related JS-stuff
Diffstat (limited to 'functions.js')
-rw-r--r-- | functions.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/functions.js b/functions.js index 5940174d3..384f34827 100644 --- a/functions.js +++ b/functions.js @@ -413,8 +413,13 @@ function setActiveFeedId(id) { var xmlhttp_rpc = Ajax.getTransport(); -function parse_counters(reply, f_document, title_obj, scheduled_call) { +function parse_counters(reply, scheduled_call) { try { + var f_document = getMainContext().frames["feeds-frame"].document; + var title_obj = getMainContext(); + + debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj); + for (var l = 0; l < reply.childNodes.length; l++) { if (!reply.childNodes[l] || typeof(reply.childNodes[l].getAttribute) == "undefined") { @@ -498,9 +503,6 @@ function parse_counters(reply, f_document, title_obj, scheduled_call) { } } -// this one is called from feedlist context -// thus title_obj passed to parse_counters is parent (e.g. main ttrss window) - function all_counters_callback() { if (xmlhttp_rpc.readyState == 4) { try { @@ -515,9 +517,9 @@ function all_counters_callback() { } var reply = xmlhttp_rpc.responseXML.firstChild; - var f_document = parent.frames["feeds-frame"].document; +// var f_document = parent.frames["feeds-frame"].document; - parse_counters(reply, f_document, parent); + parse_counters(reply); } catch (e) { exception_error("all_counters_callback", e); @@ -1054,4 +1056,28 @@ function filterCR(e) return true; } +function getMainContext() { + if (parent.window != window) { + return parent.window; + } else { + return this.window; + } +} + +function debug(msg) { + var ctx = getMainContext(); + + var c = ctx.document.getElementById('debug_output'); + if (c && c.style.display == "block") { + while (c.lastChild != 'undefined' && c.childNodes.length > 20) { + c.removeChild(c.lastChild); + } + + var d = new Date(); + var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + + ":" + leading_zero(d.getSeconds()); + c.innerHTML = "<li>[" + ts + "] " + msg + "</li>" + c.innerHTML; + } +} + |