]>
git.wh0rd.org - tt-rss.git/blob - tt-rss.js
31f5b29c6393d23359e86cbcfac74499df683765
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
= "";
14 /*@if (@_jscript_version >= 5)
15 // JScript gives us Conditional compilation, we can cope with old IE versions.
16 // and security blocked creation of the objects.
18 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
21 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
28 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
29 xmlhttp
= new XMLHttpRequest();
33 function feedlist_callback() {
34 var container = document.getElementById('feeds');
35 if (xmlhttp.readyState == 4) {
36 container.innerHTML=xmlhttp.responseText;
39 scheduleFeedUpdate(false);
40 if (getCookie("ttrss_vf_actfeed")) {
41 viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
51 function refetch_callback() {
52 if (xmlhttp
.readyState
== 4) {
54 document
.title
= "Tiny Tiny RSS";
55 notify("All feeds updated.");
57 var reply
= xmlhttp
.responseXML
.firstChild
;
59 var f_document
= window
.frames
["feeds-frame"].document
;
61 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
62 var id
= reply
.childNodes
[l
].getAttribute("id");
63 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
65 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
66 var feedu
= f_document
.getElementById("FEEDU-" + id
);
67 var feedr
= f_document
.getElementById("FEEDR-" + id
);
69 feedu
.innerHTML
= ctr
;
72 feedctr
.className
= "odd";
73 if (!feedr
.className
.match("Unread")) {
74 feedr
.className
= feedr
.className
+ "Unread";
77 feedctr
.className
= "invisible";
78 feedr
.className
= feedr
.className
.replace("Unread", "");
84 function updateFeed(feed_id
) {
86 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
88 if (xmlhttp_ready(xmlhttp
)) {
89 xmlhttp
.open("GET", query_str
, true);
90 xmlhttp
.onreadystatechange
=feed_update_callback
;
98 function scheduleFeedUpdate(force
) {
100 notify("Updating feeds in background...");
102 document
.title
= "Tiny Tiny RSS - Updating...";
104 var query_str
= "backend.php?op=rpc&subop=";
107 query_str
= query_str
+ "forceUpdateAllFeeds";
109 query_str
= query_str
+ "updateAllFeeds";
112 if (xmlhttp_ready(xmlhttp
)) {
113 xmlhttp
.open("GET", query_str
, true);
114 xmlhttp
.onreadystatechange
=refetch_callback
;
121 function updateFeedList(silent
, fetch
) {
123 // if (silent != true) {
124 // notify("Loading feed list...");
127 var query_str
= "backend.php?op=feeds";
129 if (getActiveFeedId()) {
130 query_str
= query_str
+ "&actid=" + getActiveFeedId();
133 if (fetch
) query_str
= query_str
+ "&fetch=yes";
135 var feeds_frame
= document
.getElementById("feeds-frame");
137 feeds_frame
.src
= query_str
;
140 function catchupAllFeeds() {
142 var query_str
= "backend.php?op=feeds&subop=catchupAll";
144 notify("Marking all feeds as read...");
146 var feeds_frame
= document
.getElementById("feeds-frame");
148 feeds_frame
.src
= query_str
;
152 function viewCurrentFeed(skip
, subop
) {
154 if (getActiveFeedId()) {
155 viewfeed(getActiveFeedId(), skip
, subop
);
159 function viewfeed(feed
, skip
, subop
) {
161 // notify("Loading headlines...");
165 var searchbox
= document
.getElementById("searchbox");
168 search_query
= searchbox
.value
;
173 var viewbox
= document
.getElementById("viewbox");
178 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
180 view_mode
= "All Posts";
183 setCookie("ttrss_vf_vmode", view_mode
);
185 var limitbox
= document
.getElementById("limitbox");
190 limit
= limitbox
[limitbox
.selectedIndex
].text
;
191 setCookie("ttrss_vf_limit", limit
);
196 setActiveFeedId(feed
);
198 var f_doc
= frames
["feeds-frame"].document
;
200 // f_doc.getElementById("ACTFEEDID").innerHTML = feed;
202 if (subop
== "MarkAllRead") {
204 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
205 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
207 feedctr
.className
= "invisible";
209 if (feedr
.className
.match("Unread")) {
210 feedr
.className
= feedr
.className
.replace("Unread", "");
214 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
215 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
216 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
218 if (search_query
!= "") {
219 query
= query
+ "&search=" + param_escape(search_query
);
222 var headlines_frame
= parent
.frames
["headlines-frame"];
224 headlines_frame
.location
.href
= query
+ "&addheader=true";
226 cleanSelected("feedsList");
227 var feedr
= document
.getElementById("FEEDR-" + feed
);
229 feedr
.className
= feedr
.className
+ "Selected";
232 disableContainerChildren("headlinesToolbar", false, doc
);
240 scheduleFeedUpdate(true);
241 setTimeout("timeout()", 1800*1000);
244 function resetSearch() {
245 var searchbox
= document
.getElementById("searchbox")
247 if (searchbox
.value
!= "" && getActiveFeedId()) {
248 searchbox
.value
= "";
249 viewfeed(getActiveFeedId(), 0, "");
255 if (getActiveFeedId()) {
256 viewfeed(getActiveFeedId(), 0, "");
258 notify("Please select some feed first.");
262 function localPiggieFunction(enable
) {
264 var query_str
= "backend.php?op=feeds&subop=piggie";
266 if (xmlhttp_ready(xmlhttp
)) {
268 xmlhttp
.open("GET", query_str
, true);
269 xmlhttp
.onreadystatechange
=feedlist_callback
;
275 function localHotkeyHandler(keycode
) {
277 /* if (keycode == 78) {
278 return moveToPost('next');
282 return moveToPost('prev');
286 return scheduleFeedUpdate(true);
290 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
293 // notify("KC: " + keycode);
297 function genericSanityCheck() {
300 document
.getElementById("headlines").innerHTML
=
301 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
302 "to function properly. Your browser doesn't seem to support it.";
306 setCookie("ttrss_vf_test", "TEST");
307 if (getCookie("ttrss_vf_test") != "TEST") {
309 document
.getElementById("headlines").innerHTML
=
310 "<b>Fatal error:</b> This program requires cookies " +
311 "to function properly. Your browser doesn't seem to support them.";
321 disableContainerChildren("headlinesToolbar", true);
323 if (!genericSanityCheck())
326 updateFeedList(false, false);
327 document
.onkeydown
= hotkey_handler
;
329 setTimeout("timeout()", 1800*1000);
330 scheduleFeedUpdate(true);
332 var content
= document
.getElementById("content");
334 if (getCookie("ttrss_vf_vmode")) {
335 var viewbox
= document
.getElementById("viewbox");
336 viewbox
.value
= getCookie("ttrss_vf_vmode");
339 if (getCookie("ttrss_vf_limit")) {
340 var limitbox
= document
.getElementById("limitbox");
341 limitbox
.value
= getCookie("ttrss_vf_limit");
344 // if (getCookie("ttrss_vf_actfeed")) {
345 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
348 setCookie("ttrss_vf_actfeed", "");