]> git.wh0rd.org - tt-rss.git/blame - view.js
automagically updating labels with cute XML RPC
[tt-rss.git] / view.js
CommitLineData
090e250b
AD
1var xmlhttp_rpc = false;
2
3/*@cc_on @*/
4/*@if (@_jscript_version >= 5)
5// JScript gives us Conditional compilation, we can cope with old IE versions.
6// and security blocked creation of the objects.
7try {
8 xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
9} catch (e) {
10 try {
11 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
12 } catch (E) {
13 xmlhttp_rpc = false;
14 }
15}
16@end @*/
17
18if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
19 xmlhttp_rpc = new XMLHttpRequest();
20}
21
22function label_counters_callback() {
23 if (xmlhttp_rpc.readyState == 4) {
24 var reply = xmlhttp_rpc.responseXML.firstChild;
25
26 var f_document = parent.frames["feeds-frame"].document;
27
28 for (var l = 0; l < reply.childNodes.length; l++) {
29 var id = reply.childNodes[l].getAttribute("id");
30 var ctr = reply.childNodes[l].getAttribute("counter");
31
32 var feedctr = f_document.getElementById("FEEDCTR-" + id);
33 var feedu = f_document.getElementById("FEEDU-" + id);
34
35 feedu.innerHTML = ctr;
36
37 if (ctr > 0) {
38 feedctr.className = "odd";
39 } else {
40 feedctr.className = "invisible";
41 }
42 }
43 }
44}
45
46function update_label_counters() {
47 if (xmlhttp_ready(xmlhttp_rpc)) {
48 var query = "backend.php?op=rpc&subop=getLabelCounters";
49 xmlhttp_rpc.open("GET", query, true);
50 xmlhttp_rpc.onreadystatechange=label_counters_callback;
51 xmlhttp_rpc.send(null);
52 }
53}