]> git.wh0rd.org - tt-rss.git/blame - prefs.js
fix show only unread in feed actions
[tt-rss.git] / prefs.js
CommitLineData
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
6var xmlhttp = false;
7
961513a3 8var active_feed = false;
a0d53889 9var active_filter = false;
48f0adb0 10var active_label = false;
e6cb77a0 11var active_user = false;
961513a3 12
f5a50b25
AD
13var active_tab = false;
14
007bda35
AD
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.
19try {
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
30if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
31 xmlhttp = new XMLHttpRequest();
32}
33
007bda35 34function feedlist_callback() {
f5a50b25 35 var container = document.getElementById('prefContent');
007bda35
AD
36 if (xmlhttp.readyState == 4) {
37 container.innerHTML=xmlhttp.responseText;
961513a3
AD
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 }
f5a50b25 50 p_notify("");
007bda35
AD
51 }
52}
53
a0d53889 54function filterlist_callback() {
f5a50b25 55 var container = document.getElementById('prefContent');
a0d53889 56 if (xmlhttp.readyState == 4) {
f5a50b25 57
a0d53889
AD
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 }
f5a50b25 73 p_notify("");
a0d53889
AD
74 }
75}
76
48f0adb0 77function labellist_callback() {
f5a50b25 78 var container = document.getElementById('prefContent');
48f0adb0
AD
79 if (xmlhttp.readyState == 4) {
80 container.innerHTML=xmlhttp.responseText;
81
967955b7 82 if (active_label) {
48f0adb0
AD
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 }
f5a50b25 95 p_notify("");
48f0adb0
AD
96 }
97}
4255b24c 98
e6cb77a0
AD
99function userlist_callback() {
100 var container = document.getElementById('prefContent');
101 if (xmlhttp.readyState == 4) {
102 container.innerHTML=xmlhttp.responseText;
103
1a7572cb
AD
104 if (active_user) {
105 var row = document.getElementById("UMRR-" + active_user);
e6cb77a0
AD
106 if (row) {
107 if (!row.className.match("Selected")) {
108 row.className = row.className + "Selected";
109 }
110 }
1a7572cb 111 var checkbox = document.getElementById("UMCHK-" + active_user);
e6cb77a0
AD
112
113 if (checkbox) {
114 checkbox.checked = true;
115 }
1a7572cb
AD
116 }
117
e6cb77a0
AD
118 p_notify("");
119 }
120}
121
c6c3a07f
AD
122function infobox_callback() {
123 var container = document.getElementById('infoBox');
1a7572cb 124 if (xmlhttp.readyState == 4) {
c6c3a07f
AD
125 if (container) {
126 container.innerHTML=xmlhttp.responseText;
127 container.style.display = "block";
128 }
1a7572cb
AD
129 }
130}
131
132
4255b24c
AD
133function 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
b1895692
AD
143function 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}
4255b24c
AD
152
153
0e091d38
AD
154function notify_callback() {
155 var container = document.getElementById('notify');
156 if (xmlhttp.readyState == 4) {
157 container.innerHTML=xmlhttp.responseText;
158 }
159}
160
175847de 161
0e091d38 162function updateFeedList() {
007bda35 163
c0e5a40e 164 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
165 printLockingError();
166 return
167 }
168
f5a50b25
AD
169// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
170
171 p_notify("Loading, please wait...");
007bda35
AD
172
173 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
174 xmlhttp.onreadystatechange=feedlist_callback;
175 xmlhttp.send(null);
176
177}
178
e6cb77a0
AD
179function 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
007bda35
AD
196function 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
48f0adb0
AD
210function 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
de435974
AD
235function 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
25cb5736
AD
250 var v_match = match[match.selectedIndex].text;
251
de435974 252 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
25cb5736 253 param_escape(regexp.value) + "&match=" + v_match, true);
de435974
AD
254
255 xmlhttp.onreadystatechange=filterlist_callback;
256 xmlhttp.send(null);
257
258 regexp.value = "";
259 }
260
261}
48f0adb0 262
71ad3959
AD
263function addFeed() {
264
c0e5a40e 265 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
266 printLockingError();
267 return
268 }
269
331900c6
AD
270 var link = document.getElementById("fadd_link");
271
83fe4d6d 272 if (link.value.length == 0) {
c753cd32 273 notify("Missing feed URL.");
331900c6
AD
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
e6cb77a0
AD
288function 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
48f0adb0
AD
313function 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
e6cb77a0
AD
329function 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
a0d53889
AD
345function 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
331900c6
AD
361function editFeed(feed) {
362
508a81e1
AD
363// notify("Editing feed...");
364
c0e5a40e 365 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
366 printLockingError();
367 return
368 }
331900c6 369
961513a3
AD
370 active_feed = feed;
371
331900c6
AD
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
48f0adb0
AD
379function 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
e6cb77a0
AD
395function 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
48f0adb0 411
a0d53889
AD
412function 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
83fe4d6d 428function getSelectedFeeds() {
331900c6
AD
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
83fe4d6d
AD
441 return sel_rows;
442}
443
444function readSelectedFeeds() {
445
c0e5a40e 446 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
447 printLockingError();
448 return
449 }
450
83fe4d6d
AD
451 var sel_rows = getSelectedFeeds();
452
453 if (sel_rows.length > 0) {
454
455 notify("Marking selected feeds as read...");
456
0e091d38 457 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
83fe4d6d 458 param_escape(sel_rows.toString()), true);
0e091d38 459 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
460 xmlhttp.send(null);
461
462 } else {
463
c753cd32 464 notify("Please select some feeds first.");
83fe4d6d
AD
465
466 }
467}
468
469function unreadSelectedFeeds() {
470
c0e5a40e 471 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
472 printLockingError();
473 return
474 }
475
83fe4d6d
AD
476 var sel_rows = getSelectedFeeds();
477
478 if (sel_rows.length > 0) {
479
480 notify("Marking selected feeds as unread...");
481
0e091d38 482 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
83fe4d6d 483 param_escape(sel_rows.toString()), true);
0e091d38 484 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
485 xmlhttp.send(null);
486
487 } else {
488
c753cd32 489 notify("Please select some feeds first.");
83fe4d6d
AD
490
491 }
492}
493
48f0adb0
AD
494function 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
e6cb77a0
AD
517function 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
48f0adb0
AD
540function 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
83fe4d6d
AD
564function removeSelectedFeeds() {
565
c0e5a40e 566 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
567 printLockingError();
568 return
569 }
570
83fe4d6d
AD
571 var sel_rows = getSelectedFeeds();
572
331900c6
AD
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);
71ad3959 581
71ad3959 582 } else {
331900c6 583
c753cd32 584 notify("Please select some feeds first.");
331900c6 585
71ad3959
AD
586 }
587
588}
007bda35 589
508a81e1
AD
590function feedEditCancel() {
591
c0e5a40e 592 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
593 printLockingError();
594 return
595 }
596
961513a3
AD
597 active_feed = false;
598
508a81e1
AD
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
603c27f8
AD
607function feedEditSave() {
608
609 var feed = active_feed;
508a81e1 610
c0e5a40e 611 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
612 printLockingError();
613 return
614 }
615
603c27f8
AD
616 var link = document.getElementById("iedit_link").value;
617 var title = document.getElementById("iedit_title").value;
d148926e 618 var upd_intl = document.getElementById("iedit_updintl").value;
5d73494a 619 var purge_intl = document.getElementById("iedit_purgintl").value;
508a81e1 620
603c27f8 621// notify("Saving feed.");
508a81e1 622
140aae81 623/* if (upd_intl < 0) {
d148926e
AD
624 notify("Update interval must be &gt;= 0 (0 = default)");
625 return;
626 }
627
5d73494a
AD
628 if (purge_intl < 0) {
629 notify("Purge days must be &gt;= 0 (0 = default)");
630 return;
140aae81 631 } */
d148926e 632
508a81e1
AD
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
603c27f8
AD
643 active_feed = false;
644
dbd9e2f1
AD
645 notify("");
646
508a81e1 647 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
d148926e 648 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
5d73494a 649 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
508a81e1
AD
650 xmlhttp.onreadystatechange=feedlist_callback;
651 xmlhttp.send(null);
652
653}
654
48f0adb0
AD
655function labelEditCancel() {
656
657 if (!xmlhttp_ready(xmlhttp)) {
658 printLockingError();
659 return
660 }
661
662 active_label = false;
663
664 notify("Operation cancelled.");
665
666 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
667 xmlhttp.onreadystatechange=labellist_callback;
668 xmlhttp.send(null);
669
670}
671
e6cb77a0
AD
672function userEditCancel() {
673
674 if (!xmlhttp_ready(xmlhttp)) {
675 printLockingError();
676 return
677 }
678
679 active_user = false;
680
681 notify("Operation cancelled.");
682
683 xmlhttp.open("GET", "backend.php?op=pref-users", true);
684 xmlhttp.onreadystatechange=userlist_callback;
685 xmlhttp.send(null);
686
687}
48f0adb0 688
a0d53889
AD
689function filterEditCancel() {
690
691 if (!xmlhttp_ready(xmlhttp)) {
692 printLockingError();
693 return
694 }
695
696 active_filter = false;
697
698 notify("Operation cancelled.");
699
700 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
701 xmlhttp.onreadystatechange=filterlist_callback;
702 xmlhttp.send(null);
703
704}
705
48f0adb0
AD
706function labelEditSave() {
707
708 var label = active_label;
709
710 if (!xmlhttp_ready(xmlhttp)) {
711 printLockingError();
712 return
713 }
714
715 var sqlexp = document.getElementById("iedit_expr").value;
716 var descr = document.getElementById("iedit_descr").value;
717
718// notify("Saving label " + sqlexp + ": " + descr);
719
720 if (sqlexp.length == 0) {
721 notify("SQL expression cannot be blank.");
722 return;
723 }
724
725 if (descr.length == 0) {
726 notify("Caption cannot be blank.");
727 return;
728 }
729
dbd9e2f1
AD
730 notify("");
731
48f0adb0
AD
732 active_label = false;
733
734 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
735 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
736 true);
737
738 xmlhttp.onreadystatechange=labellist_callback;
739 xmlhttp.send(null);
740
741}
742
e6cb77a0
AD
743function userEditSave() {
744
745 var user = active_user;
746
747 if (!xmlhttp_ready(xmlhttp)) {
748 printLockingError();
749 return
750 }
751
752 var login = document.getElementById("iedit_ulogin").value;
753 var level = document.getElementById("iedit_ulevel").value;
754
755 if (login.length == 0) {
756 notify("Login cannot be blank.");
757 return;
758 }
759
760 if (level.length == 0) {
761 notify("User level cannot be blank.");
762 return;
763 }
764
765 active_user = false;
766
dbd9e2f1
AD
767 notify("");
768
e6cb77a0
AD
769 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
770 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
771 true);
772
dbd9e2f1 773 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0
AD
774 xmlhttp.send(null);
775
776}
777
778
a0d53889
AD
779function filterEditSave() {
780
781 var filter = active_filter;
782
783 if (!xmlhttp_ready(xmlhttp)) {
784 printLockingError();
785 return
786 }
787
788 var regexp = document.getElementById("iedit_regexp").value;
789 var descr = document.getElementById("iedit_descr").value;
25cb5736
AD
790 var match = document.getElementById("iedit_match");
791
792 var v_match = match[match.selectedIndex].text;
a0d53889
AD
793
794// notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
795
796 if (regexp.length == 0) {
797 notify("Filter expression cannot be blank.");
798 return;
799 }
800
801 active_filter = false;
802
803 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
804 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
25cb5736 805 "&m=" + param_escape(v_match), true);
dbd9e2f1
AD
806
807 notify("");
808
a0d53889
AD
809 xmlhttp.onreadystatechange=filterlist_callback;
810 xmlhttp.send(null);
811
812}
813
48f0adb0
AD
814function editSelectedLabel() {
815 var rows = getSelectedLabels();
a0d53889 816
48f0adb0
AD
817 if (rows.length == 0) {
818 notify("No labels are selected.");
819 return;
a0d53889
AD
820 }
821
48f0adb0
AD
822 if (rows.length > 1) {
823 notify("Please select one label.");
824 return;
825 }
a0d53889 826
dbd9e2f1
AD
827 notify("");
828
48f0adb0 829 editLabel(rows[0]);
a0d53889 830
a0d53889
AD
831}
832
e6cb77a0
AD
833function editSelectedUser() {
834 var rows = getSelectedUsers();
835
836 if (rows.length == 0) {
837 notify("No users are selected.");
838 return;
839 }
840
841 if (rows.length > 1) {
842 notify("Please select one user.");
843 return;
844 }
845
dbd9e2f1
AD
846 notify("");
847
e6cb77a0
AD
848 editUser(rows[0]);
849}
850
851function resetSelectedUserPass() {
852 var rows = getSelectedUsers();
853
854 if (rows.length == 0) {
855 notify("No users are selected.");
856 return;
857 }
858
859 if (rows.length > 1) {
860 notify("Please select one user.");
861 return;
862 }
863
864 notify("Resetting password for selected user...");
865
866 var id = rows[0];
867
868 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
869 param_escape(id), true);
870 xmlhttp.onreadystatechange=userlist_callback;
871 xmlhttp.send(null);
872
873}
874
717f5e64 875function selectedUserDetails() {
e6cb77a0 876
1a7572cb
AD
877 if (!xmlhttp_ready(xmlhttp)) {
878 printLockingError();
879 return
880 }
881
717f5e64
AD
882 var rows = getSelectedUsers();
883
884 if (rows.length == 0) {
885 notify("No users are selected.");
886 return;
887 }
888
889 if (rows.length > 1) {
890 notify("Please select one user.");
891 return;
892 }
893
894 var id = rows[0];
895
dbd9e2f1
AD
896 notify("");
897
1a7572cb 898 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
899 xmlhttp.onreadystatechange=infobox_callback;
900 xmlhttp.send(null);
901
902}
903
904function selectedFeedDetails() {
905
906 if (!xmlhttp_ready(xmlhttp)) {
907 printLockingError();
908 return
909 }
910
911 var rows = getSelectedFeeds();
912
913 if (rows.length == 0) {
914 notify("No feeds are selected.");
915 return;
916 }
917
918 if (rows.length > 1) {
919 notify("Please select one feed.");
920 return;
921 }
922
923 var id = rows[0];
924
dbd9e2f1
AD
925 notify("");
926
c6c3a07f
AD
927 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
928 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 929 xmlhttp.send(null);
717f5e64
AD
930
931}
a0d53889
AD
932
933function editSelectedFilter() {
934 var rows = getSelectedFilters();
935
936 if (rows.length == 0) {
937 notify("No filters are selected.");
938 return;
939 }
940
941 if (rows.length > 1) {
942 notify("Please select one filter.");
943 return;
944 }
945
dbd9e2f1
AD
946 notify("");
947
a0d53889
AD
948 editFilter(rows[0]);
949
950}
951
952
508a81e1
AD
953function editSelectedFeed() {
954 var rows = getSelectedFeeds();
955
956 if (rows.length == 0) {
957 notify("No feeds are selected.");
958 return;
959 }
960
961 if (rows.length > 1) {
962 notify("Please select one feed.");
963 return;
964 }
965
dbd9e2f1
AD
966 notify("");
967
508a81e1
AD
968 editFeed(rows[0]);
969
970}
971
13ad9102
AD
972function localPiggieFunction(enable) {
973 if (enable) {
508a81e1
AD
974 piggie.style.display = "block";
975 seq = "";
976 notify("I loveded it!!!");
977 } else {
978 piggie.style.display = "none";
979 notify("");
980 }
508a81e1
AD
981}
982
9f311df6
AD
983function validateOpmlImport() {
984
985 var opml_file = document.getElementById("opml_file");
986
987 if (opml_file.value.length == 0) {
988 notify("Please select OPML file to upload.");
989 return false;
990 } else {
991 return true;
992 }
993}
994
a0d53889
AD
995function updateFilterList() {
996
997 if (!xmlhttp_ready(xmlhttp)) {
998 printLockingError();
999 return
1000 }
1001
f5a50b25
AD
1002// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1003
1004 p_notify("Loading, please wait...");
a0d53889
AD
1005
1006 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1007 xmlhttp.onreadystatechange=filterlist_callback;
1008 xmlhttp.send(null);
1009
1010}
1011
48f0adb0
AD
1012function updateLabelList() {
1013
1014 if (!xmlhttp_ready(xmlhttp)) {
1015 printLockingError();
1016 return
1017 }
1018
f5a50b25
AD
1019 p_notify("Loading, please wait...");
1020
1021// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1022
1023 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1024 xmlhttp.onreadystatechange=labellist_callback;
1025 xmlhttp.send(null);
48f0adb0
AD
1026}
1027
4255b24c
AD
1028function updatePrefsList() {
1029
1030 if (!xmlhttp_ready(xmlhttp)) {
1031 printLockingError();
1032 return
1033 }
1034
1035 p_notify("Loading, please wait...");
1036
1037 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1038 xmlhttp.onreadystatechange=prefslist_callback;
1039 xmlhttp.send(null);
1040
1041}
1042
f5a50b25 1043function selectTab(id) {
48f0adb0 1044
c6c3a07f
AD
1045 if (!xmlhttp_ready(xmlhttp)) {
1046 printLockingError();
1047 return
1048 }
1049
f5a50b25 1050 if (id == "feedConfig") {
a0d53889 1051 updateFeedList();
f5a50b25 1052 } else if (id == "filterConfig") {
a0d53889 1053 updateFilterList();
f5a50b25 1054 } else if (id == "labelConfig") {
48f0adb0 1055 updateLabelList();
4255b24c
AD
1056 } else if (id == "genConfig") {
1057 updatePrefsList();
e6cb77a0
AD
1058 } else if (id == "userConfig") {
1059 updateUsersList();
a0d53889 1060 }
f5a50b25
AD
1061
1062 var tab = document.getElementById(active_tab + "Tab");
1063
1064 if (tab) {
1065 if (tab.className.match("Selected")) {
1066 tab.className = "prefsTab";
1067 }
1068 }
1069
1070 tab = document.getElementById(id + "Tab");
1071
1072 if (tab) {
1073 if (!tab.className.match("Selected")) {
1074 tab.className = tab.className + "Selected";
1075 }
1076 }
1077
1078 active_tab = id;
1079
a0d53889
AD
1080}
1081
007bda35 1082function init() {
e2ec66a8
AD
1083
1084 // IE kludge
1085
ad095c16 1086 if (!xmlhttp) {
e2ec66a8
AD
1087 document.getElementById("prefContent").innerHTML =
1088 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1089 "to function properly. Your browser doesn't seem to support it.";
1090 return;
1091 }
1092
77e96719 1093 selectTab("genConfig");
f5a50b25 1094
508a81e1 1095 document.onkeydown = hotkey_handler;
857a9270
AD
1096 notify("");
1097
007bda35 1098}
b1895692
AD
1099
1100/*
1101var help_topic_id = false;
1102
1103function do_dispOptionHelp() {
1104
1105 if (!xmlhttp_ready(xmlhttp))
1106 return;
1107
1108 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1109 param_escape(help_topic_id), true);
1110 xmlhttp.onreadystatechange=gethelp_callback;
1111 xmlhttp.send(null);
1112
1113}
1114
1115function dispOptionHelp(event, sender) {
1116
1117 help_topic_id = sender.id;
1118
1119// document.setTimeout("do_dispOptionHelp()", 100);
1120
1121} */
1122
c6c3a07f
AD
1123function closeInfoBox() {
1124 var d = document.getElementById('infoBox');
1a7572cb
AD
1125 d.style.display = "none";
1126}