]>
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.
11 var search_query
= "";
13 var display_tags
= false;
16 /*@if (@_jscript_version >= 5)
17 // JScript gives us Conditional compilation, we can cope with old IE versions.
18 // and security blocked creation of the objects.
20 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
23 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
30 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
31 xmlhttp
= new XMLHttpRequest();
34 function toggleTags() {
35 display_tags
= !display_tags
;
37 var p
= document
.getElementById("dispSwitchPrompt");
40 p
.innerHTML
= "display feeds";
42 p
.innerHTML
= "display tags";
49 function feedlist_callback() {
50 var container = document.getElementById('feeds');
51 if (xmlhttp.readyState == 4) {
52 container.innerHTML=xmlhttp.responseText;
55 scheduleFeedUpdate(false);
56 if (getCookie("ttrss_vf_actfeed")) {
57 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
67 function refetch_callback() {
68 if (xmlhttp
.readyState
== 4) {
70 document
.title
= "Tiny Tiny RSS";
71 notify("All feeds updated.");
73 if (!xmlhttp
.responseXML
) {
74 notify("refetch_callback: backend did not return valid XML");
78 var reply
= xmlhttp
.responseXML
.firstChild
;
81 notify("refetch_callback: backend did not return expected XML object");
85 var f_document
= window
.frames
["feeds-frame"].document
;
87 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
88 var id
= reply
.childNodes
[l
].getAttribute("id");
89 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
91 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
92 var feedu
= f_document
.getElementById("FEEDU-" + id
);
93 var feedr
= f_document
.getElementById("FEEDR-" + id
);
95 if (feedctr
&& feedu
&& feedr
) {
97 feedu
.innerHTML
= ctr
;
100 feedctr
.className
= "odd";
101 if (!feedr
.className
.match("Unread")) {
102 feedr
.className
= feedr
.className
+ "Unread";
105 feedctr
.className
= "invisible";
106 feedr
.className
= feedr
.className
.replace("Unread", "");
113 function updateFeed(feed_id
) {
115 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
117 if (xmlhttp_ready(xmlhttp
)) {
118 xmlhttp
.open("GET", query_str
, true);
119 xmlhttp
.onreadystatechange
=feed_update_callback
;
127 function scheduleFeedUpdate(force
) {
129 notify("Updating feeds in background...");
131 document
.title
= "Tiny Tiny RSS - Updating...";
133 var query_str
= "backend.php?op=rpc&subop=";
136 query_str
= query_str
+ "forceUpdateAllFeeds";
138 query_str
= query_str
+ "updateAllFeeds";
141 if (xmlhttp_ready(xmlhttp
)) {
142 xmlhttp
.open("GET", query_str
, true);
143 xmlhttp
.onreadystatechange
=refetch_callback
;
150 function updateFeedList(silent
, fetch
) {
152 // if (silent != true) {
153 // notify("Loading feed list...");
156 var query_str
= "backend.php?op=feeds";
159 query_str
= query_str
+ "&tags=1";
162 if (getActiveFeedId()) {
163 query_str
= query_str
+ "&actid=" + getActiveFeedId();
166 if (fetch
) query_str
= query_str
+ "&fetch=yes";
168 var feeds_frame
= document
.getElementById("feeds-frame");
170 feeds_frame
.src
= query_str
;
173 function catchupAllFeeds() {
175 var query_str
= "backend.php?op=feeds&subop=catchupAll";
177 notify("Marking all feeds as read...");
179 var feeds_frame
= document
.getElementById("feeds-frame");
181 feeds_frame
.src
= query_str
;
185 function viewCurrentFeed(skip
, subop
) {
187 if (getActiveFeedId()) {
188 viewfeed(getActiveFeedId(), skip
, subop
);
192 function viewfeed(feed
, skip
, subop
) {
194 // notify("Loading headlines...");
198 var searchbox
= document
.getElementById("searchbox");
201 search_query
= searchbox
.value
;
206 var viewbox
= document
.getElementById("viewbox");
211 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
213 view_mode
= "All Posts";
216 setCookie("ttrss_vf_vmode", view_mode
);
218 var limitbox
= document
.getElementById("limitbox");
223 limit
= limitbox
[limitbox
.selectedIndex
].text
;
224 setCookie("ttrss_vf_limit", limit
);
229 setActiveFeedId(feed
);
231 var f_doc
= frames
["feeds-frame"].document
;
233 // f_doc.getElementById("ACTFEEDID").innerHTML = feed;
235 if (subop
== "MarkAllRead") {
237 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
238 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
240 feedctr
.className
= "invisible";
242 if (feedr
.className
.match("Unread")) {
243 feedr
.className
= feedr
.className
.replace("Unread", "");
247 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
248 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
249 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
251 if (search_query
!= "") {
252 query
= query
+ "&search=" + param_escape(search_query
);
255 var headlines_frame
= parent
.frames
["headlines-frame"];
257 headlines_frame
.location
.href
= query
+ "&addheader=true";
259 cleanSelected("feedsList");
260 var feedr
= document
.getElementById("FEEDR-" + feed
);
262 feedr
.className
= feedr
.className
+ "Selected";
265 disableContainerChildren("headlinesToolbar", false, doc
);
273 scheduleFeedUpdate(true);
274 setTimeout("timeout()", 1800*1000);
277 function resetSearch() {
278 var searchbox
= document
.getElementById("searchbox")
280 if (searchbox
.value
!= "" && getActiveFeedId()) {
281 searchbox
.value
= "";
282 viewfeed(getActiveFeedId(), 0, "");
287 viewCurrentFeed(0, "");
290 function localPiggieFunction(enable
) {
292 var query_str
= "backend.php?op=feeds&subop=piggie";
294 if (xmlhttp_ready(xmlhttp
)) {
296 xmlhttp
.open("GET", query_str
, true);
297 xmlhttp
.onreadystatechange
=feedlist_callback
;
303 function localHotkeyHandler(keycode
) {
305 /* if (keycode == 78) {
306 return moveToPost('next');
310 return moveToPost('prev');
314 return scheduleFeedUpdate(true);
318 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
321 // notify("KC: " + keycode);
325 function genericSanityCheck() {
328 document
.getElementById("headlines").innerHTML
=
329 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
330 "to function properly. Your browser doesn't seem to support it.";
334 setCookie("ttrss_vf_test", "TEST");
335 if (getCookie("ttrss_vf_test") != "TEST") {
337 document
.getElementById("headlines").innerHTML
=
338 "<b>Fatal error:</b> This program requires cookies " +
339 "to function properly. Your browser doesn't seem to support them.";
349 disableContainerChildren("headlinesToolbar", true);
351 if (!genericSanityCheck())
354 setCookie("ttrss_vf_actfeed", "");
356 updateFeedList(false, false);
357 document
.onkeydown
= hotkey_handler
;
359 setTimeout("timeout()", 1800*1000);
360 scheduleFeedUpdate(true);
362 var content
= document
.getElementById("content");
364 if (getCookie("ttrss_vf_vmode")) {
365 var viewbox
= document
.getElementById("viewbox");
366 viewbox
.value
= getCookie("ttrss_vf_vmode");
369 if (getCookie("ttrss_vf_limit")) {
370 var limitbox
= document
.getElementById("limitbox");
371 limitbox
.value
= getCookie("ttrss_vf_limit");
374 // if (getCookie("ttrss_vf_actfeed")) {
375 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');