]>
Commit | Line | Data |
---|---|---|
007bda35 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 | ||
961513a3 | 8 | var active_feed = false; |
a0d53889 | 9 | var active_filter = false; |
48f0adb0 | 10 | var active_label = false; |
961513a3 | 11 | |
f5a50b25 AD |
12 | var active_tab = false; |
13 | ||
007bda35 AD |
14 | /*@cc_on @*/ |
15 | /*@if (@_jscript_version >= 5) | |
16 | // JScript gives us Conditional compilation, we can cope with old IE versions. | |
17 | // and security blocked creation of the objects. | |
18 | try { | |
19 | xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); | |
20 | } catch (e) { | |
21 | try { | |
22 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
23 | } catch (E) { | |
24 | xmlhttp = false; | |
25 | } | |
26 | } | |
27 | @end @*/ | |
28 | ||
29 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
30 | xmlhttp = new XMLHttpRequest(); | |
31 | } | |
32 | ||
007bda35 | 33 | function feedlist_callback() { |
f5a50b25 | 34 | var container = document.getElementById('prefContent'); |
007bda35 AD |
35 | if (xmlhttp.readyState == 4) { |
36 | container.innerHTML=xmlhttp.responseText; | |
961513a3 AD |
37 | if (active_feed) { |
38 | var row = document.getElementById("FEEDR-" + active_feed); | |
39 | if (row) { | |
40 | if (!row.className.match("Selected")) { | |
41 | row.className = row.className + "Selected"; | |
42 | } | |
43 | } | |
44 | var checkbox = document.getElementById("FRCHK-" + active_feed); | |
45 | if (checkbox) { | |
46 | checkbox.checked = true; | |
47 | } | |
48 | } | |
f5a50b25 | 49 | p_notify(""); |
007bda35 AD |
50 | } |
51 | } | |
52 | ||
a0d53889 | 53 | function filterlist_callback() { |
f5a50b25 | 54 | var container = document.getElementById('prefContent'); |
a0d53889 | 55 | if (xmlhttp.readyState == 4) { |
f5a50b25 | 56 | |
a0d53889 AD |
57 | container.innerHTML=xmlhttp.responseText; |
58 | ||
59 | if (active_filter) { | |
60 | var row = document.getElementById("FILRR-" + active_filter); | |
61 | if (row) { | |
62 | if (!row.className.match("Selected")) { | |
63 | row.className = row.className + "Selected"; | |
64 | } | |
65 | } | |
66 | var checkbox = document.getElementById("FICHK-" + active_filter); | |
67 | ||
68 | if (checkbox) { | |
69 | checkbox.checked = true; | |
70 | } | |
71 | } | |
f5a50b25 | 72 | p_notify(""); |
a0d53889 AD |
73 | } |
74 | } | |
75 | ||
48f0adb0 | 76 | function labellist_callback() { |
f5a50b25 | 77 | var container = document.getElementById('prefContent'); |
48f0adb0 AD |
78 | if (xmlhttp.readyState == 4) { |
79 | container.innerHTML=xmlhttp.responseText; | |
80 | ||
81 | if (active_filter) { | |
82 | var row = document.getElementById("LILRR-" + active_label); | |
83 | if (row) { | |
84 | if (!row.className.match("Selected")) { | |
85 | row.className = row.className + "Selected"; | |
86 | } | |
87 | } | |
88 | var checkbox = document.getElementById("LICHK-" + active_label); | |
89 | ||
90 | if (checkbox) { | |
91 | checkbox.checked = true; | |
92 | } | |
93 | } | |
f5a50b25 | 94 | p_notify(""); |
48f0adb0 AD |
95 | } |
96 | } | |
4255b24c AD |
97 | |
98 | function prefslist_callback() { | |
99 | var container = document.getElementById('prefContent'); | |
100 | if (xmlhttp.readyState == 4) { | |
101 | ||
102 | container.innerHTML=xmlhttp.responseText; | |
103 | ||
104 | p_notify(""); | |
105 | } | |
106 | } | |
107 | ||
108 | ||
109 | ||
0e091d38 AD |
110 | function notify_callback() { |
111 | var container = document.getElementById('notify'); | |
112 | if (xmlhttp.readyState == 4) { | |
113 | container.innerHTML=xmlhttp.responseText; | |
114 | } | |
115 | } | |
116 | ||
175847de | 117 | |
0e091d38 | 118 | function updateFeedList() { |
007bda35 | 119 | |
c0e5a40e | 120 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
121 | printLockingError(); |
122 | return | |
123 | } | |
124 | ||
f5a50b25 AD |
125 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; |
126 | ||
127 | p_notify("Loading, please wait..."); | |
007bda35 AD |
128 | |
129 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
130 | xmlhttp.onreadystatechange=feedlist_callback; | |
131 | xmlhttp.send(null); | |
132 | ||
133 | } | |
134 | ||
135 | function toggleSelectRow(sender) { | |
136 | var parent_row = sender.parentNode.parentNode; | |
137 | ||
138 | if (sender.checked) { | |
139 | if (!parent_row.className.match("Selected")) { | |
140 | parent_row.className = parent_row.className + "Selected"; | |
141 | } | |
142 | } else { | |
143 | if (parent_row.className.match("Selected")) { | |
144 | parent_row.className = parent_row.className.replace("Selected", ""); | |
145 | } | |
146 | } | |
147 | } | |
148 | ||
48f0adb0 AD |
149 | function addLabel() { |
150 | ||
151 | if (!xmlhttp_ready(xmlhttp)) { | |
152 | printLockingError(); | |
153 | return | |
154 | } | |
155 | ||
156 | var sqlexp = document.getElementById("ladd_expr"); | |
157 | ||
158 | if (sqlexp.value.length == 0) { | |
159 | notify("Missing SQL expression."); | |
160 | } else { | |
161 | notify("Adding label..."); | |
162 | ||
163 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" + | |
164 | param_escape(sqlexp.value), true); | |
165 | ||
166 | xmlhttp.onreadystatechange=labellist_callback; | |
167 | xmlhttp.send(null); | |
168 | ||
169 | sqlexp.value = ""; | |
170 | } | |
171 | ||
172 | } | |
173 | ||
de435974 AD |
174 | function addFilter() { |
175 | ||
176 | if (!xmlhttp_ready(xmlhttp)) { | |
177 | printLockingError(); | |
178 | return | |
179 | } | |
180 | ||
181 | var regexp = document.getElementById("fadd_regexp"); | |
182 | var match = document.getElementById("fadd_match"); | |
183 | ||
184 | if (regexp.value.length == 0) { | |
185 | notify("Missing filter expression."); | |
186 | } else { | |
187 | notify("Adding filter..."); | |
188 | ||
25cb5736 AD |
189 | var v_match = match[match.selectedIndex].text; |
190 | ||
de435974 | 191 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" + |
25cb5736 | 192 | param_escape(regexp.value) + "&match=" + v_match, true); |
de435974 AD |
193 | |
194 | xmlhttp.onreadystatechange=filterlist_callback; | |
195 | xmlhttp.send(null); | |
196 | ||
197 | regexp.value = ""; | |
198 | } | |
199 | ||
200 | } | |
48f0adb0 | 201 | |
71ad3959 AD |
202 | function addFeed() { |
203 | ||
c0e5a40e | 204 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
205 | printLockingError(); |
206 | return | |
207 | } | |
208 | ||
331900c6 AD |
209 | var link = document.getElementById("fadd_link"); |
210 | ||
83fe4d6d | 211 | if (link.value.length == 0) { |
c753cd32 | 212 | notify("Missing feed URL."); |
331900c6 AD |
213 | } else { |
214 | notify("Adding feed..."); | |
215 | ||
216 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
217 | param_escape(link.value), true); | |
218 | xmlhttp.onreadystatechange=feedlist_callback; | |
219 | xmlhttp.send(null); | |
220 | ||
221 | link.value = ""; | |
222 | ||
223 | } | |
224 | ||
225 | } | |
226 | ||
48f0adb0 AD |
227 | function editLabel(id) { |
228 | ||
229 | if (!xmlhttp_ready(xmlhttp)) { | |
230 | printLockingError(); | |
231 | return | |
232 | } | |
233 | ||
234 | active_label = id; | |
235 | ||
236 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" + | |
237 | param_escape(id), true); | |
238 | xmlhttp.onreadystatechange=labellist_callback; | |
239 | xmlhttp.send(null); | |
240 | ||
241 | } | |
242 | ||
a0d53889 AD |
243 | function editFilter(id) { |
244 | ||
245 | if (!xmlhttp_ready(xmlhttp)) { | |
246 | printLockingError(); | |
247 | return | |
248 | } | |
249 | ||
250 | active_filter = id; | |
251 | ||
252 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + | |
253 | param_escape(id), true); | |
254 | xmlhttp.onreadystatechange=filterlist_callback; | |
255 | xmlhttp.send(null); | |
256 | ||
257 | } | |
258 | ||
331900c6 AD |
259 | function editFeed(feed) { |
260 | ||
508a81e1 AD |
261 | // notify("Editing feed..."); |
262 | ||
c0e5a40e | 263 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
264 | printLockingError(); |
265 | return | |
266 | } | |
331900c6 | 267 | |
961513a3 AD |
268 | active_feed = feed; |
269 | ||
331900c6 AD |
270 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + |
271 | param_escape(feed), true); | |
272 | xmlhttp.onreadystatechange=feedlist_callback; | |
273 | xmlhttp.send(null); | |
274 | ||
275 | } | |
276 | ||
48f0adb0 AD |
277 | function getSelectedLabels() { |
278 | ||
279 | var content = document.getElementById("prefLabelList"); | |
280 | ||
281 | var sel_rows = new Array(); | |
282 | ||
283 | for (i = 0; i < content.rows.length; i++) { | |
284 | if (content.rows[i].className.match("Selected")) { | |
285 | var row_id = content.rows[i].id.replace("LILRR-", ""); | |
286 | sel_rows.push(row_id); | |
287 | } | |
288 | } | |
289 | ||
290 | return sel_rows; | |
291 | } | |
292 | ||
293 | ||
a0d53889 AD |
294 | function getSelectedFilters() { |
295 | ||
296 | var content = document.getElementById("prefFilterList"); | |
297 | ||
298 | var sel_rows = new Array(); | |
299 | ||
300 | for (i = 0; i < content.rows.length; i++) { | |
301 | if (content.rows[i].className.match("Selected")) { | |
302 | var row_id = content.rows[i].id.replace("FILRR-", ""); | |
303 | sel_rows.push(row_id); | |
304 | } | |
305 | } | |
306 | ||
307 | return sel_rows; | |
308 | } | |
309 | ||
83fe4d6d | 310 | function getSelectedFeeds() { |
331900c6 AD |
311 | |
312 | var content = document.getElementById("prefFeedList"); | |
313 | ||
314 | var sel_rows = new Array(); | |
315 | ||
316 | for (i = 0; i < content.rows.length; i++) { | |
317 | if (content.rows[i].className.match("Selected")) { | |
318 | var row_id = content.rows[i].id.replace("FEEDR-", ""); | |
319 | sel_rows.push(row_id); | |
320 | } | |
321 | } | |
322 | ||
83fe4d6d AD |
323 | return sel_rows; |
324 | } | |
325 | ||
326 | function readSelectedFeeds() { | |
327 | ||
c0e5a40e | 328 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
329 | printLockingError(); |
330 | return | |
331 | } | |
332 | ||
83fe4d6d AD |
333 | var sel_rows = getSelectedFeeds(); |
334 | ||
335 | if (sel_rows.length > 0) { | |
336 | ||
337 | notify("Marking selected feeds as read..."); | |
338 | ||
0e091d38 | 339 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 340 | param_escape(sel_rows.toString()), true); |
0e091d38 | 341 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
342 | xmlhttp.send(null); |
343 | ||
344 | } else { | |
345 | ||
c753cd32 | 346 | notify("Please select some feeds first."); |
83fe4d6d AD |
347 | |
348 | } | |
349 | } | |
350 | ||
351 | function unreadSelectedFeeds() { | |
352 | ||
c0e5a40e | 353 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
354 | printLockingError(); |
355 | return | |
356 | } | |
357 | ||
83fe4d6d AD |
358 | var sel_rows = getSelectedFeeds(); |
359 | ||
360 | if (sel_rows.length > 0) { | |
361 | ||
362 | notify("Marking selected feeds as unread..."); | |
363 | ||
0e091d38 | 364 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ |
83fe4d6d | 365 | param_escape(sel_rows.toString()), true); |
0e091d38 | 366 | xmlhttp.onreadystatechange=notify_callback; |
83fe4d6d AD |
367 | xmlhttp.send(null); |
368 | ||
369 | } else { | |
370 | ||
c753cd32 | 371 | notify("Please select some feeds first."); |
83fe4d6d AD |
372 | |
373 | } | |
374 | } | |
375 | ||
48f0adb0 AD |
376 | function removeSelectedLabels() { |
377 | ||
378 | if (!xmlhttp_ready(xmlhttp)) { | |
379 | printLockingError(); | |
380 | return | |
381 | } | |
382 | ||
383 | var sel_rows = getSelectedLabels(); | |
384 | ||
385 | if (sel_rows.length > 0) { | |
386 | ||
387 | notify("Removing selected labels..."); | |
388 | ||
389 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
390 | param_escape(sel_rows.toString()), true); | |
391 | xmlhttp.onreadystatechange=labellist_callback; | |
392 | xmlhttp.send(null); | |
393 | ||
394 | } else { | |
395 | notify("Please select some labels first."); | |
396 | } | |
397 | } | |
398 | ||
399 | function removeSelectedFilters() { | |
400 | ||
401 | if (!xmlhttp_ready(xmlhttp)) { | |
402 | printLockingError(); | |
403 | return | |
404 | } | |
405 | ||
406 | var sel_rows = getSelectedFilters(); | |
407 | ||
408 | if (sel_rows.length > 0) { | |
409 | ||
410 | notify("Removing selected filters..."); | |
411 | ||
412 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
413 | param_escape(sel_rows.toString()), true); | |
414 | xmlhttp.onreadystatechange=filterlist_callback; | |
415 | xmlhttp.send(null); | |
416 | ||
417 | } else { | |
418 | notify("Please select some filters first."); | |
419 | } | |
420 | } | |
421 | ||
422 | ||
83fe4d6d AD |
423 | function removeSelectedFeeds() { |
424 | ||
c0e5a40e | 425 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
426 | printLockingError(); |
427 | return | |
428 | } | |
429 | ||
83fe4d6d AD |
430 | var sel_rows = getSelectedFeeds(); |
431 | ||
331900c6 AD |
432 | if (sel_rows.length > 0) { |
433 | ||
434 | notify("Removing selected feeds..."); | |
435 | ||
436 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
437 | param_escape(sel_rows.toString()), true); | |
438 | xmlhttp.onreadystatechange=feedlist_callback; | |
439 | xmlhttp.send(null); | |
71ad3959 | 440 | |
71ad3959 | 441 | } else { |
331900c6 | 442 | |
c753cd32 | 443 | notify("Please select some feeds first."); |
331900c6 | 444 | |
71ad3959 AD |
445 | } |
446 | ||
447 | } | |
007bda35 | 448 | |
508a81e1 AD |
449 | function feedEditCancel() { |
450 | ||
c0e5a40e | 451 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
452 | printLockingError(); |
453 | return | |
454 | } | |
455 | ||
961513a3 AD |
456 | active_feed = false; |
457 | ||
508a81e1 AD |
458 | notify("Operation cancelled."); |
459 | ||
460 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
461 | xmlhttp.onreadystatechange=feedlist_callback; | |
462 | xmlhttp.send(null); | |
463 | ||
464 | } | |
465 | ||
603c27f8 AD |
466 | function feedEditSave() { |
467 | ||
468 | var feed = active_feed; | |
508a81e1 | 469 | |
c0e5a40e | 470 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
471 | printLockingError(); |
472 | return | |
473 | } | |
474 | ||
603c27f8 AD |
475 | var link = document.getElementById("iedit_link").value; |
476 | var title = document.getElementById("iedit_title").value; | |
d148926e | 477 | var upd_intl = document.getElementById("iedit_updintl").value; |
5d73494a | 478 | var purge_intl = document.getElementById("iedit_purgintl").value; |
508a81e1 | 479 | |
603c27f8 | 480 | // notify("Saving feed."); |
508a81e1 | 481 | |
140aae81 | 482 | /* if (upd_intl < 0) { |
d148926e AD |
483 | notify("Update interval must be >= 0 (0 = default)"); |
484 | return; | |
485 | } | |
486 | ||
5d73494a AD |
487 | if (purge_intl < 0) { |
488 | notify("Purge days must be >= 0 (0 = default)"); | |
489 | return; | |
140aae81 | 490 | } */ |
d148926e | 491 | |
508a81e1 AD |
492 | if (link.length == 0) { |
493 | notify("Feed link cannot be blank."); | |
494 | return; | |
495 | } | |
496 | ||
497 | if (title.length == 0) { | |
498 | notify("Feed title cannot be blank."); | |
499 | return; | |
500 | } | |
501 | ||
603c27f8 AD |
502 | active_feed = false; |
503 | ||
508a81e1 | 504 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + |
d148926e | 505 | feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) + |
5d73494a | 506 | "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true); |
508a81e1 AD |
507 | xmlhttp.onreadystatechange=feedlist_callback; |
508 | xmlhttp.send(null); | |
509 | ||
510 | } | |
511 | ||
48f0adb0 AD |
512 | function labelEditCancel() { |
513 | ||
514 | if (!xmlhttp_ready(xmlhttp)) { | |
515 | printLockingError(); | |
516 | return | |
517 | } | |
518 | ||
519 | active_label = false; | |
520 | ||
521 | notify("Operation cancelled."); | |
522 | ||
523 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
524 | xmlhttp.onreadystatechange=labellist_callback; | |
525 | xmlhttp.send(null); | |
526 | ||
527 | } | |
528 | ||
529 | ||
a0d53889 AD |
530 | function filterEditCancel() { |
531 | ||
532 | if (!xmlhttp_ready(xmlhttp)) { | |
533 | printLockingError(); | |
534 | return | |
535 | } | |
536 | ||
537 | active_filter = false; | |
538 | ||
539 | notify("Operation cancelled."); | |
540 | ||
541 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
542 | xmlhttp.onreadystatechange=filterlist_callback; | |
543 | xmlhttp.send(null); | |
544 | ||
545 | } | |
546 | ||
48f0adb0 AD |
547 | function labelEditSave() { |
548 | ||
549 | var label = active_label; | |
550 | ||
551 | if (!xmlhttp_ready(xmlhttp)) { | |
552 | printLockingError(); | |
553 | return | |
554 | } | |
555 | ||
556 | var sqlexp = document.getElementById("iedit_expr").value; | |
557 | var descr = document.getElementById("iedit_descr").value; | |
558 | ||
559 | // notify("Saving label " + sqlexp + ": " + descr); | |
560 | ||
561 | if (sqlexp.length == 0) { | |
562 | notify("SQL expression cannot be blank."); | |
563 | return; | |
564 | } | |
565 | ||
566 | if (descr.length == 0) { | |
567 | notify("Caption cannot be blank."); | |
568 | return; | |
569 | } | |
570 | ||
571 | active_label = false; | |
572 | ||
573 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" + | |
574 | label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr), | |
575 | true); | |
576 | ||
577 | xmlhttp.onreadystatechange=labellist_callback; | |
578 | xmlhttp.send(null); | |
579 | ||
580 | } | |
581 | ||
a0d53889 AD |
582 | function filterEditSave() { |
583 | ||
584 | var filter = active_filter; | |
585 | ||
586 | if (!xmlhttp_ready(xmlhttp)) { | |
587 | printLockingError(); | |
588 | return | |
589 | } | |
590 | ||
591 | var regexp = document.getElementById("iedit_regexp").value; | |
592 | var descr = document.getElementById("iedit_descr").value; | |
25cb5736 AD |
593 | var match = document.getElementById("iedit_match"); |
594 | ||
595 | var v_match = match[match.selectedIndex].text; | |
a0d53889 AD |
596 | |
597 | // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match); | |
598 | ||
599 | if (regexp.length == 0) { | |
600 | notify("Filter expression cannot be blank."); | |
601 | return; | |
602 | } | |
603 | ||
604 | active_filter = false; | |
605 | ||
606 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" + | |
607 | filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) + | |
25cb5736 | 608 | "&m=" + param_escape(v_match), true); |
a0d53889 AD |
609 | |
610 | xmlhttp.onreadystatechange=filterlist_callback; | |
611 | xmlhttp.send(null); | |
612 | ||
613 | } | |
614 | ||
48f0adb0 AD |
615 | function editSelectedLabel() { |
616 | var rows = getSelectedLabels(); | |
a0d53889 | 617 | |
48f0adb0 AD |
618 | if (rows.length == 0) { |
619 | notify("No labels are selected."); | |
620 | return; | |
a0d53889 AD |
621 | } |
622 | ||
48f0adb0 AD |
623 | if (rows.length > 1) { |
624 | notify("Please select one label."); | |
625 | return; | |
626 | } | |
a0d53889 | 627 | |
48f0adb0 | 628 | editLabel(rows[0]); |
a0d53889 | 629 | |
a0d53889 AD |
630 | } |
631 | ||
632 | ||
633 | function editSelectedFilter() { | |
634 | var rows = getSelectedFilters(); | |
635 | ||
636 | if (rows.length == 0) { | |
637 | notify("No filters are selected."); | |
638 | return; | |
639 | } | |
640 | ||
641 | if (rows.length > 1) { | |
642 | notify("Please select one filter."); | |
643 | return; | |
644 | } | |
645 | ||
646 | editFilter(rows[0]); | |
647 | ||
648 | } | |
649 | ||
650 | ||
508a81e1 AD |
651 | function editSelectedFeed() { |
652 | var rows = getSelectedFeeds(); | |
653 | ||
654 | if (rows.length == 0) { | |
655 | notify("No feeds are selected."); | |
656 | return; | |
657 | } | |
658 | ||
659 | if (rows.length > 1) { | |
660 | notify("Please select one feed."); | |
661 | return; | |
662 | } | |
663 | ||
664 | editFeed(rows[0]); | |
665 | ||
666 | } | |
667 | ||
13ad9102 AD |
668 | function localPiggieFunction(enable) { |
669 | if (enable) { | |
508a81e1 AD |
670 | piggie.style.display = "block"; |
671 | seq = ""; | |
672 | notify("I loveded it!!!"); | |
673 | } else { | |
674 | piggie.style.display = "none"; | |
675 | notify(""); | |
676 | } | |
508a81e1 AD |
677 | } |
678 | ||
9f311df6 AD |
679 | function validateOpmlImport() { |
680 | ||
681 | var opml_file = document.getElementById("opml_file"); | |
682 | ||
683 | if (opml_file.value.length == 0) { | |
684 | notify("Please select OPML file to upload."); | |
685 | return false; | |
686 | } else { | |
687 | return true; | |
688 | } | |
689 | } | |
690 | ||
a0d53889 AD |
691 | function updateFilterList() { |
692 | ||
693 | if (!xmlhttp_ready(xmlhttp)) { | |
694 | printLockingError(); | |
695 | return | |
696 | } | |
697 | ||
f5a50b25 AD |
698 | // document.getElementById("prefContent").innerHTML = "Loading filters, please wait..."; |
699 | ||
700 | p_notify("Loading, please wait..."); | |
a0d53889 AD |
701 | |
702 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
703 | xmlhttp.onreadystatechange=filterlist_callback; | |
704 | xmlhttp.send(null); | |
705 | ||
706 | } | |
707 | ||
48f0adb0 AD |
708 | function updateLabelList() { |
709 | ||
710 | if (!xmlhttp_ready(xmlhttp)) { | |
711 | printLockingError(); | |
712 | return | |
713 | } | |
714 | ||
f5a50b25 AD |
715 | p_notify("Loading, please wait..."); |
716 | ||
717 | // document.getElementById("prefContent").innerHTML = "Loading labels, please wait..."; | |
48f0adb0 AD |
718 | |
719 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
720 | xmlhttp.onreadystatechange=labellist_callback; | |
721 | xmlhttp.send(null); | |
48f0adb0 AD |
722 | } |
723 | ||
4255b24c AD |
724 | function updatePrefsList() { |
725 | ||
726 | if (!xmlhttp_ready(xmlhttp)) { | |
727 | printLockingError(); | |
728 | return | |
729 | } | |
730 | ||
731 | p_notify("Loading, please wait..."); | |
732 | ||
733 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); | |
734 | xmlhttp.onreadystatechange=prefslist_callback; | |
735 | xmlhttp.send(null); | |
736 | ||
737 | } | |
738 | ||
f5a50b25 | 739 | function selectTab(id) { |
48f0adb0 | 740 | |
f5a50b25 | 741 | if (id == "feedConfig") { |
a0d53889 | 742 | updateFeedList(); |
f5a50b25 | 743 | } else if (id == "filterConfig") { |
a0d53889 | 744 | updateFilterList(); |
f5a50b25 | 745 | } else if (id == "labelConfig") { |
48f0adb0 | 746 | updateLabelList(); |
4255b24c AD |
747 | } else if (id == "genConfig") { |
748 | updatePrefsList(); | |
a0d53889 | 749 | } |
f5a50b25 AD |
750 | |
751 | var tab = document.getElementById(active_tab + "Tab"); | |
752 | ||
753 | if (tab) { | |
754 | if (tab.className.match("Selected")) { | |
755 | tab.className = "prefsTab"; | |
756 | } | |
757 | } | |
758 | ||
759 | tab = document.getElementById(id + "Tab"); | |
760 | ||
761 | if (tab) { | |
762 | if (!tab.className.match("Selected")) { | |
763 | tab.className = tab.className + "Selected"; | |
764 | } | |
765 | } | |
766 | ||
767 | active_tab = id; | |
768 | ||
a0d53889 AD |
769 | } |
770 | ||
007bda35 | 771 | function init() { |
e2ec66a8 AD |
772 | |
773 | // IE kludge | |
774 | ||
ad095c16 | 775 | if (!xmlhttp) { |
e2ec66a8 AD |
776 | document.getElementById("prefContent").innerHTML = |
777 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
778 | "to function properly. Your browser doesn't seem to support it."; | |
779 | return; | |
780 | } | |
781 | ||
77e96719 | 782 | selectTab("genConfig"); |
f5a50b25 | 783 | |
508a81e1 | 784 | document.onkeydown = hotkey_handler; |
857a9270 AD |
785 | notify(""); |
786 | ||
007bda35 | 787 | } |