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