diff options
author | Andrew Dolgov <[email protected]> | 2005-09-08 13:10:07 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2005-09-08 13:10:07 +0100 |
commit | 090e250b6905ecbc078cdc2f485f343a1d3a7bfc (patch) | |
tree | 709d6ac23c67969cde10ed94027c91e73509c648 /functions.js | |
parent | a82065a18b430f808799634cf1132c9921a5f18b (diff) |
automagically updating labels with cute XML RPC
Diffstat (limited to 'functions.js')
-rw-r--r-- | functions.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/functions.js b/functions.js index 4e758a7d0..0db4ea307 100644 --- a/functions.js +++ b/functions.js @@ -278,3 +278,57 @@ function getActiveFeedId() { function setActiveFeedId(id) { return setCookie("ttrss_vf_actfeed", id); } + +var xmlhttp_rpc = false; + +/*@cc_on @*/ +/*@if (@_jscript_version >= 5) +// JScript gives us Conditional compilation, we can cope with old IE versions. +// and security blocked creation of the objects. +try { + xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP"); +} catch (e) { + try { + xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp_rpc = false; + } +} +@end @*/ + +if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { + xmlhttp_rpc = new XMLHttpRequest(); +} + +function label_counters_callback() { + if (xmlhttp_rpc.readyState == 4) { + var reply = xmlhttp_rpc.responseXML.firstChild; + + var f_document = parent.frames["feeds-frame"].document; + + for (var l = 0; l < reply.childNodes.length; l++) { + var id = reply.childNodes[l].getAttribute("id"); + var ctr = reply.childNodes[l].getAttribute("counter"); + + var feedctr = f_document.getElementById("FEEDCTR-" + id); + var feedu = f_document.getElementById("FEEDU-" + id); + + feedu.innerHTML = ctr; + + if (ctr > 0) { + feedctr.className = "odd"; + } else { + feedctr.className = "invisible"; + } + } + } +} + +function update_label_counters() { + if (xmlhttp_ready(xmlhttp_rpc)) { + var query = "backend.php?op=rpc&subop=getLabelCounters"; + xmlhttp_rpc.open("GET", query, true); + xmlhttp_rpc.onreadystatechange=label_counters_callback; + xmlhttp_rpc.send(null); + } +} |