]> git.wh0rd.org - tt-rss.git/blame - prefs.js
handle site_url in ttrss_feeds (and display in feed details)
[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
508a81e1 645 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
d148926e 646 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
5d73494a 647 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
508a81e1
AD
648 xmlhttp.onreadystatechange=feedlist_callback;
649 xmlhttp.send(null);
650
651}
652
48f0adb0
AD
653function 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
e6cb77a0
AD
670function 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}
48f0adb0 686
a0d53889
AD
687function 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
48f0adb0
AD
704function 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
e6cb77a0
AD
739function 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
a0d53889
AD
773function 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;
25cb5736
AD
784 var match = document.getElementById("iedit_match");
785
786 var v_match = match[match.selectedIndex].text;
a0d53889
AD
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) +
25cb5736 799 "&m=" + param_escape(v_match), true);
a0d53889
AD
800
801 xmlhttp.onreadystatechange=filterlist_callback;
802 xmlhttp.send(null);
803
804}
805
48f0adb0
AD
806function editSelectedLabel() {
807 var rows = getSelectedLabels();
a0d53889 808
48f0adb0
AD
809 if (rows.length == 0) {
810 notify("No labels are selected.");
811 return;
a0d53889
AD
812 }
813
48f0adb0
AD
814 if (rows.length > 1) {
815 notify("Please select one label.");
816 return;
817 }
a0d53889 818
48f0adb0 819 editLabel(rows[0]);
a0d53889 820
a0d53889
AD
821}
822
e6cb77a0
AD
823function 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
839function 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
717f5e64 863function selectedUserDetails() {
e6cb77a0 864
1a7572cb
AD
865 if (!xmlhttp_ready(xmlhttp)) {
866 printLockingError();
867 return
868 }
869
717f5e64
AD
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
1a7572cb 884 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
885 xmlhttp.onreadystatechange=infobox_callback;
886 xmlhttp.send(null);
887
888}
889
890function 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;
1a7572cb 913 xmlhttp.send(null);
717f5e64
AD
914
915}
a0d53889
AD
916
917function 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
508a81e1
AD
935function 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
13ad9102
AD
952function localPiggieFunction(enable) {
953 if (enable) {
508a81e1
AD
954 piggie.style.display = "block";
955 seq = "";
956 notify("I loveded it!!!");
957 } else {
958 piggie.style.display = "none";
959 notify("");
960 }
508a81e1
AD
961}
962
9f311df6
AD
963function 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
a0d53889
AD
975function updateFilterList() {
976
977 if (!xmlhttp_ready(xmlhttp)) {
978 printLockingError();
979 return
980 }
981
f5a50b25
AD
982// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
983
984 p_notify("Loading, please wait...");
a0d53889
AD
985
986 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
987 xmlhttp.onreadystatechange=filterlist_callback;
988 xmlhttp.send(null);
989
990}
991
48f0adb0
AD
992function updateLabelList() {
993
994 if (!xmlhttp_ready(xmlhttp)) {
995 printLockingError();
996 return
997 }
998
f5a50b25
AD
999 p_notify("Loading, please wait...");
1000
1001// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1002
1003 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1004 xmlhttp.onreadystatechange=labellist_callback;
1005 xmlhttp.send(null);
48f0adb0
AD
1006}
1007
4255b24c
AD
1008function 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
f5a50b25 1023function selectTab(id) {
48f0adb0 1024
c6c3a07f
AD
1025 if (!xmlhttp_ready(xmlhttp)) {
1026 printLockingError();
1027 return
1028 }
1029
f5a50b25 1030 if (id == "feedConfig") {
a0d53889 1031 updateFeedList();
f5a50b25 1032 } else if (id == "filterConfig") {
a0d53889 1033 updateFilterList();
f5a50b25 1034 } else if (id == "labelConfig") {
48f0adb0 1035 updateLabelList();
4255b24c
AD
1036 } else if (id == "genConfig") {
1037 updatePrefsList();
e6cb77a0
AD
1038 } else if (id == "userConfig") {
1039 updateUsersList();
a0d53889 1040 }
f5a50b25
AD
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
a0d53889
AD
1060}
1061
007bda35 1062function init() {
e2ec66a8
AD
1063
1064 // IE kludge
1065
ad095c16 1066 if (!xmlhttp) {
e2ec66a8
AD
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
77e96719 1073 selectTab("genConfig");
f5a50b25 1074
508a81e1 1075 document.onkeydown = hotkey_handler;
857a9270
AD
1076 notify("");
1077
007bda35 1078}
b1895692
AD
1079
1080/*
1081var help_topic_id = false;
1082
1083function 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
1095function dispOptionHelp(event, sender) {
1096
1097 help_topic_id = sender.id;
1098
1099// document.setTimeout("do_dispOptionHelp()", 100);
1100
1101} */
1102
c6c3a07f
AD
1103function closeInfoBox() {
1104 var d = document.getElementById('infoBox');
1a7572cb
AD
1105 d.style.display = "none";
1106}