]>
Commit | Line | Data |
---|---|---|
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() { | |
50 | var container = document.getElementById('feeds'); | |
51 | if (xmlhttp.readyState == 4) { | |
52 | container.innerHTML=xmlhttp.responseText; | |
53 | } | |
54 | } | |
55 | ||
56 | function viewfeed_callback() { | |
57 | var container = document.getElementById('headlines'); | |
58 | if (xmlhttp.readyState == 4) { | |
59 | container.innerHTML = xmlhttp.responseText; | |
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 | } | |
82 | } | |
83 | } | |
84 | ||
85 | function view_callback() { | |
86 | var container = document.getElementById('content'); | |
87 | if (xmlhttp.readyState == 4) { | |
88 | container.innerHTML=xmlhttp.responseText; | |
89 | } | |
90 | } | |
91 | ||
92 | ||
93 | function update_feed_list(called_from_timer) { | |
94 | ||
95 | if (called_from_timer != true) { | |
96 | document.getElementById("feeds").innerHTML = "Updating feeds, please wait..."; | |
97 | } | |
98 | ||
99 | xmlhttp.open("GET", "backend.php?op=feeds", true); | |
100 | xmlhttp.onreadystatechange=feedlist_callback; | |
101 | xmlhttp.send(null); | |
102 | ||
103 | ||
104 | } | |
105 | ||
106 | function viewfeed(feed, skip, ext) { | |
107 | ||
108 | notify("view-feed: " + feed); | |
109 | ||
110 | document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; | |
111 | document.getElementById('content').innerHTML=' '; | |
112 | ||
113 | xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) + | |
114 | "&skip=" + param_escape(skip) + "&ext=" + param_escape(ext) , true); | |
115 | xmlhttp.onreadystatechange=viewfeed_callback; | |
116 | xmlhttp.send(null); | |
117 | ||
118 | } | |
119 | ||
120 | function view(id,feed_id) { | |
121 | ||
122 | var crow = document.getElementById("RROW-" + id); | |
123 | ||
124 | if (crow.className.match("Unread")) { | |
125 | var umark = document.getElementById("FEEDU-" + feed_id); | |
126 | umark.innerHTML = umark.innerHTML - 1; | |
127 | crow.className = crow.className.replace("Unread", ""); | |
128 | ||
129 | if (umark.innerHTML == "0") { | |
130 | var feedr = document.getElementById("FEEDR-" + feed_id); | |
131 | feedr.className = feedr.className.replace("Unread", ""); | |
132 | } | |
133 | } | |
134 | ||
135 | document.getElementById('content').innerHTML='Loading, please wait...'; | |
136 | ||
137 | xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true); | |
138 | xmlhttp.onreadystatechange=view_callback; | |
139 | xmlhttp.send(null); | |
140 | ||
141 | } | |
142 | ||
143 | function timeout() { | |
144 | ||
145 | update_feed_list(true); | |
146 | ||
147 | setTimeout("timeout()", 1800*1000); | |
148 | ||
149 | } | |
150 | ||
151 | function search(feed, sender) { | |
152 | ||
153 | notify("Search: " + feed + ", " + sender.value) | |
154 | ||
155 | document.getElementById('headlines').innerHTML='Loading headlines, please wait...'; | |
156 | document.getElementById('content').innerHTML=' '; | |
157 | ||
158 | xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) + | |
159 | "&search=" + param_escape(sender.value) + "&ext=SEARCH", true); | |
160 | xmlhttp.onreadystatechange=viewfeed_callback; | |
161 | xmlhttp.send(null); | |
162 | ||
163 | } | |
164 | ||
165 | function init() { | |
166 | ||
167 | notify("init"); | |
168 | ||
169 | update_feed_list(); | |
170 | ||
171 | setTimeout("timeout()", 1800*1000); | |
172 | ||
173 | } |