]>
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 var reply
= xmlhttp
.responseXML
.firstChild
;
75 var f_document
= window
.frames
["feeds-frame"].document
;
77 for (var l
= 0; l
< reply
.childNodes
.length
; l
++) {
78 var id
= reply
.childNodes
[l
].getAttribute("id");
79 var ctr
= reply
.childNodes
[l
].getAttribute("counter");
81 var feedctr
= f_document
.getElementById("FEEDCTR-" + id
);
82 var feedu
= f_document
.getElementById("FEEDU-" + id
);
83 var feedr
= f_document
.getElementById("FEEDR-" + id
);
85 if (feedctr
&& feedu
&& feedr
) {
87 feedu
.innerHTML
= ctr
;
90 feedctr
.className
= "odd";
91 if (!feedr
.className
.match("Unread")) {
92 feedr
.className
= feedr
.className
+ "Unread";
95 feedctr
.className
= "invisible";
96 feedr
.className
= feedr
.className
.replace("Unread", "");
103 function updateFeed(feed_id
) {
105 var query_str
= "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id
;
107 if (xmlhttp_ready(xmlhttp
)) {
108 xmlhttp
.open("GET", query_str
, true);
109 xmlhttp
.onreadystatechange
=feed_update_callback
;
117 function scheduleFeedUpdate(force
) {
119 notify("Updating feeds in background...");
121 document
.title
= "Tiny Tiny RSS - Updating...";
123 var query_str
= "backend.php?op=rpc&subop=";
126 query_str
= query_str
+ "forceUpdateAllFeeds";
128 query_str
= query_str
+ "updateAllFeeds";
131 if (xmlhttp_ready(xmlhttp
)) {
132 xmlhttp
.open("GET", query_str
, true);
133 xmlhttp
.onreadystatechange
=refetch_callback
;
140 function updateFeedList(silent
, fetch
) {
142 // if (silent != true) {
143 // notify("Loading feed list...");
146 var query_str
= "backend.php?op=feeds";
149 query_str
= query_str
+ "&tags=1";
152 if (getActiveFeedId()) {
153 query_str
= query_str
+ "&actid=" + getActiveFeedId();
156 if (fetch
) query_str
= query_str
+ "&fetch=yes";
158 var feeds_frame
= document
.getElementById("feeds-frame");
160 feeds_frame
.src
= query_str
;
163 function catchupAllFeeds() {
165 var query_str
= "backend.php?op=feeds&subop=catchupAll";
167 notify("Marking all feeds as read...");
169 var feeds_frame
= document
.getElementById("feeds-frame");
171 feeds_frame
.src
= query_str
;
175 function viewCurrentFeed(skip
, subop
) {
177 if (getActiveFeedId()) {
178 viewfeed(getActiveFeedId(), skip
, subop
);
182 function viewfeed(feed
, skip
, subop
) {
184 // notify("Loading headlines...");
188 var searchbox
= document
.getElementById("searchbox");
191 search_query
= searchbox
.value
;
196 var viewbox
= document
.getElementById("viewbox");
201 view_mode
= viewbox
[viewbox
.selectedIndex
].text
;
203 view_mode
= "All Posts";
206 setCookie("ttrss_vf_vmode", view_mode
);
208 var limitbox
= document
.getElementById("limitbox");
213 limit
= limitbox
[limitbox
.selectedIndex
].text
;
214 setCookie("ttrss_vf_limit", limit
);
219 setActiveFeedId(feed
);
221 var f_doc
= frames
["feeds-frame"].document
;
223 // f_doc.getElementById("ACTFEEDID").innerHTML = feed;
225 if (subop
== "MarkAllRead") {
227 var feedr
= f_doc
.getElementById("FEEDR-" + feed
);
228 var feedctr
= f_doc
.getElementById("FEEDCTR-" + feed
);
230 feedctr
.className
= "invisible";
232 if (feedr
.className
.match("Unread")) {
233 feedr
.className
= feedr
.className
.replace("Unread", "");
237 var query
= "backend.php?op=viewfeed&feed=" + param_escape(feed
) +
238 "&skip=" + param_escape(skip
) + "&subop=" + param_escape(subop
) +
239 "&view=" + param_escape(view_mode
) + "&limit=" + limit
;
241 if (search_query
!= "") {
242 query
= query
+ "&search=" + param_escape(search_query
);
245 var headlines_frame
= parent
.frames
["headlines-frame"];
247 headlines_frame
.location
.href
= query
+ "&addheader=true";
249 cleanSelected("feedsList");
250 var feedr
= document
.getElementById("FEEDR-" + feed
);
252 feedr
.className
= feedr
.className
+ "Selected";
255 disableContainerChildren("headlinesToolbar", false, doc
);
263 scheduleFeedUpdate(true);
264 setTimeout("timeout()", 1800*1000);
267 function resetSearch() {
268 var searchbox
= document
.getElementById("searchbox")
270 if (searchbox
.value
!= "" && getActiveFeedId()) {
271 searchbox
.value
= "";
272 viewfeed(getActiveFeedId(), 0, "");
277 viewCurrentFeed(0, "");
280 function localPiggieFunction(enable
) {
282 var query_str
= "backend.php?op=feeds&subop=piggie";
284 if (xmlhttp_ready(xmlhttp
)) {
286 xmlhttp
.open("GET", query_str
, true);
287 xmlhttp
.onreadystatechange
=feedlist_callback
;
293 function localHotkeyHandler(keycode
) {
295 /* if (keycode == 78) {
296 return moveToPost('next');
300 return moveToPost('prev');
304 return scheduleFeedUpdate(true);
308 return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
311 // notify("KC: " + keycode);
315 function genericSanityCheck() {
318 document
.getElementById("headlines").innerHTML
=
319 "<b>Fatal error:</b> This program requires XmlHttpRequest " +
320 "to function properly. Your browser doesn't seem to support it.";
324 setCookie("ttrss_vf_test", "TEST");
325 if (getCookie("ttrss_vf_test") != "TEST") {
327 document
.getElementById("headlines").innerHTML
=
328 "<b>Fatal error:</b> This program requires cookies " +
329 "to function properly. Your browser doesn't seem to support them.";
339 disableContainerChildren("headlinesToolbar", true);
341 if (!genericSanityCheck())
344 setCookie("ttrss_vf_actfeed", "");
346 updateFeedList(false, false);
347 document
.onkeydown
= hotkey_handler
;
349 setTimeout("timeout()", 1800*1000);
350 scheduleFeedUpdate(true);
352 var content
= document
.getElementById("content");
354 if (getCookie("ttrss_vf_vmode")) {
355 var viewbox
= document
.getElementById("viewbox");
356 viewbox
.value
= getCookie("ttrss_vf_vmode");
359 if (getCookie("ttrss_vf_limit")) {
360 var limitbox
= document
.getElementById("limitbox");
361 limitbox
.value
= getCookie("ttrss_vf_limit");
364 // if (getCookie("ttrss_vf_actfeed")) {
365 // viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');