]>
git.wh0rd.org - tt-rss.git/blob - tt-rss.js
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.
7 var xmlhttp_rpc
= false;
8 var xmlhttp_view
= false;
13 var active_feed_id
= false;
15 var search_query
= "";
18 /*@if (@_jscript_version >= 5)
19 // JScript gives us Conditional compilation, we can cope with old IE versions.
20 // and security blocked creation of the objects.
22 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
25 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
27 xmlhttp_view = new ActiveXObject("Microsoft.XMLHTTP");
36 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
37 xmlhttp
= new XMLHttpRequest();
38 xmlhttp_rpc
= new XMLHttpRequest();
39 xmlhttp_view
= new XMLHttpRequest();
43 function feedlist_callback() {
44 var container = document.getElementById('feeds');
45 if (xmlhttp.readyState == 4) {
46 container.innerHTML=xmlhttp.responseText;
49 scheduleFeedUpdate(false);
50 if (getCookie("ttrss_vf_actfeed")) {
51 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
62 function refetch_callback() {
64 if (xmlhttp_rpc
.readyState
== 4) {
66 var actfeedid
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID");
69 active_feed_id
= actfeedid
.innerHTML
;
72 document
.title
= "Tiny Tiny RSS";
73 notify("All feeds updated.");
81 function updateFeed(feed_id
) {
83 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
85 if (xmlhttp_ready(xmlhttp_rpc
)) {
86 xmlhttp_rpc
.open("GET", query_str
, true);
87 xmlhttp_rpc
.onreadystatechange
=feed_update_callback
;
88 xmlhttp_rpc
.send(null);
95 function scheduleFeedUpdate(force
) {
97 notify("Updating feeds in background...");
99 document
.title
= "Tiny Tiny RSS - Updating...";
101 var query_str
= "backend.php?op=rpc&subop=";
104 query_str
= query_str
+ "forceUpdateAllFeeds";
106 query_str
= query_str
+ "updateAllFeeds";
109 if (xmlhttp_ready(xmlhttp_rpc
)) {
110 xmlhttp_rpc
.open("GET", query_str
, true);
111 xmlhttp_rpc
.onreadystatechange
=refetch_callback
;
112 xmlhttp_rpc
.send(null);
118 function updateFeedList(silent
, fetch
) {
120 // if (silent != true) {
121 // notify("Loading feed list...");
124 var query_str
= "backend.php?op=feeds";
126 if (active_feed_id
) {
127 query_str
= query_str
+ "&actid=" + active_feed_id
;
130 if (fetch
) query_str
= query_str
+ "&fetch=yes";
132 var feeds_frame
= document
.getElementById("feeds-frame");
134 feeds_frame
.src
= query_str
;
137 function catchupAllFeeds() {
139 var query_str
= "backend.php?op=feeds&subop=catchupAll";
141 notify("Marking all feeds as read...");
143 var feeds_frame
= document
.getElementById("feeds-frame");
145 feeds_frame
.src
= query_str
;
149 function viewCurrentFeed(skip
, subop
) {
151 active_feed_id
= frames
["feeds-frame"].document
.getElementById("ACTFEEDID").innerHTML
;
153 if (active_feed_id
) {
154 viewfeed(active_feed_id
, skip
, subop
);
158 function viewfeed(feed
, skip
, subop
) {
160 notify("Loading headlines...");
164 var searchbox
= document
.getElementById("searchbox");
167 search_query
= searchbox
.value
;
172 var viewbox
= document
.getElementById("viewbox");
177 view_mode
= viewbox
.value
;
179 view_mode
= "All Posts";
182 setCookie("ttrss_vf_vmode", view_mode
);
184 var limitbox
= document
.getElementById("limitbox");
189 limit
= limitbox
.value
;
190 setCookie("ttrss_vf_limit", limit
);
195 active_feed_id
= feed
;
197 var f_doc
= frames
["feeds-frame"].document
;
199 f_doc
.getElementById("ACTFEEDID").innerHTML
= feed
;
201 setCookie("ttrss_vf_actfeed", feed
);
203 if (subop
== "MarkAllRead") {
205 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
206 var feedt
= f_doc
.getElementById("FEEDT-" + feed
);
207 var feedu
= f_doc
.getElementById("FEEDU-" + feed
);
209 feedu
.innerHTML
= "0";
211 if (feedr
.className
.match("Unread")) {
212 feedr
.className
= feedr
.className
.replace("Unread", "");
216 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
217 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
218 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
220 if (search_query
!= "") {
221 query
= query
+ "&search=" + param_escape(search_query
);
224 var headlines_frame
= parent
.frames
["headlines-frame"];
226 headlines_frame
.location
.href
= query
+ "&addheader=true";
228 cleanSelected("feedsList");
229 var feedr
= document
.getElementById("FEEDR-" + feed
);
231 feedr
.className
= feedr
.className
+ "Selected";
234 disableContainerChildren("headlinesToolbar", false, doc
);
242 scheduleFeedUpdate(true);
243 setTimeout("timeout()", 1800*1000);
246 function resetSearch() {
247 var searchbox
= document
.getElementById("searchbox")
249 if (searchbox
.value
!= "" && active_feed_id
) {
250 searchbox
.value
= "";
251 viewfeed(active_feed_id
, 0, "");
256 if (active_feed_id
) {
257 viewfeed(active_feed_id
, 0, "");
259 notify("Please select some feed first.");
263 function localPiggieFunction(enable
) {
265 var query_str
= "backend.php?op=feeds&subop=piggie";
267 if (xmlhttp_ready(xmlhttp
)) {
269 xmlhttp
.open("GET", query_str
, true);
270 xmlhttp
.onreadystatechange
=feedlist_callback
;
276 function localHotkeyHandler(keycode
) {
278 /* if (keycode == 78) {
279 return moveToPost('next');
283 return moveToPost('prev');
287 return scheduleFeedUpdate(true);
291 return viewfeed(active_feed_id
, active_offset
, "ForceUpdate");
294 // notify("KC: " + keycode);
300 disableContainerChildren("headlinesToolbar", true);
304 if (xmlhttp
&& !xmlhttp_rpc
) {
305 xmlhttp_rpc
= xmlhttp
;
306 xmlhttp_view
= xmlhttp
;
309 if (!xmlhttp
|| !xmlhttp_rpc
|| !xmlhttp_view
) {
310 document
.getElementById("headlines").innerHTML
=
311 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
312 "to function properly. Your browser doesn't seem to support it.";
316 updateFeedList(false, false);
317 document
.onkeydown
= hotkey_handler
;
318 setTimeout("timeout()", 1800*1000);
320 scheduleFeedUpdate(true);
322 var content
= document
.getElementById("content");
324 if (getCookie("ttrss_vf_vmode")) {
325 var viewbox
= document
.getElementById("viewbox");
326 viewbox
.value
= getCookie("ttrss_vf_vmode");
329 if (getCookie("ttrss_vf_limit")) {
330 var limitbox
= document
.getElementById("limitbox");
331 limitbox
.value
= getCookie("ttrss_vf_limit");