]>
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 | var active_feed = false; | |
9 | var active_filter = false; | |
10 | var active_label = false; | |
11 | var active_user = false; | |
12 | ||
13 | var active_tab = false; | |
14 | ||
15 | /*@cc_on @*/ | |
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. | |
19 | try { | |
20 | xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); | |
21 | } catch (e) { | |
22 | try { | |
23 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
24 | } catch (E) { | |
25 | xmlhttp = false; | |
26 | } | |
27 | } | |
28 | @end @*/ | |
29 | ||
30 | if (!xmlhttp && typeof XMLHttpRequest!='undefined') { | |
31 | xmlhttp = new XMLHttpRequest(); | |
32 | } | |
33 | ||
34 | function feedlist_callback() { | |
35 | var container = document.getElementById('prefContent'); | |
36 | if (xmlhttp.readyState == 4) { | |
37 | container.innerHTML=xmlhttp.responseText; | |
38 | if (active_feed) { | |
39 | var row = document.getElementById("FEEDR-" + active_feed); | |
40 | if (row) { | |
41 | if (!row.className.match("Selected")) { | |
42 | row.className = row.className + "Selected"; | |
43 | } | |
44 | } | |
45 | var checkbox = document.getElementById("FRCHK-" + active_feed); | |
46 | if (checkbox) { | |
47 | checkbox.checked = true; | |
48 | } | |
49 | } | |
50 | p_notify(""); | |
51 | } | |
52 | } | |
53 | ||
54 | function filterlist_callback() { | |
55 | var container = document.getElementById('prefContent'); | |
56 | if (xmlhttp.readyState == 4) { | |
57 | ||
58 | container.innerHTML=xmlhttp.responseText; | |
59 | ||
60 | if (active_filter) { | |
61 | var row = document.getElementById("FILRR-" + active_filter); | |
62 | if (row) { | |
63 | if (!row.className.match("Selected")) { | |
64 | row.className = row.className + "Selected"; | |
65 | } | |
66 | } | |
67 | var checkbox = document.getElementById("FICHK-" + active_filter); | |
68 | ||
69 | if (checkbox) { | |
70 | checkbox.checked = true; | |
71 | } | |
72 | } | |
73 | p_notify(""); | |
74 | } | |
75 | } | |
76 | ||
77 | function labellist_callback() { | |
78 | var container = document.getElementById('prefContent'); | |
79 | if (xmlhttp.readyState == 4) { | |
80 | container.innerHTML=xmlhttp.responseText; | |
81 | ||
82 | if (active_label) { | |
83 | var row = document.getElementById("LILRR-" + active_label); | |
84 | if (row) { | |
85 | if (!row.className.match("Selected")) { | |
86 | row.className = row.className + "Selected"; | |
87 | } | |
88 | } | |
89 | var checkbox = document.getElementById("LICHK-" + active_label); | |
90 | ||
91 | if (checkbox) { | |
92 | checkbox.checked = true; | |
93 | } | |
94 | } | |
95 | p_notify(""); | |
96 | } | |
97 | } | |
98 | ||
99 | function userlist_callback() { | |
100 | var container = document.getElementById('prefContent'); | |
101 | if (xmlhttp.readyState == 4) { | |
102 | container.innerHTML=xmlhttp.responseText; | |
103 | ||
104 | if (active_user) { | |
105 | var row = document.getElementById("UMRR-" + active_user); | |
106 | if (row) { | |
107 | if (!row.className.match("Selected")) { | |
108 | row.className = row.className + "Selected"; | |
109 | } | |
110 | } | |
111 | var checkbox = document.getElementById("UMCHK-" + active_user); | |
112 | ||
113 | if (checkbox) { | |
114 | checkbox.checked = true; | |
115 | } | |
116 | } | |
117 | ||
118 | p_notify(""); | |
119 | } | |
120 | } | |
121 | ||
122 | function infobox_callback() { | |
123 | var container = document.getElementById('infoBox'); | |
124 | if (xmlhttp.readyState == 4) { | |
125 | if (container) { | |
126 | container.innerHTML=xmlhttp.responseText; | |
127 | container.style.display = "block"; | |
128 | } | |
129 | } | |
130 | } | |
131 | ||
132 | ||
133 | function prefslist_callback() { | |
134 | var container = document.getElementById('prefContent'); | |
135 | if (xmlhttp.readyState == 4) { | |
136 | ||
137 | container.innerHTML=xmlhttp.responseText; | |
138 | ||
139 | p_notify(""); | |
140 | } | |
141 | } | |
142 | ||
143 | function gethelp_callback() { | |
144 | var container = document.getElementById('prefHelpBox'); | |
145 | if (xmlhttp.readyState == 4) { | |
146 | ||
147 | container.innerHTML = xmlhttp.responseText; | |
148 | container.style.display = "block"; | |
149 | ||
150 | } | |
151 | } | |
152 | ||
153 | ||
154 | function notify_callback() { | |
155 | var container = document.getElementById('notify'); | |
156 | if (xmlhttp.readyState == 4) { | |
157 | container.innerHTML=xmlhttp.responseText; | |
158 | } | |
159 | } | |
160 | ||
161 | ||
162 | function updateFeedList() { | |
163 | ||
164 | if (!xmlhttp_ready(xmlhttp)) { | |
165 | printLockingError(); | |
166 | return | |
167 | } | |
168 | ||
169 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; | |
170 | ||
171 | p_notify("Loading, please wait..."); | |
172 | ||
173 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
174 | xmlhttp.onreadystatechange=feedlist_callback; | |
175 | xmlhttp.send(null); | |
176 | ||
177 | } | |
178 | ||
179 | function updateUsersList() { | |
180 | ||
181 | if (!xmlhttp_ready(xmlhttp)) { | |
182 | printLockingError(); | |
183 | return | |
184 | } | |
185 | ||
186 | // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait..."; | |
187 | ||
188 | p_notify("Loading, please wait..."); | |
189 | ||
190 | xmlhttp.open("GET", "backend.php?op=pref-users", true); | |
191 | xmlhttp.onreadystatechange=userlist_callback; | |
192 | xmlhttp.send(null); | |
193 | ||
194 | } | |
195 | ||
196 | function toggleSelectRow(sender) { | |
197 | var parent_row = sender.parentNode.parentNode; | |
198 | ||
199 | if (sender.checked) { | |
200 | if (!parent_row.className.match("Selected")) { | |
201 | parent_row.className = parent_row.className + "Selected"; | |
202 | } | |
203 | } else { | |
204 | if (parent_row.className.match("Selected")) { | |
205 | parent_row.className = parent_row.className.replace("Selected", ""); | |
206 | } | |
207 | } | |
208 | } | |
209 | ||
210 | function addLabel() { | |
211 | ||
212 | if (!xmlhttp_ready(xmlhttp)) { | |
213 | printLockingError(); | |
214 | return | |
215 | } | |
216 | ||
217 | var sqlexp = document.getElementById("ladd_expr"); | |
218 | ||
219 | if (sqlexp.value.length == 0) { | |
220 | notify("Missing SQL expression."); | |
221 | } else { | |
222 | notify("Adding label..."); | |
223 | ||
224 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" + | |
225 | param_escape(sqlexp.value), true); | |
226 | ||
227 | xmlhttp.onreadystatechange=labellist_callback; | |
228 | xmlhttp.send(null); | |
229 | ||
230 | sqlexp.value = ""; | |
231 | } | |
232 | ||
233 | } | |
234 | ||
235 | function addFilter() { | |
236 | ||
237 | if (!xmlhttp_ready(xmlhttp)) { | |
238 | printLockingError(); | |
239 | return | |
240 | } | |
241 | ||
242 | var regexp = document.getElementById("fadd_regexp"); | |
243 | var match = document.getElementById("fadd_match"); | |
244 | ||
245 | if (regexp.value.length == 0) { | |
246 | notify("Missing filter expression."); | |
247 | } else { | |
248 | notify("Adding filter..."); | |
249 | ||
250 | var v_match = match[match.selectedIndex].text; | |
251 | ||
252 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" + | |
253 | param_escape(regexp.value) + "&match=" + v_match, true); | |
254 | ||
255 | xmlhttp.onreadystatechange=filterlist_callback; | |
256 | xmlhttp.send(null); | |
257 | ||
258 | regexp.value = ""; | |
259 | } | |
260 | ||
261 | } | |
262 | ||
263 | function addFeed() { | |
264 | ||
265 | if (!xmlhttp_ready(xmlhttp)) { | |
266 | printLockingError(); | |
267 | return | |
268 | } | |
269 | ||
270 | var link = document.getElementById("fadd_link"); | |
271 | ||
272 | if (link.value.length == 0) { | |
273 | notify("Missing feed URL."); | |
274 | } else { | |
275 | notify("Adding feed..."); | |
276 | ||
277 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + | |
278 | param_escape(link.value), true); | |
279 | xmlhttp.onreadystatechange=feedlist_callback; | |
280 | xmlhttp.send(null); | |
281 | ||
282 | link.value = ""; | |
283 | ||
284 | } | |
285 | ||
286 | } | |
287 | ||
288 | function addUser() { | |
289 | ||
290 | if (!xmlhttp_ready(xmlhttp)) { | |
291 | printLockingError(); | |
292 | return | |
293 | } | |
294 | ||
295 | var sqlexp = document.getElementById("uadd_box"); | |
296 | ||
297 | if (sqlexp.value.length == 0) { | |
298 | notify("Missing user login."); | |
299 | } else { | |
300 | notify("Adding user..."); | |
301 | ||
302 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" + | |
303 | param_escape(sqlexp.value), true); | |
304 | ||
305 | xmlhttp.onreadystatechange=userlist_callback; | |
306 | xmlhttp.send(null); | |
307 | ||
308 | sqlexp.value = ""; | |
309 | } | |
310 | ||
311 | } | |
312 | ||
313 | function editLabel(id) { | |
314 | ||
315 | if (!xmlhttp_ready(xmlhttp)) { | |
316 | printLockingError(); | |
317 | return | |
318 | } | |
319 | ||
320 | active_label = id; | |
321 | ||
322 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" + | |
323 | param_escape(id), true); | |
324 | xmlhttp.onreadystatechange=labellist_callback; | |
325 | xmlhttp.send(null); | |
326 | ||
327 | } | |
328 | ||
329 | function editUser(id) { | |
330 | ||
331 | if (!xmlhttp_ready(xmlhttp)) { | |
332 | printLockingError(); | |
333 | return | |
334 | } | |
335 | ||
336 | active_user = id; | |
337 | ||
338 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" + | |
339 | param_escape(id), true); | |
340 | xmlhttp.onreadystatechange=userlist_callback; | |
341 | xmlhttp.send(null); | |
342 | ||
343 | } | |
344 | ||
345 | function editFilter(id) { | |
346 | ||
347 | if (!xmlhttp_ready(xmlhttp)) { | |
348 | printLockingError(); | |
349 | return | |
350 | } | |
351 | ||
352 | active_filter = id; | |
353 | ||
354 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + | |
355 | param_escape(id), true); | |
356 | xmlhttp.onreadystatechange=filterlist_callback; | |
357 | xmlhttp.send(null); | |
358 | ||
359 | } | |
360 | ||
361 | function editFeed(feed) { | |
362 | ||
363 | // notify("Editing feed..."); | |
364 | ||
365 | if (!xmlhttp_ready(xmlhttp)) { | |
366 | printLockingError(); | |
367 | return | |
368 | } | |
369 | ||
370 | active_feed = feed; | |
371 | ||
372 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" + | |
373 | param_escape(feed), true); | |
374 | xmlhttp.onreadystatechange=feedlist_callback; | |
375 | xmlhttp.send(null); | |
376 | ||
377 | } | |
378 | ||
379 | function getSelectedLabels() { | |
380 | ||
381 | var content = document.getElementById("prefLabelList"); | |
382 | ||
383 | var sel_rows = new Array(); | |
384 | ||
385 | for (i = 0; i < content.rows.length; i++) { | |
386 | if (content.rows[i].className.match("Selected")) { | |
387 | var row_id = content.rows[i].id.replace("LILRR-", ""); | |
388 | sel_rows.push(row_id); | |
389 | } | |
390 | } | |
391 | ||
392 | return sel_rows; | |
393 | } | |
394 | ||
395 | function getSelectedUsers() { | |
396 | ||
397 | var content = document.getElementById("prefUserList"); | |
398 | ||
399 | var sel_rows = new Array(); | |
400 | ||
401 | for (i = 0; i < content.rows.length; i++) { | |
402 | if (content.rows[i].className.match("Selected")) { | |
403 | var row_id = content.rows[i].id.replace("UMRR-", ""); | |
404 | sel_rows.push(row_id); | |
405 | } | |
406 | } | |
407 | ||
408 | return sel_rows; | |
409 | } | |
410 | ||
411 | ||
412 | function getSelectedFilters() { | |
413 | ||
414 | var content = document.getElementById("prefFilterList"); | |
415 | ||
416 | var sel_rows = new Array(); | |
417 | ||
418 | for (i = 0; i < content.rows.length; i++) { | |
419 | if (content.rows[i].className.match("Selected")) { | |
420 | var row_id = content.rows[i].id.replace("FILRR-", ""); | |
421 | sel_rows.push(row_id); | |
422 | } | |
423 | } | |
424 | ||
425 | return sel_rows; | |
426 | } | |
427 | ||
428 | function getSelectedFeeds() { | |
429 | ||
430 | var content = document.getElementById("prefFeedList"); | |
431 | ||
432 | var sel_rows = new Array(); | |
433 | ||
434 | for (i = 0; i < content.rows.length; i++) { | |
435 | if (content.rows[i].className.match("Selected")) { | |
436 | var row_id = content.rows[i].id.replace("FEEDR-", ""); | |
437 | sel_rows.push(row_id); | |
438 | } | |
439 | } | |
440 | ||
441 | return sel_rows; | |
442 | } | |
443 | ||
444 | function readSelectedFeeds() { | |
445 | ||
446 | if (!xmlhttp_ready(xmlhttp)) { | |
447 | printLockingError(); | |
448 | return | |
449 | } | |
450 | ||
451 | var sel_rows = getSelectedFeeds(); | |
452 | ||
453 | if (sel_rows.length > 0) { | |
454 | ||
455 | notify("Marking selected feeds as read..."); | |
456 | ||
457 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ | |
458 | param_escape(sel_rows.toString()), true); | |
459 | xmlhttp.onreadystatechange=notify_callback; | |
460 | xmlhttp.send(null); | |
461 | ||
462 | } else { | |
463 | ||
464 | notify("Please select some feeds first."); | |
465 | ||
466 | } | |
467 | } | |
468 | ||
469 | function unreadSelectedFeeds() { | |
470 | ||
471 | if (!xmlhttp_ready(xmlhttp)) { | |
472 | printLockingError(); | |
473 | return | |
474 | } | |
475 | ||
476 | var sel_rows = getSelectedFeeds(); | |
477 | ||
478 | if (sel_rows.length > 0) { | |
479 | ||
480 | notify("Marking selected feeds as unread..."); | |
481 | ||
482 | xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ | |
483 | param_escape(sel_rows.toString()), true); | |
484 | xmlhttp.onreadystatechange=notify_callback; | |
485 | xmlhttp.send(null); | |
486 | ||
487 | } else { | |
488 | ||
489 | notify("Please select some feeds first."); | |
490 | ||
491 | } | |
492 | } | |
493 | ||
494 | function removeSelectedLabels() { | |
495 | ||
496 | if (!xmlhttp_ready(xmlhttp)) { | |
497 | printLockingError(); | |
498 | return | |
499 | } | |
500 | ||
501 | var sel_rows = getSelectedLabels(); | |
502 | ||
503 | if (sel_rows.length > 0) { | |
504 | ||
505 | notify("Removing selected labels..."); | |
506 | ||
507 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
508 | param_escape(sel_rows.toString()), true); | |
509 | xmlhttp.onreadystatechange=labellist_callback; | |
510 | xmlhttp.send(null); | |
511 | ||
512 | } else { | |
513 | notify("Please select some labels first."); | |
514 | } | |
515 | } | |
516 | ||
517 | function removeSelectedUsers() { | |
518 | ||
519 | if (!xmlhttp_ready(xmlhttp)) { | |
520 | printLockingError(); | |
521 | return | |
522 | } | |
523 | ||
524 | var sel_rows = getSelectedUsers(); | |
525 | ||
526 | if (sel_rows.length > 0) { | |
527 | ||
528 | notify("Removing selected users..."); | |
529 | ||
530 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
531 | param_escape(sel_rows.toString()), true); | |
532 | xmlhttp.onreadystatechange=userlist_callback; | |
533 | xmlhttp.send(null); | |
534 | ||
535 | } else { | |
536 | notify("Please select some labels first."); | |
537 | } | |
538 | } | |
539 | ||
540 | function removeSelectedFilters() { | |
541 | ||
542 | if (!xmlhttp_ready(xmlhttp)) { | |
543 | printLockingError(); | |
544 | return | |
545 | } | |
546 | ||
547 | var sel_rows = getSelectedFilters(); | |
548 | ||
549 | if (sel_rows.length > 0) { | |
550 | ||
551 | notify("Removing selected filters..."); | |
552 | ||
553 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
554 | param_escape(sel_rows.toString()), true); | |
555 | xmlhttp.onreadystatechange=filterlist_callback; | |
556 | xmlhttp.send(null); | |
557 | ||
558 | } else { | |
559 | notify("Please select some filters first."); | |
560 | } | |
561 | } | |
562 | ||
563 | ||
564 | function removeSelectedFeeds() { | |
565 | ||
566 | if (!xmlhttp_ready(xmlhttp)) { | |
567 | printLockingError(); | |
568 | return | |
569 | } | |
570 | ||
571 | var sel_rows = getSelectedFeeds(); | |
572 | ||
573 | if (sel_rows.length > 0) { | |
574 | ||
575 | notify("Removing selected feeds..."); | |
576 | ||
577 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
578 | param_escape(sel_rows.toString()), true); | |
579 | xmlhttp.onreadystatechange=feedlist_callback; | |
580 | xmlhttp.send(null); | |
581 | ||
582 | } else { | |
583 | ||
584 | notify("Please select some feeds first."); | |
585 | ||
586 | } | |
587 | ||
588 | } | |
589 | ||
590 | function feedEditCancel() { | |
591 | ||
592 | if (!xmlhttp_ready(xmlhttp)) { | |
593 | printLockingError(); | |
594 | return | |
595 | } | |
596 | ||
597 | active_feed = false; | |
598 | ||
599 | notify("Operation cancelled."); | |
600 | ||
601 | xmlhttp.open("GET", "backend.php?op=pref-feeds", true); | |
602 | xmlhttp.onreadystatechange=feedlist_callback; | |
603 | xmlhttp.send(null); | |
604 | ||
605 | } | |
606 | ||
607 | function feedEditSave() { | |
608 | ||
609 | var feed = active_feed; | |
610 | ||
611 | if (!xmlhttp_ready(xmlhttp)) { | |
612 | printLockingError(); | |
613 | return | |
614 | } | |
615 | ||
616 | var link = document.getElementById("iedit_link").value; | |
617 | var title = document.getElementById("iedit_title").value; | |
618 | var upd_intl = document.getElementById("iedit_updintl").value; | |
619 | var purge_intl = document.getElementById("iedit_purgintl").value; | |
620 | ||
621 | // notify("Saving feed."); | |
622 | ||
623 | /* if (upd_intl < 0) { | |
624 | notify("Update interval must be >= 0 (0 = default)"); | |
625 | return; | |
626 | } | |
627 | ||
628 | if (purge_intl < 0) { | |
629 | notify("Purge days must be >= 0 (0 = default)"); | |
630 | return; | |
631 | } */ | |
632 | ||
633 | if (link.length == 0) { | |
634 | notify("Feed link cannot be blank."); | |
635 | return; | |
636 | } | |
637 | ||
638 | if (title.length == 0) { | |
639 | notify("Feed title cannot be blank."); | |
640 | return; | |
641 | } | |
642 | ||
643 | active_feed = false; | |
644 | ||
645 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" + | |
646 | feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) + | |
647 | "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true); | |
648 | xmlhttp.onreadystatechange=feedlist_callback; | |
649 | xmlhttp.send(null); | |
650 | ||
651 | } | |
652 | ||
653 | function labelEditCancel() { | |
654 | ||
655 | if (!xmlhttp_ready(xmlhttp)) { | |
656 | printLockingError(); | |
657 | return | |
658 | } | |
659 | ||
660 | active_label = false; | |
661 | ||
662 | notify("Operation cancelled."); | |
663 | ||
664 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
665 | xmlhttp.onreadystatechange=labellist_callback; | |
666 | xmlhttp.send(null); | |
667 | ||
668 | } | |
669 | ||
670 | function userEditCancel() { | |
671 | ||
672 | if (!xmlhttp_ready(xmlhttp)) { | |
673 | printLockingError(); | |
674 | return | |
675 | } | |
676 | ||
677 | active_user = false; | |
678 | ||
679 | notify("Operation cancelled."); | |
680 | ||
681 | xmlhttp.open("GET", "backend.php?op=pref-users", true); | |
682 | xmlhttp.onreadystatechange=userlist_callback; | |
683 | xmlhttp.send(null); | |
684 | ||
685 | } | |
686 | ||
687 | function filterEditCancel() { | |
688 | ||
689 | if (!xmlhttp_ready(xmlhttp)) { | |
690 | printLockingError(); | |
691 | return | |
692 | } | |
693 | ||
694 | active_filter = false; | |
695 | ||
696 | notify("Operation cancelled."); | |
697 | ||
698 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
699 | xmlhttp.onreadystatechange=filterlist_callback; | |
700 | xmlhttp.send(null); | |
701 | ||
702 | } | |
703 | ||
704 | function labelEditSave() { | |
705 | ||
706 | var label = active_label; | |
707 | ||
708 | if (!xmlhttp_ready(xmlhttp)) { | |
709 | printLockingError(); | |
710 | return | |
711 | } | |
712 | ||
713 | var sqlexp = document.getElementById("iedit_expr").value; | |
714 | var descr = document.getElementById("iedit_descr").value; | |
715 | ||
716 | // notify("Saving label " + sqlexp + ": " + descr); | |
717 | ||
718 | if (sqlexp.length == 0) { | |
719 | notify("SQL expression cannot be blank."); | |
720 | return; | |
721 | } | |
722 | ||
723 | if (descr.length == 0) { | |
724 | notify("Caption cannot be blank."); | |
725 | return; | |
726 | } | |
727 | ||
728 | active_label = false; | |
729 | ||
730 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" + | |
731 | label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr), | |
732 | true); | |
733 | ||
734 | xmlhttp.onreadystatechange=labellist_callback; | |
735 | xmlhttp.send(null); | |
736 | ||
737 | } | |
738 | ||
739 | function userEditSave() { | |
740 | ||
741 | var user = active_user; | |
742 | ||
743 | if (!xmlhttp_ready(xmlhttp)) { | |
744 | printLockingError(); | |
745 | return | |
746 | } | |
747 | ||
748 | var login = document.getElementById("iedit_ulogin").value; | |
749 | var level = document.getElementById("iedit_ulevel").value; | |
750 | ||
751 | if (login.length == 0) { | |
752 | notify("Login cannot be blank."); | |
753 | return; | |
754 | } | |
755 | ||
756 | if (level.length == 0) { | |
757 | notify("User level cannot be blank."); | |
758 | return; | |
759 | } | |
760 | ||
761 | active_user = false; | |
762 | ||
763 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" + | |
764 | user + "&l=" + param_escape(login) + "&al=" + param_escape(level), | |
765 | true); | |
766 | ||
767 | xmlhttp.onreadystatechange=labellist_callback; | |
768 | xmlhttp.send(null); | |
769 | ||
770 | } | |
771 | ||
772 | ||
773 | function filterEditSave() { | |
774 | ||
775 | var filter = active_filter; | |
776 | ||
777 | if (!xmlhttp_ready(xmlhttp)) { | |
778 | printLockingError(); | |
779 | return | |
780 | } | |
781 | ||
782 | var regexp = document.getElementById("iedit_regexp").value; | |
783 | var descr = document.getElementById("iedit_descr").value; | |
784 | var match = document.getElementById("iedit_match"); | |
785 | ||
786 | var v_match = match[match.selectedIndex].text; | |
787 | ||
788 | // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match); | |
789 | ||
790 | if (regexp.length == 0) { | |
791 | notify("Filter expression cannot be blank."); | |
792 | return; | |
793 | } | |
794 | ||
795 | active_filter = false; | |
796 | ||
797 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" + | |
798 | filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) + | |
799 | "&m=" + param_escape(v_match), true); | |
800 | ||
801 | xmlhttp.onreadystatechange=filterlist_callback; | |
802 | xmlhttp.send(null); | |
803 | ||
804 | } | |
805 | ||
806 | function editSelectedLabel() { | |
807 | var rows = getSelectedLabels(); | |
808 | ||
809 | if (rows.length == 0) { | |
810 | notify("No labels are selected."); | |
811 | return; | |
812 | } | |
813 | ||
814 | if (rows.length > 1) { | |
815 | notify("Please select one label."); | |
816 | return; | |
817 | } | |
818 | ||
819 | editLabel(rows[0]); | |
820 | ||
821 | } | |
822 | ||
823 | function editSelectedUser() { | |
824 | var rows = getSelectedUsers(); | |
825 | ||
826 | if (rows.length == 0) { | |
827 | notify("No users are selected."); | |
828 | return; | |
829 | } | |
830 | ||
831 | if (rows.length > 1) { | |
832 | notify("Please select one user."); | |
833 | return; | |
834 | } | |
835 | ||
836 | editUser(rows[0]); | |
837 | } | |
838 | ||
839 | function resetSelectedUserPass() { | |
840 | var rows = getSelectedUsers(); | |
841 | ||
842 | if (rows.length == 0) { | |
843 | notify("No users are selected."); | |
844 | return; | |
845 | } | |
846 | ||
847 | if (rows.length > 1) { | |
848 | notify("Please select one user."); | |
849 | return; | |
850 | } | |
851 | ||
852 | notify("Resetting password for selected user..."); | |
853 | ||
854 | var id = rows[0]; | |
855 | ||
856 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
857 | param_escape(id), true); | |
858 | xmlhttp.onreadystatechange=userlist_callback; | |
859 | xmlhttp.send(null); | |
860 | ||
861 | } | |
862 | ||
863 | function selectedUserDetails() { | |
864 | ||
865 | if (!xmlhttp_ready(xmlhttp)) { | |
866 | printLockingError(); | |
867 | return | |
868 | } | |
869 | ||
870 | var rows = getSelectedUsers(); | |
871 | ||
872 | if (rows.length == 0) { | |
873 | notify("No users are selected."); | |
874 | return; | |
875 | } | |
876 | ||
877 | if (rows.length > 1) { | |
878 | notify("Please select one user."); | |
879 | return; | |
880 | } | |
881 | ||
882 | var id = rows[0]; | |
883 | ||
884 | xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true); | |
885 | xmlhttp.onreadystatechange=infobox_callback; | |
886 | xmlhttp.send(null); | |
887 | ||
888 | } | |
889 | ||
890 | function selectedFeedDetails() { | |
891 | ||
892 | if (!xmlhttp_ready(xmlhttp)) { | |
893 | printLockingError(); | |
894 | return | |
895 | } | |
896 | ||
897 | var rows = getSelectedFeeds(); | |
898 | ||
899 | if (rows.length == 0) { | |
900 | notify("No feeds are selected."); | |
901 | return; | |
902 | } | |
903 | ||
904 | if (rows.length > 1) { | |
905 | notify("Please select one feed."); | |
906 | return; | |
907 | } | |
908 | ||
909 | var id = rows[0]; | |
910 | ||
911 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true); | |
912 | xmlhttp.onreadystatechange=infobox_callback; | |
913 | xmlhttp.send(null); | |
914 | ||
915 | } | |
916 | ||
917 | function editSelectedFilter() { | |
918 | var rows = getSelectedFilters(); | |
919 | ||
920 | if (rows.length == 0) { | |
921 | notify("No filters are selected."); | |
922 | return; | |
923 | } | |
924 | ||
925 | if (rows.length > 1) { | |
926 | notify("Please select one filter."); | |
927 | return; | |
928 | } | |
929 | ||
930 | editFilter(rows[0]); | |
931 | ||
932 | } | |
933 | ||
934 | ||
935 | function editSelectedFeed() { | |
936 | var rows = getSelectedFeeds(); | |
937 | ||
938 | if (rows.length == 0) { | |
939 | notify("No feeds are selected."); | |
940 | return; | |
941 | } | |
942 | ||
943 | if (rows.length > 1) { | |
944 | notify("Please select one feed."); | |
945 | return; | |
946 | } | |
947 | ||
948 | editFeed(rows[0]); | |
949 | ||
950 | } | |
951 | ||
952 | function localPiggieFunction(enable) { | |
953 | if (enable) { | |
954 | piggie.style.display = "block"; | |
955 | seq = ""; | |
956 | notify("I loveded it!!!"); | |
957 | } else { | |
958 | piggie.style.display = "none"; | |
959 | notify(""); | |
960 | } | |
961 | } | |
962 | ||
963 | function validateOpmlImport() { | |
964 | ||
965 | var opml_file = document.getElementById("opml_file"); | |
966 | ||
967 | if (opml_file.value.length == 0) { | |
968 | notify("Please select OPML file to upload."); | |
969 | return false; | |
970 | } else { | |
971 | return true; | |
972 | } | |
973 | } | |
974 | ||
975 | function updateFilterList() { | |
976 | ||
977 | if (!xmlhttp_ready(xmlhttp)) { | |
978 | printLockingError(); | |
979 | return | |
980 | } | |
981 | ||
982 | // document.getElementById("prefContent").innerHTML = "Loading filters, please wait..."; | |
983 | ||
984 | p_notify("Loading, please wait..."); | |
985 | ||
986 | xmlhttp.open("GET", "backend.php?op=pref-filters", true); | |
987 | xmlhttp.onreadystatechange=filterlist_callback; | |
988 | xmlhttp.send(null); | |
989 | ||
990 | } | |
991 | ||
992 | function updateLabelList() { | |
993 | ||
994 | if (!xmlhttp_ready(xmlhttp)) { | |
995 | printLockingError(); | |
996 | return | |
997 | } | |
998 | ||
999 | p_notify("Loading, please wait..."); | |
1000 | ||
1001 | // document.getElementById("prefContent").innerHTML = "Loading labels, please wait..."; | |
1002 | ||
1003 | xmlhttp.open("GET", "backend.php?op=pref-labels", true); | |
1004 | xmlhttp.onreadystatechange=labellist_callback; | |
1005 | xmlhttp.send(null); | |
1006 | } | |
1007 | ||
1008 | function updatePrefsList() { | |
1009 | ||
1010 | if (!xmlhttp_ready(xmlhttp)) { | |
1011 | printLockingError(); | |
1012 | return | |
1013 | } | |
1014 | ||
1015 | p_notify("Loading, please wait..."); | |
1016 | ||
1017 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); | |
1018 | xmlhttp.onreadystatechange=prefslist_callback; | |
1019 | xmlhttp.send(null); | |
1020 | ||
1021 | } | |
1022 | ||
1023 | function selectTab(id) { | |
1024 | ||
1025 | if (!xmlhttp_ready(xmlhttp)) { | |
1026 | printLockingError(); | |
1027 | return | |
1028 | } | |
1029 | ||
1030 | if (id == "feedConfig") { | |
1031 | updateFeedList(); | |
1032 | } else if (id == "filterConfig") { | |
1033 | updateFilterList(); | |
1034 | } else if (id == "labelConfig") { | |
1035 | updateLabelList(); | |
1036 | } else if (id == "genConfig") { | |
1037 | updatePrefsList(); | |
1038 | } else if (id == "userConfig") { | |
1039 | updateUsersList(); | |
1040 | } | |
1041 | ||
1042 | var tab = document.getElementById(active_tab + "Tab"); | |
1043 | ||
1044 | if (tab) { | |
1045 | if (tab.className.match("Selected")) { | |
1046 | tab.className = "prefsTab"; | |
1047 | } | |
1048 | } | |
1049 | ||
1050 | tab = document.getElementById(id + "Tab"); | |
1051 | ||
1052 | if (tab) { | |
1053 | if (!tab.className.match("Selected")) { | |
1054 | tab.className = tab.className + "Selected"; | |
1055 | } | |
1056 | } | |
1057 | ||
1058 | active_tab = id; | |
1059 | ||
1060 | } | |
1061 | ||
1062 | function init() { | |
1063 | ||
1064 | // IE kludge | |
1065 | ||
1066 | if (!xmlhttp) { | |
1067 | document.getElementById("prefContent").innerHTML = | |
1068 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1069 | "to function properly. Your browser doesn't seem to support it."; | |
1070 | return; | |
1071 | } | |
1072 | ||
1073 | selectTab("genConfig"); | |
1074 | ||
1075 | document.onkeydown = hotkey_handler; | |
1076 | notify(""); | |
1077 | ||
1078 | } | |
1079 | ||
1080 | /* | |
1081 | var help_topic_id = false; | |
1082 | ||
1083 | function do_dispOptionHelp() { | |
1084 | ||
1085 | if (!xmlhttp_ready(xmlhttp)) | |
1086 | return; | |
1087 | ||
1088 | xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" + | |
1089 | param_escape(help_topic_id), true); | |
1090 | xmlhttp.onreadystatechange=gethelp_callback; | |
1091 | xmlhttp.send(null); | |
1092 | ||
1093 | } | |
1094 | ||
1095 | function dispOptionHelp(event, sender) { | |
1096 | ||
1097 | help_topic_id = sender.id; | |
1098 | ||
1099 | // document.setTimeout("do_dispOptionHelp()", 100); | |
1100 | ||
1101 | } */ | |
1102 | ||
1103 | function closeInfoBox() { | |
1104 | var d = document.getElementById('infoBox'); | |
1105 | d.style.display = "none"; | |
1106 | } |