]>
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 | ||
28 | function feedlist_callback() { | |
29 | var container = document.getElementById('feeds'); | |
30 | if (xmlhttp.readyState == 4) { | |
31 | container.innerHTML=xmlhttp.responseText; | |
32 | } | |
33 | } | |
34 | ||
35 | function notify_callback() { | |
36 | var container = document.getElementById('notify'); | |
37 | if (xmlhttp.readyState == 4) { | |
38 | container.innerHTML=xmlhttp.responseText; | |
39 | } | |
40 | } | |
41 | ||
42 | ||
43 | function updateFeedList() { | |
44 | ||
45 | if (!xmlhttp_ready(xmlhttp)) { | |
46 | printLockingError(); | |
47 | return | |
48 | } | |
49 | ||
50 | document.getElementById("feeds").innerHTML = "Loading feeds, please wait..."; | |
51 | ||
52 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
53 | xmlhttp.onreadystatechange=feedlist_callback; | |
54 | xmlhttp.send(null); | |
55 | ||
56 | } | |
57 | ||
58 | function toggleSelectRow(sender) { | |
59 | var parent_row = sender.parentNode.parentNode; | |
60 | ||
61 | if (sender.checked) { | |
62 | if (!parent_row.className.match("Selected")) { | |
63 | parent_row.className = parent_row.className + "Selected"; | |
64 | } | |
65 | } else { | |
66 | if (parent_row.className.match("Selected")) { | |
67 | parent_row.className = parent_row.className.replace("Selected", ""); | |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | function addFeed() { | |
73 | ||
74 | if (!xmlhttp_ready(xmlhttp)) { | |
75 | printLockingError(); | |
76 | return | |
77 | } | |
78 | ||
79 | var link = document.getElementById("fadd_link"); | |
80 | ||
81 | if (link.value.length == 0) { | |
82 | notify("Missing feed URL."); | |
83 | } else { | |
84 | notify("Adding feed..."); | |
85 | ||
86 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
87 | param_escape(link.value), true); | |
88 | xmlhttp.onreadystatechange=feedlist_callback; | |
89 | xmlhttp.send(null); | |
90 | ||
91 | link.value = ""; | |
92 | ||
93 | } | |
94 | ||
95 | } | |
96 | ||
97 | function editFeed(feed) { | |
98 | ||
99 | // notify("Editing feed..."); | |
100 | ||
101 | if (!xmlhttp_ready(xmlhttp)) { | |
102 | printLockingError(); | |
103 | return | |
104 | } | |
105 | ||
106 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + | |
107 | param_escape(feed), true); | |
108 | xmlhttp.onreadystatechange=feedlist_callback; | |
109 | xmlhttp.send(null); | |
110 | ||
111 | } | |
112 | ||
113 | function getSelectedFeeds() { | |
114 | ||
115 | var content = document.getElementById("prefFeedList"); | |
116 | ||
117 | var sel_rows = new Array(); | |
118 | ||
119 | for (i = 0; i < content.rows.length; i++) { | |
120 | if (content.rows[i].className.match("Selected")) { | |
121 | var row_id = content.rows[i].id.replace("FEEDR-", ""); | |
122 | sel_rows.push(row_id); | |
123 | } | |
124 | } | |
125 | ||
126 | return sel_rows; | |
127 | } | |
128 | ||
129 | function readSelectedFeeds() { | |
130 | ||
131 | if (!xmlhttp_ready(xmlhttp)) { | |
132 | printLockingError(); | |
133 | return | |
134 | } | |
135 | ||
136 | var sel_rows = getSelectedFeeds(); | |
137 | ||
138 | if (sel_rows.length > 0) { | |
139 | ||
140 | notify("Marking selected feeds as read..."); | |
141 | ||
142 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ | |
143 | param_escape(sel_rows.toString()), true); | |
144 | xmlhttp.onreadystatechange=notify_callback; | |
145 | xmlhttp.send(null); | |
146 | ||
147 | } else { | |
148 | ||
149 | notify("Please select some feeds first."); | |
150 | ||
151 | } | |
152 | } | |
153 | ||
154 | function unreadSelectedFeeds() { | |
155 | ||
156 | if (!xmlhttp_ready(xmlhttp)) { | |
157 | printLockingError(); | |
158 | return | |
159 | } | |
160 | ||
161 | var sel_rows = getSelectedFeeds(); | |
162 | ||
163 | if (sel_rows.length > 0) { | |
164 | ||
165 | notify("Marking selected feeds as unread..."); | |
166 | ||
167 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ | |
168 | param_escape(sel_rows.toString()), true); | |
169 | xmlhttp.onreadystatechange=notify_callback; | |
170 | xmlhttp.send(null); | |
171 | ||
172 | } else { | |
173 | ||
174 | notify("Please select some feeds first."); | |
175 | ||
176 | } | |
177 | } | |
178 | ||
179 | function removeSelectedFeeds() { | |
180 | ||
181 | if (!xmlhttp_ready(xmlhttp)) { | |
182 | printLockingError(); | |
183 | return | |
184 | } | |
185 | ||
186 | var sel_rows = getSelectedFeeds(); | |
187 | ||
188 | if (sel_rows.length > 0) { | |
189 | ||
190 | notify("Removing selected feeds..."); | |
191 | ||
192 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
193 | param_escape(sel_rows.toString()), true); | |
194 | xmlhttp.onreadystatechange=feedlist_callback; | |
195 | xmlhttp.send(null); | |
196 | ||
197 | } else { | |
198 | ||
199 | notify("Please select some feeds first."); | |
200 | ||
201 | } | |
202 | ||
203 | } | |
204 | ||
205 | function feedEditCancel() { | |
206 | ||
207 | if (!xmlhttp_ready(xmlhttp)) { | |
208 | printLockingError(); | |
209 | return | |
210 | } | |
211 | ||
212 | notify("Operation cancelled."); | |
213 | ||
214 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
215 | xmlhttp.onreadystatechange=feedlist_callback; | |
216 | xmlhttp.send(null); | |
217 | ||
218 | } | |
219 | ||
220 | function feedEditSave(feed) { | |
221 | ||
222 | if (!xmlhttp_ready(xmlhttp)) { | |
223 | printLockingError(); | |
224 | return | |
225 | } | |
226 | ||
227 | notify("Saving feed."); | |
228 | ||
229 | var link = document.getElementById("fedit_link").value; | |
230 | var title = document.getElementById("fedit_title").value; | |
231 | ||
232 | if (link.length == 0) { | |
233 | notify("Feed link cannot be blank."); | |
234 | return; | |
235 | } | |
236 | ||
237 | if (title.length == 0) { | |
238 | notify("Feed title cannot be blank."); | |
239 | return; | |
240 | } | |
241 | ||
242 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + | |
243 | feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) ,true); | |
244 | xmlhttp.onreadystatechange=feedlist_callback; | |
245 | xmlhttp.send(null); | |
246 | ||
247 | } | |
248 | ||
249 | function editSelectedFeed() { | |
250 | var rows = getSelectedFeeds(); | |
251 | ||
252 | if (rows.length == 0) { | |
253 | notify("No feeds are selected."); | |
254 | return; | |
255 | } | |
256 | ||
257 | if (rows.length > 1) { | |
258 | notify("Please select one feed."); | |
259 | return; | |
260 | } | |
261 | ||
262 | editFeed(rows[0]); | |
263 | ||
264 | } | |
265 | ||
266 | function localPiggieFunction(enable) { | |
267 | if (enable) { | |
268 | piggie.style.display = "block"; | |
269 | seq = ""; | |
270 | notify("I loveded it!!!"); | |
271 | } else { | |
272 | piggie.style.display = "none"; | |
273 | notify(""); | |
274 | } | |
275 | } | |
276 | ||
277 | function init() { | |
278 | ||
279 | updateFeedList(); | |
280 | document.onkeydown = hotkey_handler; | |
281 | notify(""); | |
282 | ||
283 | } |