]> git.wh0rd.org - tt-rss.git/blame_incremental - tt-rss.js
prefs RPC optimizations
[tt-rss.git] / tt-rss.js
... / ...
CommitLineData
1/*
2 This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com>
3 Licensed under GPL v.2 or (at your preference) any later version.
4*/
5
6var xmlhttp = false;
7
8/*@cc_on @*/
9/*@if (@_jscript_version >= 5)
10// JScript gives us Conditional compilation, we can cope with old IE versions.
11// and security blocked creation of the objects.
12try {
13 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
14} catch (e) {
15 try {
16 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
17 } catch (E) {
18 xmlhttp = false;
19 }
20}
21@end @*/
22
23if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
24 xmlhttp = new XMLHttpRequest();
25}
26
27function feedlist_callback() {
28 var container = document.getElementById('feeds');
29 if (xmlhttp.readyState == 4) {
30 container.innerHTML=xmlhttp.responseText;
31 }
32}
33
34function viewfeed_callback() {
35 var container = document.getElementById('headlines');
36 if (xmlhttp.readyState == 4) {
37 container.innerHTML = xmlhttp.responseText;
38
39 var factive = document.getElementById("FACTIVE");
40 var funread = document.getElementById("FUNREAD");
41 var ftotal = document.getElementById("FTOTAL");
42
43 if (ftotal && factive && funread) {
44 var feed_id = factive.innerHTML;
45
46 var feedr = document.getElementById("FEEDR-" + feed_id);
47 var feedt = document.getElementById("FEEDT-" + feed_id);
48 var feedu = document.getElementById("FEEDU-" + feed_id);
49
50 feedt.innerHTML = ftotal.innerHTML;
51 feedu.innerHTML = funread.innerHTML;
52
53 if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
54 feedr.className = feedr.className + "Unread";
55 } else if (feedu.innerHTML <= 0) {
56 feedr.className = feedr.className.replace("Unread", "");
57 }
58
59 }
60 }
61}
62
63function view_callback() {
64 var container = document.getElementById('content');
65 if (xmlhttp.readyState == 4) {
66 container.innerHTML=xmlhttp.responseText;
67 }
68}
69
70
71function update_feed_list(called_from_timer, fetch) {
72
73 if (called_from_timer != true) {
74 document.getElementById("feeds").innerHTML = "Loading feeds, please wait...";
75 }
76
77 var query_str = "backend.php?op=feeds";
78
79 if (fetch) query_str = query_str + "&fetch=yes";
80
81 xmlhttp.open("GET", query_str, true);
82 xmlhttp.onreadystatechange=feedlist_callback;
83 xmlhttp.send(null);
84
85
86}
87
88function viewfeed(feed, skip, ext) {
89
90// notify("view-feed: " + feed);
91
92 document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
93 document.getElementById('content').innerHTML='&nbsp;';
94
95 xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
96 "&skip=" + param_escape(skip) + "&ext=" + param_escape(ext) , true);
97 xmlhttp.onreadystatechange=viewfeed_callback;
98 xmlhttp.send(null);
99
100}
101
102function view(id,feed_id) {
103
104 var crow = document.getElementById("RROW-" + id);
105
106 if (crow.className.match("Unread")) {
107 var umark = document.getElementById("FEEDU-" + feed_id);
108 umark.innerHTML = umark.innerHTML - 1;
109 crow.className = crow.className.replace("Unread", "");
110
111 if (umark.innerHTML == "0") {
112 var feedr = document.getElementById("FEEDR-" + feed_id);
113 feedr.className = feedr.className.replace("Unread", "");
114 }
115 }
116
117 document.getElementById('content').innerHTML='Loading, please wait...';
118
119 xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true);
120 xmlhttp.onreadystatechange=view_callback;
121 xmlhttp.send(null);
122
123}
124
125function timeout() {
126
127 update_feed_list(true);
128
129 setTimeout("timeout()", 1800*1000);
130
131}
132
133function search(feed, sender) {
134
135 notify("Search: " + feed + ", " + sender.value)
136
137 document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
138 document.getElementById('content').innerHTML='&nbsp;';
139
140 xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
141 "&search=" + param_escape(sender.value) + "&ext=SEARCH", true);
142 xmlhttp.onreadystatechange=viewfeed_callback;
143 xmlhttp.send(null);
144
145}
146
147function init() {
148
149 update_feed_list(false, false);
150
151 setTimeout("timeout()", 1800*1000);
152
153
154}