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