]>
Commit | Line | Data |
---|---|---|
1cd17194 AD |
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 | ||
6 | var 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. | |
12 | try { | |
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 | ||
23 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
24 | xmlhttp = new XMLHttpRequest(); | |
25 | } | |
26 | ||
27 | function param_escape(arg) { | |
28 | if (typeof encodeURIComponent != 'undefined') | |
29 | return encodeURIComponent(arg); | |
30 | else | |
31 | return escape(arg); | |
32 | } | |
33 | ||
34 | function param_unescape(arg) { | |
35 | if (typeof decodeURIComponent != 'undefined') | |
36 | return decodeURIComponent(arg); | |
37 | else | |
38 | return unescape(arg); | |
39 | } | |
40 | ||
41 | function notify(msg) { | |
42 | ||
43 | var n = document.getElementById("notify"); | |
44 | ||
45 | n.innerHTML = msg; | |
46 | ||
47 | } | |
48 | ||
49 | function feedlist_callback() { | |
d76a3b03 | 50 | var container = document.getElementById('feeds'); |
1cd17194 | 51 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 52 | container.innerHTML=xmlhttp.responseText; |
1cd17194 AD |
53 | } |
54 | } | |
55 | ||
56 | function viewfeed_callback() { | |
d76a3b03 | 57 | var container = document.getElementById('headlines'); |
1cd17194 | 58 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 59 | container.innerHTML = xmlhttp.responseText; |
a1a8a2be AD |
60 | |
61 | var factive = document.getElementById("FACTIVE"); | |
62 | var funread = document.getElementById("FUNREAD"); | |
63 | var ftotal = document.getElementById("FTOTAL"); | |
64 | ||
65 | if (ftotal && factive && funread) { | |
66 | var feed_id = factive.innerHTML; | |
67 | ||
68 | var feedr = document.getElementById("FEEDR-" + feed_id); | |
69 | var feedt = document.getElementById("FEEDT-" + feed_id); | |
70 | var feedu = document.getElementById("FEEDU-" + feed_id); | |
71 | ||
72 | feedt.innerHTML = ftotal.innerHTML; | |
73 | feedu.innerHTML = funread.innerHTML; | |
74 | ||
75 | if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) { | |
76 | feedr.className = feedr.className + "Unread"; | |
77 | } else if (feedu.innerHTML <= 0) { | |
78 | feedr.className = feedr.className.replace("Unread", ""); | |
79 | } | |
80 | ||
81 | } | |
1cd17194 AD |
82 | } |
83 | } | |
84 | ||
85 | function view_callback() { | |
d76a3b03 | 86 | var container = document.getElementById('content'); |
1cd17194 | 87 | if (xmlhttp.readyState == 4) { |
d76a3b03 | 88 | container.innerHTML=xmlhttp.responseText; |
1cd17194 AD |
89 | } |
90 | } | |
91 | ||
92 | ||
40d13c28 | 93 | function update_feed_list(called_from_timer) { |
1cd17194 | 94 | |
40d13c28 AD |
95 | if (called_from_timer != true) { |
96 | document.getElementById("feeds").innerHTML = "Updating feeds, please wait..."; | |
97 | } | |
82baad4a | 98 | |
1cd17194 AD |
99 | xmlhttp.open("GET", "backend.php?op=feeds", true); |
100 | xmlhttp.onreadystatechange=feedlist_callback; | |
101 | xmlhttp.send(null); | |
102 | ||
40d13c28 | 103 | |
1cd17194 AD |
104 | } |
105 | ||
a1a8a2be | 106 | function viewfeed(feed, skip, ext) { |
1cd17194 AD |
107 | |
108 | notify("view-feed: " + feed); | |
109 | ||
d76a3b03 | 110 | document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; |
a1a8a2be | 111 | document.getElementById('content').innerHTML=' '; |
d76a3b03 AD |
112 | |
113 | xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) + | |
a1a8a2be | 114 | "&skip=" + param_escape(skip) + "&ext=" + param_escape(ext) , true); |
1cd17194 AD |
115 | xmlhttp.onreadystatechange=viewfeed_callback; |
116 | xmlhttp.send(null); | |
117 | ||
118 | } | |
119 | ||
a1a8a2be | 120 | function view(id,feed_id) { |
d76a3b03 AD |
121 | |
122 | var crow = document.getElementById("RROW-" + id); | |
123 | ||
a1a8a2be AD |
124 | if (crow.className.match("Unread")) { |
125 | var umark = document.getElementById("FEEDU-" + feed_id); | |
126 | umark.innerHTML = umark.innerHTML - 1; | |
d76a3b03 | 127 | crow.className = crow.className.replace("Unread", ""); |
d76a3b03 | 128 | |
a1a8a2be AD |
129 | if (umark.innerHTML == "0") { |
130 | var feedr = document.getElementById("FEEDR-" + feed_id); | |
131 | feedr.className = feedr.className.replace("Unread", ""); | |
132 | } | |
133 | } | |
1cd17194 | 134 | |
d76a3b03 | 135 | document.getElementById('content').innerHTML='Loading, please wait...'; |
1cd17194 | 136 | |
d76a3b03 | 137 | xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true); |
1cd17194 AD |
138 | xmlhttp.onreadystatechange=view_callback; |
139 | xmlhttp.send(null); | |
140 | ||
141 | } | |
142 | ||
40d13c28 AD |
143 | function timeout() { |
144 | ||
145 | update_feed_list(true); | |
146 | ||
147 | setTimeout("timeout()", 120*1000); | |
148 | ||
149 | } | |
150 | ||
1cd17194 AD |
151 | function init() { |
152 | ||
153 | notify("init"); | |
154 | ||
155 | update_feed_list(); | |
156 | ||
40d13c28 AD |
157 | setTimeout("timeout()", 120*1000); |
158 | ||
1cd17194 | 159 | } |