]> git.wh0rd.org - tt-rss.git/blame - js/prefs.js
simplify filter overview
[tt-rss.git] / js / prefs.js
CommitLineData
a7565293
AD
1var init_params = new Array();
2
746dcf42 3var hotkey_prefix = false;
78935092 4var hotkey_prefix_pressed = false;
7a09510c 5
a998dbef
AD
6var seq = "";
7
66665fba
AD
8function notify_callback2(transport, sticky) {
9 notify_info(transport.responseText, sticky);
60715b53
AD
10}
11
b83c7545 12function updateFeedList(sort_key) {
16270276
AD
13
14 var user_search = $("feed_search");
15 var search = "";
16 if (user_search) { search = user_search.value; }
17
b4e75b2a 18 new Ajax.Request("backend.php", {
16270276 19 parameters: "?op=pref-feeds&search=" + param_escape(search),
fb5662de 20 onComplete: function(transport) {
cbe50c80
AD
21 dijit.byId('feedConfigTab').attr('content', transport.responseText);
22 selectTab("feedConfig", true);
23 notify("");
60715b53 24 } });
007bda35
AD
25}
26
373266eb 27
79ec0f2f 28function updateUsersList(sort_key) {
fbf7d545 29 try {
acac8448 30 var user_search = $("user_search");
fbf7d545
AD
31 var search = "";
32 if (user_search) { search = user_search.value; }
fb5662de 33
b4e75b2a 34 var query = "?op=pref-users&sort="
fbf7d545
AD
35 + param_escape(sort_key) +
36 "&search=" + param_escape(search);
fb5662de 37
b4e75b2a
AD
38 new Ajax.Request("backend.php", {
39 parameters: query,
fb5662de 40 onComplete: function(transport) {
66665fba
AD
41 dijit.byId('userConfigTab').attr('content', transport.responseText);
42 selectTab("userConfig", true)
43 notify("");
fbf7d545 44 } });
e6cb77a0 45
fbf7d545
AD
46 } catch (e) {
47 exception_error("updateUsersList", e);
48 }
e6cb77a0
AD
49}
50
e6cb77a0
AD
51function addUser() {
52
fbf7d545 53 try {
e6cb77a0 54
eb70b777 55 var login = prompt(__("Please enter login:"), "");
fb5662de
AD
56
57 if (login == null) {
eb70b777
AD
58 return false;
59 }
fb5662de 60
eb70b777
AD
61 if (login == "") {
62 alert(__("Can't create user: no login specified."));
63 return false;
fbf7d545 64 }
fb5662de 65
eb70b777 66 notify_progress("Adding user...");
fb5662de 67
f30ef1fa 68 var query = "?op=pref-users&method=add&login=" +
eb70b777 69 param_escape(login);
fb5662de 70
b4e75b2a
AD
71 new Ajax.Request("backend.php", {
72 parameters: query,
fb5662de 73 onComplete: function(transport) {
66665fba
AD
74 notify_callback2(transport);
75 updateUsersList();
eb70b777 76 } });
e6cb77a0 77
fbf7d545
AD
78 } catch (e) {
79 exception_error("addUser", e);
e6cb77a0 80 }
e6cb77a0
AD
81}
82
a998dbef 83function editUser(id, event) {
e6cb77a0 84
163723c4 85 try {
163723c4 86 notify_progress("Loading, please wait...");
9e31e1b9 87
f30ef1fa 88 var query = "?op=pref-users&method=edit&id=" +
163723c4
AD
89 param_escape(id);
90
b4e75b2a
AD
91 new Ajax.Request("backend.php", {
92 parameters: query,
163723c4
AD
93 onComplete: function(transport) {
94 infobox_callback2(transport);
fb5662de 95 document.forms['user_edit_form'].login.focus();
163723c4 96 } });
e6cb77a0 97
163723c4
AD
98 } catch (e) {
99 exception_error("editUser", e);
100 }
fb5662de 101
e6cb77a0
AD
102}
103
8a097fa3 104function editFilter(id) {
163723c4 105 try {
a0d53889 106
f30ef1fa 107 var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
4cd30111
AD
108
109 if (dijit.byId("feedEditDlg"))
110 dijit.byId("feedEditDlg").destroyRecursive();
6068d33b 111
d90868d7
AD
112 if (dijit.byId("filterEditDlg"))
113 dijit.byId("filterEditDlg").destroyRecursive();
114
115 dialog = new dijit.Dialog({
116 id: "filterEditDlg",
117 title: __("Edit Filter"),
118 style: "width: 600px",
4e02f582
AD
119 test: function() {
120 var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
121
122 if (dijit.byId("filterTestDlg"))
123 dijit.byId("filterTestDlg").destroyRecursive();
124
125 var test_dlg = new dijit.Dialog({
126 id: "filterTestDlg",
127 title: "Test Filter",
128 style: "width: 600px",
129 href: query});
130
131 test_dlg.show();
132 },
ec630524
AD
133 selectRules: function(select) {
134 $$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
135 e.checked = select;
136 if (select)
137 e.parentNode.addClassName("Selected");
138 else
139 e.parentNode.removeClassName("Selected");
140 });
141 },
142 selectActions: function(select) {
143 $$("#filterDlg_Actions input[type=checkbox]").each(function(e) {
144 e.checked = select;
145
146 if (select)
147 e.parentNode.addClassName("Selected");
148 else
149 e.parentNode.removeClassName("Selected");
150
151 });
152 },
6aff7845
AD
153 editRule: function(e) {
154 var li = e.parentNode;
155 var rule = li.getElementsByTagName("INPUT")[1].value;
156 addFilterRule(li, rule);
157 },
158 editAction: function(e) {
159 var li = e.parentNode;
160 var action = li.getElementsByTagName("INPUT")[1].value;
161 addFilterAction(li, action);
162 },
90e4e726 163 removeFilter: function() {
6aff7845 164 var msg = __("Remove filter?");
fb5662de 165
90e4e726
AD
166 if (confirm(msg)) {
167 this.hide();
168
169 notify_progress("Removing filter...");
fb5662de 170
90e4e726
AD
171 var id = this.attr('value').id;
172
f30ef1fa 173 var query = "?op=pref-filters&method=remove&ids="+
90e4e726
AD
174 param_escape(id);
175
176 new Ajax.Request("backend.php", {
177 parameters: query,
178 onComplete: function(transport) {
179 updateFilterList();
180 } });
181 }
182 },
6aff7845
AD
183 addAction: function() { addFilterAction(); },
184 addRule: function() { addFilterRule(); },
185 deleteAction: function() {
186 $$("#filterDlg_Actions li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
187 },
188 deleteRule: function() {
189 $$("#filterDlg_Matches li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
5593784a 190 },
d90868d7
AD
191 execute: function() {
192 if (this.validate()) {
141fb6e3 193
6aff7845 194 notify_progress("Saving data...", true);
141fb6e3 195
6aff7845 196 var query = dojo.formToQuery("filter_edit_form");
141fb6e3 197
6aff7845
AD
198 console.log(query);
199
200 new Ajax.Request("backend.php", {
141fb6e3 201 parameters: query,
d90868d7 202 onComplete: function(transport) {
6aff7845
AD
203 dialog.hide();
204 updateFilterList();
205 }});
d90868d7
AD
206 }
207 },
208 href: query});
209
210 dialog.show();
a998dbef 211
a0d53889 212
163723c4
AD
213 } catch (e) {
214 exception_error("editFilter", e);
215 }
a0d53889
AD
216}
217
91ff844a 218function getSelectedLabels() {
fb8b2153
AD
219 var tree = dijit.byId("labelTree");
220 var items = tree.model.getCheckedItems();
221 var rv = [];
222
223 items.each(function(item) {
224 rv.push(tree.model.store.getValue(item, 'bare_id'));
225 });
226
227 return rv;
91ff844a 228}
48f0adb0 229
91ff844a 230function getSelectedUsers() {
e69fb880 231 return getSelectedTableRowIds("prefUserList");
a0d53889
AD
232}
233
83fe4d6d 234function getSelectedFeeds() {
1985a5e0
AD
235 var tree = dijit.byId("feedTree");
236 var items = tree.model.getCheckedItems();
237 var rv = [];
238
239 items.each(function(item) {
7c227bb3
AD
240 if (item.id[0].match("FEED:"))
241 rv.push(tree.model.store.getValue(item, 'bare_id'));
1985a5e0
AD
242 });
243
244 return rv;
91ff844a 245}
331900c6 246
fd26d5bf
AD
247function getSelectedCategories() {
248 var tree = dijit.byId("feedTree");
249 var items = tree.model.getCheckedItems();
250 var rv = [];
251
252 items.each(function(item) {
253 if (item.id[0].match("CAT:"))
254 rv.push(tree.model.store.getValue(item, 'bare_id'));
255 });
256
257 return rv;
258}
259
91ff844a 260function getSelectedFilters() {
a740f4b5
AD
261 var tree = dijit.byId("filterTree");
262 var items = tree.model.getCheckedItems();
263 var rv = [];
264
265 items.each(function(item) {
266 rv.push(tree.model.store.getValue(item, 'bare_id'));
267 });
268
269 return rv;
270
91ff844a 271}
331900c6 272
48f0adb0
AD
273function removeSelectedLabels() {
274
48f0adb0
AD
275 var sel_rows = getSelectedLabels();
276
277 if (sel_rows.length > 0) {
278
f56e3080 279 var ok = confirm(__("Remove selected labels?"));
48f0adb0 280
69668465 281 if (ok) {
42c32916 282 notify_progress("Removing selected labels...");
fb5662de 283
f30ef1fa 284 var query = "?op=pref-labels&method=remove&ids="+
a796bfc1
AD
285 param_escape(sel_rows.toString());
286
b4e75b2a
AD
287 new Ajax.Request("backend.php", {
288 parameters: query,
a796bfc1 289 onComplete: function(transport) {
cbe50c80 290 updateLabelList();
a796bfc1
AD
291 } });
292
69668465 293 }
48f0adb0 294 } else {
89cb787e 295 alert(__("No labels are selected."));
48f0adb0 296 }
90ac84df
AD
297
298 return false;
48f0adb0
AD
299}
300
e6cb77a0
AD
301function removeSelectedUsers() {
302
fbf7d545 303 try {
e6cb77a0 304
fbf7d545 305 var sel_rows = getSelectedUsers();
fb5662de 306
fbf7d545 307 if (sel_rows.length > 0) {
fb5662de 308
50e7dd7d 309 var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
fb5662de 310
fbf7d545
AD
311 if (ok) {
312 notify_progress("Removing selected users...");
fb5662de 313
f30ef1fa 314 var query = "?op=pref-users&method=remove&ids="+
fbf7d545 315 param_escape(sel_rows.toString());
fb5662de 316
b4e75b2a
AD
317 new Ajax.Request("backend.php", {
318 parameters: query,
fb5662de 319 onComplete: function(transport) {
66665fba 320 updateUsersList();
fbf7d545 321 } });
fb5662de 322
fbf7d545 323 }
fb5662de 324
fbf7d545
AD
325 } else {
326 alert(__("No users are selected."));
69668465 327 }
e6cb77a0 328
fbf7d545
AD
329 } catch (e) {
330 exception_error("removeSelectedUsers", e);
e6cb77a0 331 }
90ac84df
AD
332
333 return false;
e6cb77a0
AD
334}
335
48f0adb0
AD
336function removeSelectedFilters() {
337
23e51f40 338 try {
48f0adb0 339
23e51f40 340 var sel_rows = getSelectedFilters();
fb5662de 341
23e51f40 342 if (sel_rows.length > 0) {
fb5662de 343
23e51f40 344 var ok = confirm(__("Remove selected filters?"));
fb5662de 345
23e51f40
AD
346 if (ok) {
347 notify_progress("Removing selected filters...");
fb5662de 348
f30ef1fa 349 var query = "?op=pref-filters&method=remove&ids="+
23e51f40 350 param_escape(sel_rows.toString());
fb5662de 351
b4e75b2a
AD
352 new Ajax.Request("backend.php", {
353 parameters: query,
23e51f40 354 onComplete: function(transport) {
687d246b
AD
355 updateFilterList();
356 } });
23e51f40
AD
357 }
358 } else {
359 alert(__("No filters are selected."));
69668465 360 }
23e51f40
AD
361
362 } catch (e) {
363 exception_error("removeSelectedFilters", e);
48f0adb0 364 }
90ac84df
AD
365
366 return false;
48f0adb0
AD
367}
368
369
83fe4d6d
AD
370function removeSelectedFeeds() {
371
a796bfc1 372 try {
69668465 373
a796bfc1 374 var sel_rows = getSelectedFeeds();
fb5662de 375
a796bfc1 376 if (sel_rows.length > 0) {
fb5662de 377
a796bfc1 378 var ok = confirm(__("Unsubscribe from selected feeds?"));
fb5662de 379
a796bfc1 380 if (ok) {
fb5662de 381
b6a6e262 382 notify_progress("Unsubscribing from selected feeds...", true);
fb5662de 383
f30ef1fa 384 var query = "?op=pref-feeds&method=remove&ids="+
a796bfc1 385 param_escape(sel_rows.toString());
b6a6e262 386
84c7b824 387 console.log(query);
b6a6e262 388
b4e75b2a
AD
389 new Ajax.Request("backend.php", {
390 parameters: query,
a796bfc1 391 onComplete: function(transport) {
b6a6e262 392 updateFeedList();
a796bfc1
AD
393 } });
394 }
fb5662de 395
a796bfc1
AD
396 } else {
397 alert(__("No feeds are selected."));
69668465 398 }
71ad3959 399
a796bfc1
AD
400 } catch (e) {
401 exception_error("removeSelectedFeeds", e);
71ad3959 402 }
fb5662de 403
90ac84df 404 return false;
71ad3959 405}
007bda35 406
c4a36709
AD
407function clearSelectedFeeds() {
408
c4a36709
AD
409 var sel_rows = getSelectedFeeds();
410
411 if (sel_rows.length > 1) {
412 alert(__("Please select only one feed."));
413 return;
414 }
415
416 if (sel_rows.length > 0) {
417
418 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
419
420 if (ok) {
421 notify_progress("Clearing selected feed...");
422 clearFeedArticles(sel_rows[0]);
423 }
424
425 } else {
426
427 alert(__("No feeds are selected."));
428
429 }
fb5662de 430
c4a36709
AD
431 return false;
432}
433
e88a65f4
AD
434function purgeSelectedFeeds() {
435
e88a65f4
AD
436 var sel_rows = getSelectedFeeds();
437
438 if (sel_rows.length > 0) {
439
440 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
441
442 if (pr != undefined) {
443 notify_progress("Purging selected feed...");
444
f30ef1fa 445 var query = "?op=rpc&method=purge&ids="+
e88a65f4
AD
446 param_escape(sel_rows.toString()) + "&days=" + pr;
447
84c7b824 448 console.log(query);
e88a65f4 449
b4e75b2a
AD
450 new Ajax.Request("prefs.php", {
451 parameters: query,
e88a65f4
AD
452 onComplete: function(transport) {
453 notify('');
454 } });
455 }
456
457 } else {
458
459 alert(__("No feeds are selected."));
460
461 }
fb5662de 462
e88a65f4
AD
463 return false;
464}
465
e6cb77a0 466function userEditCancel() {
3c5783b7 467 closeInfoBox();
90ac84df 468 return false;
e6cb77a0 469}
48f0adb0 470
e6cb77a0
AD
471function userEditSave() {
472
fbf7d545 473 try {
e6cb77a0 474
fbf7d545 475 var login = document.forms["user_edit_form"].login.value;
fb5662de 476
fbf7d545
AD
477 if (login.length == 0) {
478 alert(__("Login field cannot be blank."));
479 return;
480 }
fb5662de 481
fbf7d545 482 notify_progress("Saving user...");
fb5662de 483
fbf7d545 484 closeInfoBox();
fb5662de 485
fbf7d545 486 var query = Form.serialize("user_edit_form");
fb5662de 487
fbf7d545
AD
488 new Ajax.Request("backend.php", {
489 parameters: query,
fb5662de 490 onComplete: function(transport) {
66665fba 491 updateUsersList();
fbf7d545 492 } });
fb5662de 493
fbf7d545
AD
494 } catch (e) {
495 exception_error("userEditSave", e);
496 }
90ac84df
AD
497
498 return false;
fbf7d545 499
e6cb77a0
AD
500}
501
502
e6cb77a0
AD
503function editSelectedUser() {
504 var rows = getSelectedUsers();
505
506 if (rows.length == 0) {
f3977cf5 507 alert(__("No users are selected."));
e6cb77a0
AD
508 return;
509 }
510
511 if (rows.length > 1) {
f3977cf5 512 alert(__("Please select only one user."));
e6cb77a0
AD
513 return;
514 }
515
dbd9e2f1
AD
516 notify("");
517
e6cb77a0
AD
518 editUser(rows[0]);
519}
520
521function resetSelectedUserPass() {
e6cb77a0 522
fbf7d545 523 try {
e6cb77a0 524
fbf7d545 525 var rows = getSelectedUsers();
fb5662de 526
fbf7d545
AD
527 if (rows.length == 0) {
528 alert(__("No users are selected."));
529 return;
530 }
fb5662de 531
fbf7d545
AD
532 if (rows.length > 1) {
533 alert(__("Please select only one user."));
534 return;
535 }
fb5662de 536
fbf7d545 537 var ok = confirm(__("Reset password of selected user?"));
fb5662de 538
fbf7d545
AD
539 if (ok) {
540 notify_progress("Resetting password for selected user...");
fb5662de 541
fbf7d545 542 var id = rows[0];
fb5662de 543
f30ef1fa 544 var query = "?op=pref-users&method=resetPass&id=" +
fbf7d545 545 param_escape(id);
fb5662de 546
b4e75b2a
AD
547 new Ajax.Request("backend.php", {
548 parameters: query,
fb5662de 549 onComplete: function(transport) {
478d4067 550 notify_info(transport.responseText, true);
fbf7d545 551 } });
fb5662de 552
fbf7d545
AD
553 }
554
555 } catch (e) {
556 exception_error("resetSelectedUserPass", e);
69668465 557 }
e6cb77a0
AD
558}
559
717f5e64 560function selectedUserDetails() {
e6cb77a0 561
350468d0 562 try {
717f5e64 563
350468d0 564 var rows = getSelectedUsers();
fb5662de 565
350468d0
AD
566 if (rows.length == 0) {
567 alert(__("No users are selected."));
568 return;
569 }
fb5662de 570
350468d0
AD
571 if (rows.length > 1) {
572 alert(__("Please select only one user."));
573 return;
574 }
fb5662de 575
350468d0 576 notify_progress("Loading, please wait...");
fb5662de 577
350468d0 578 var id = rows[0];
fb5662de 579
66665fba 580 var query = "?op=pref-users&method=userdetails&id=" + id;
717f5e64 581
b4e75b2a
AD
582 new Ajax.Request("backend.php", {
583 parameters: query,
350468d0
AD
584 onComplete: function(transport) {
585 infobox_callback2(transport);
586 } });
587 } catch (e) {
588 exception_error("selectedUserDetails", e);
717f5e64 589 }
c6c3a07f
AD
590}
591
a0d53889
AD
592
593function editSelectedFilter() {
594 var rows = getSelectedFilters();
595
596 if (rows.length == 0) {
f3977cf5 597 alert(__("No filters are selected."));
a0d53889
AD
598 return;
599 }
600
601 if (rows.length > 1) {
f3977cf5 602 alert(__("Please select only one filter."));
a0d53889
AD
603 return;
604 }
605
dbd9e2f1
AD
606 notify("");
607
a0d53889
AD
608 editFilter(rows[0]);
609
610}
611
6aff7845
AD
612function joinSelectedFilters() {
613 var rows = getSelectedFilters();
614
615 if (rows.length == 0) {
616 alert(__("No filters are selected."));
617 return;
618 }
619
620 var ok = confirm(__("Combine selected filters?"));
621
622 if (ok) {
623 notify_progress("Joining filters...");
624
625 var query = "?op=pref-filters&method=join&ids="+
626 param_escape(rows.toString());
627
628 console.log(query);
629
630 new Ajax.Request("backend.php", {
631 parameters: query,
632 onComplete: function(transport) {
633 updateFilterList();
634 } });
635 }
636}
a0d53889 637
508a81e1
AD
638function editSelectedFeed() {
639 var rows = getSelectedFeeds();
640
641 if (rows.length == 0) {
f3977cf5 642 alert(__("No feeds are selected."));
508a81e1
AD
643 return;
644 }
645
646 if (rows.length > 1) {
1e5548db 647 return editSelectedFeeds();
508a81e1
AD
648 }
649
dbd9e2f1
AD
650 notify("");
651
951906dc 652 editFeed(rows[0], {});
91ff844a
AD
653
654}
655
758e1c4a
AD
656function editSelectedFeeds() {
657
350468d0
AD
658 try {
659 var rows = getSelectedFeeds();
fb5662de 660
350468d0
AD
661 if (rows.length == 0) {
662 alert(__("No feeds are selected."));
663 return;
664 }
fb5662de 665
755c8f95 666 notify_progress("Loading, please wait...");
fb5662de 667
f30ef1fa 668 var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
350468d0 669 param_escape(rows.toString());
758e1c4a 670
755c8f95
AD
671 console.log(query);
672
05acc0d6
AD
673 if (dijit.byId("feedEditDlg"))
674 dijit.byId("feedEditDlg").destroyRecursive();
675
755c8f95
AD
676 new Ajax.Request("backend.php", {
677 parameters: query,
678 onComplete: function(transport) {
05acc0d6 679
755c8f95
AD
680 notify("");
681
682 var dialog = new dijit.Dialog({
683 id: "feedEditDlg",
684 title: __("Edit Multiple Feeds"),
685 style: "width: 600px",
686 getChildByName: function (name) {
e331188f 687 var rv = null;
755c8f95
AD
688 this.getChildren().each(
689 function(child) {
690 if (child.name == name) {
691 rv = child;
692 return;
693 }
694 });
695 return rv;
696 },
697 toggleField: function (checkbox, elem, label) {
698 this.getChildByName(elem).attr('disabled', !checkbox.checked);
699
700 if ($(label))
701 if (checkbox.checked)
702 $(label).removeClassName('insensitive');
703 else
704 $(label).addClassName('insensitive');
705
706 },
707 execute: function() {
708 if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
709 var query = dojo.objectToQuery(this.attr('value'));
710
711 /* Form.serialize ignores unchecked checkboxes */
712
755c8f95
AD
713 if (!query.match("&private=") &&
714 this.getChildByName('private').attr('disabled') == false) {
715 query = query + "&private=false";
716 }
fb5662de 717
755c8f95
AD
718 try {
719 if (!query.match("&cache_images=") &&
720 this.getChildByName('cache_images').attr('disabled') == false) {
721 query = query + "&cache_images=false";
722 }
723 } catch (e) { }
fb5662de 724
bfd61d3f
AD
725 try {
726 if (!query.match("&hide_images=") &&
727 this.getChildByName('hide_images').attr('disabled') == false) {
728 query = query + "&hide_images=false";
729 }
730 } catch (e) { }
731
755c8f95
AD
732 if (!query.match("&include_in_digest=") &&
733 this.getChildByName('include_in_digest').attr('disabled') == false) {
734 query = query + "&include_in_digest=false";
735 }
fb5662de 736
755c8f95
AD
737 if (!query.match("&always_display_enclosures=") &&
738 this.getChildByName('always_display_enclosures').attr('disabled') == false) {
739 query = query + "&always_display_enclosures=false";
740 }
05acc0d6 741
755c8f95
AD
742 if (!query.match("&mark_unread_on_update=") &&
743 this.getChildByName('mark_unread_on_update').attr('disabled') == false) {
744 query = query + "&mark_unread_on_update=false";
745 }
dd04ea81 746
755c8f95 747 console.log(query);
dd04ea81 748
755c8f95 749 notify_progress("Saving data...", true);
fb5662de 750
755c8f95
AD
751 new Ajax.Request("backend.php", {
752 parameters: query,
753 onComplete: function(transport) {
754 dialog.hide();
755 updateFeedList();
e331188f 756 }});
755c8f95
AD
757 }
758 },
759 content: transport.responseText});
05acc0d6 760
755c8f95 761 dialog.show();
05acc0d6 762
755c8f95 763 } });
758e1c4a 764
350468d0
AD
765 } catch (e) {
766 exception_error("editSelectedFeeds", e);
758e1c4a 767 }
758e1c4a
AD
768}
769
eec498c3 770function piggie(enable) {
13ad9102 771 if (enable) {
84c7b824 772 console.log("I LOVEDED IT!");
acac8448 773 var piggie = $("piggie");
33377ef3 774
537625c6
AD
775 Element.show(piggie);
776 Position.Center(piggie);
777 Effect.Puff(piggie);
778
508a81e1 779 }
508a81e1
AD
780}
781
e1218480
AD
782function opmlImportComplete(iframe) {
783 try {
784 if (!iframe.contentDocument.body.innerHTML) return false;
785
55f34b81
AD
786 Element.show(iframe);
787
e1218480
AD
788 notify('');
789
790 if (dijit.byId('opmlImportDlg'))
791 dijit.byId('opmlImportDlg').destroyRecursive();
792
793 var content = iframe.contentDocument.body.innerHTML;
794
795 dialog = new dijit.Dialog({
796 id: "opmlImportDlg",
797 title: __("OPML Import"),
798 style: "width: 600px",
799 onCancel: function() {
fb5662de 800 updateFeedList();
34aa9e20
AD
801 updateFilterList();
802 updateLabelList();
803 },
804 execute: function() {
805 updateFeedList();
806 updateFilterList();
807 updateLabelList();
808 this.hide();
e1218480
AD
809 },
810 content: content});
811
812 dialog.show();
813
814 } catch (e) {
815 exception_error("opmlImportComplete", e);
816 }
817}
818
b6a6e262 819function opmlImport() {
fb5662de 820
acac8448 821 var opml_file = $("opml_file");
9f311df6
AD
822
823 if (opml_file.value.length == 0) {
d2d75353 824 alert(__("Please choose an OPML file first."));
9f311df6
AD
825 return false;
826 } else {
4d7cd9ed 827 notify_progress("Importing, please wait...", true);
55f34b81
AD
828
829 Element.show("upload_iframe");
830
9f311df6
AD
831 return true;
832 }
833}
834
55f34b81 835
05acc0d6 836function updateFilterList() {
310fa2dd
AD
837 var user_search = $("filter_search");
838 var search = "";
839 if (user_search) { search = user_search.value; }
840
05acc0d6 841 new Ajax.Request("backend.php", {
310fa2dd 842 parameters: "?op=pref-filters&search=" + param_escape(search),
05acc0d6 843 onComplete: function(transport) {
66665fba
AD
844 dijit.byId('filterConfigTab').attr('content', transport.responseText);
845 notify("");
05acc0d6 846 } });
a0d53889
AD
847}
848
05acc0d6
AD
849function updateLabelList() {
850 new Ajax.Request("backend.php", {
851 parameters: "?op=pref-labels",
852 onComplete: function(transport) {
cbe50c80
AD
853 dijit.byId('labelConfigTab').attr('content', transport.responseText);
854 notify("");
05acc0d6 855 } });
48f0adb0
AD
856}
857
4255b24c 858function updatePrefsList() {
b4e75b2a 859 new Ajax.Request("backend.php", {
05acc0d6 860 parameters: "?op=pref-prefs",
fb5662de 861 onComplete: function(transport) {
cbe50c80
AD
862 dijit.byId('genConfigTab').attr('content', transport.responseText);
863 notify("");
e9802ead 864 } });
4255b24c
AD
865}
866
f30ef1fa 867function selectTab(id, noupdate, method) {
b2caf812 868 try {
b2caf812 869 if (!noupdate) {
9e31e1b9 870 notify_progress("Loading, please wait...");
d15f8675 871
b2caf812
AD
872 if (id == "feedConfig") {
873 updateFeedList();
874 } else if (id == "filterConfig") {
875 updateFilterList();
876 } else if (id == "labelConfig") {
877 updateLabelList();
878 } else if (id == "genConfig") {
879 updatePrefsList();
880 } else if (id == "userConfig") {
881 updateUsersList();
b2caf812 882 }
d62796de
AD
883
884 var tab = dijit.byId(id + "Tab");
885 dijit.byId("pref-tabs").selectChild(tab);
886
f5a50b25 887 }
fb5662de 888
b2caf812
AD
889 } catch (e) {
890 exception_error("selectTab", e);
a7565293 891 }
a7565293
AD
892}
893
a7565293 894function init_second_stage() {
b2caf812 895 try {
4da47970 896
d437c8cf 897 document.onkeydown = pref_hotkey_handler;
fcc36744 898 loading_set_progress(50);
d62796de
AD
899 notify("");
900
556e5b46 901 dojo.addOnLoad(function() {
a8328019 902 var tab = getURLParam('tab');
556e5b46 903
a8328019
AD
904 if (tab) {
905 tab = dijit.byId(tab + "Tab");
906 if (tab) dijit.byId("pref-tabs").selectChild(tab);
907 }
b01b1b38 908
f30ef1fa 909 var method = getURLParam('method');
b01b1b38 910
f30ef1fa
AD
911 if (method == 'editFeed') {
912 var param = getURLParam('methodparam');
b01b1b38
AD
913
914 window.setTimeout('editFeed(' + param + ')', 100);
915 }
05acc0d6 916 });
556e5b46 917
78935092
AD
918 setTimeout("hotkey_prefix_timeout()", 5*1000);
919
b2caf812
AD
920 } catch (e) {
921 exception_error("init_second_stage", e);
922 }
a0d53889
AD
923}
924
007bda35 925function init() {
e2ec66a8 926
7719618b 927 try {
1985a5e0 928 dojo.registerModulePath("lib", "..");
107d0cf3 929 dojo.registerModulePath("fox", "../../js/");
1985a5e0 930
1354d172
AD
931 dojo.require("dijit.ColorPalette");
932 dojo.require("dijit.Dialog");
933 dojo.require("dijit.form.Button");
934 dojo.require("dijit.form.CheckBox");
935 dojo.require("dijit.form.DropDownButton");
936 dojo.require("dijit.form.FilteringSelect");
937 dojo.require("dijit.form.Form");
938 dojo.require("dijit.form.RadioButton");
939 dojo.require("dijit.form.Select");
940 dojo.require("dijit.form.SimpleTextarea");
941 dojo.require("dijit.form.TextBox");
942 dojo.require("dijit.form.ValidationTextBox");
943 dojo.require("dijit.InlineEditBox");
944 dojo.require("dijit.layout.AccordionContainer");
945 dojo.require("dijit.layout.BorderContainer");
946 dojo.require("dijit.layout.ContentPane");
947 dojo.require("dijit.layout.TabContainer");
948 dojo.require("dijit.Menu");
949 dojo.require("dijit.ProgressBar");
950 dojo.require("dijit.ProgressBar");
951 dojo.require("dijit.Toolbar");
952 dojo.require("dijit.Tree");
953 dojo.require("dijit.tree.dndSource");
954 dojo.require("dojo.data.ItemFileWriteStore");
955
1985a5e0 956 dojo.require("lib.CheckBoxTree");
2148e0d5 957 dojo.require("fox.PrefFeedTree");
a740f4b5 958 dojo.require("fox.PrefFilterTree");
fb8b2153 959 dojo.require("fox.PrefLabelTree");
fcf70c51 960
a089699c
AD
961 dojo.parser.parse();
962
df1c35f4
AD
963 dojo.addOnLoad(function() {
964 loading_set_progress(50);
fbf7d545 965
df1c35f4 966 new Ajax.Request("backend.php", {
f30ef1fa 967 parameters: {op: "rpc", method: "sanityCheck"},
fb5662de 968 onComplete: function(transport) {
df1c35f4
AD
969 backend_sanity_check_callback(transport);
970 } });
971 });
a7565293 972
7719618b
AD
973 } catch (e) {
974 exception_error("init", e);
e2ec66a8 975 }
007bda35 976}
b1895692 977
69668465 978function validatePrefsReset() {
b652c1b7
AD
979 try {
980 var ok = confirm(__("Reset to defaults?"));
981
982 if (ok) {
983
1395083e 984 query = "?op=pref-prefs&method=resetconfig";
84c7b824 985 console.log(query);
b652c1b7 986
e9802ead
AD
987 new Ajax.Request("backend.php", {
988 parameters: query,
fb5662de 989 onComplete: function(transport) {
1a697fa3
AD
990 var msg = transport.responseText;
991 if (msg.match("PREFS_THEME_CHANGED")) {
992 window.location.reload();
993 } else {
994 notify_info(msg);
995 selectTab();
996 }
e9802ead
AD
997 } });
998
b652c1b7
AD
999 }
1000
1001 } catch (e) {
d9084cf2 1002 exception_error("validatePrefsReset", e);
b652c1b7
AD
1003 }
1004
1005 return false;
1006
69668465 1007}
f9cb39ac 1008
d437c8cf
AD
1009function pref_hotkey_handler(e) {
1010 try {
b8cb4d08 1011
e33b0b80 1012 if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
18606807 1013
e331188f 1014 var keycode = false;
746dcf42
AD
1015 var shift_key = false;
1016
78935092
AD
1017 var cmdline = $('cmdline');
1018
746dcf42
AD
1019 try {
1020 shift_key = e.shiftKey;
1021 } catch (e) {
1022
1023 }
1024
d437c8cf
AD
1025 if (window.event) {
1026 keycode = window.event.keyCode;
1027 } else if (e) {
1028 keycode = e.which;
1029 }
746dcf42 1030
eec498c3
AD
1031 var keychar = String.fromCharCode(keycode);
1032
746dcf42 1033 if (keycode == 27) { // escape
746dcf42 1034 hotkey_prefix = false;
fb5662de 1035 }
746dcf42 1036
746dcf42 1037 if (keycode == 16) return; // ignore lone shift
49c6c279 1038 if (keycode == 17) return; // ignore lone ctrl
746dcf42 1039
b8cb4d08
AD
1040 if (!shift_key) keychar = keychar.toLowerCase();
1041
1042 var hotkeys = getInitParam("hotkeys");
1043
1044 if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
78935092
AD
1045
1046 var date = new Date();
1047 var ts = Math.round(date.getTime() / 1000);
1048
b8cb4d08 1049 hotkey_prefix = keychar;
78935092
AD
1050 hotkey_prefix_pressed = ts;
1051
1052 cmdline.innerHTML = keychar;
1053 Element.show(cmdline);
1054
b8cb4d08 1055 return true;
746dcf42
AD
1056 }
1057
78935092
AD
1058 Element.hide(cmdline);
1059
b8cb4d08
AD
1060 var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
1061 hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
1062 hotkey_prefix = false;
8d727bfc 1063
b8cb4d08
AD
1064 var hotkey_action = false;
1065 var hotkeys = getInitParam("hotkeys");
746dcf42 1066
b8cb4d08
AD
1067 for (sequence in hotkeys[1]) {
1068 if (sequence == hotkey) {
1069 hotkey_action = hotkeys[1][sequence];
1070 break;
746dcf42
AD
1071 }
1072 }
1073
b8cb4d08
AD
1074 switch (hotkey_action) {
1075 case "feed_subscribe":
1076 quickAddFeed();
4ba1f8bb 1077 return false;
b8cb4d08
AD
1078 case "create_label":
1079 addLabel();
4ba1f8bb 1080 return false;
b8cb4d08
AD
1081 case "create_filter":
1082 quickAddFilter();
4ba1f8bb 1083 return false;
b8cb4d08
AD
1084 case "help_dialog":
1085 //helpDialog("prefs");
1086 return false;
1087 default:
1088 console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
d437c8cf 1089 }
d437c8cf
AD
1090
1091 } catch (e) {
b8cb4d08 1092 exception_error("hotkey_handler", e);
d437c8cf
AD
1093 }
1094}
1095
5ef071e0 1096function removeCategory(id, item) {
a349077c 1097 try {
350468d0 1098
5ef071e0 1099 var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
da1f74c9 1100
5ef071e0 1101 if (ok) {
28537341 1102 var query = "?op=pref-feeds&method=removeCat&ids="+
5ef071e0 1103 param_escape(id);
fb5662de 1104
5ef071e0 1105 notify_progress("Removing category...");
fb5662de 1106
5ef071e0
AD
1107 new Ajax.Request("backend.php", {
1108 parameters: query,
1109 onComplete: function(transport) {
1110 notify('');
1111 updateFeedList();
1112 } });
1113 }
fb5662de 1114
5ef071e0
AD
1115 } catch (e) {
1116 exception_error("removeCategory", e);
1117 }
1118}
fb5662de 1119
fd26d5bf
AD
1120function removeSelectedCategories() {
1121
1122 var sel_rows = getSelectedCategories();
1123
1124 if (sel_rows.length > 0) {
1125
1126 var ok = confirm(__("Remove selected categories?"));
1127
1128 if (ok) {
1129 notify_progress("Removing selected categories...");
1130
1131 var query = "?op=pref-feeds&method=removeCat&ids="+
1132 param_escape(sel_rows.toString());
1133
1134 new Ajax.Request("backend.php", {
1135 parameters: query,
1136 onComplete: function(transport) {
1137 updateFeedList();
1138 } });
1139
1140 }
1141 } else {
1142 alert(__("No categories are selected."));
1143 }
1144
1145 return false;
1146}
1147
5ef071e0
AD
1148function createCategory() {
1149 try {
1150 var title = prompt(__("Category title:"));
fb5662de 1151
5ef071e0 1152 if (title) {
da1f74c9 1153
5ef071e0 1154 notify_progress("Creating category...");
da1f74c9 1155
28537341 1156 var query = "?op=pref-feeds&method=addCat&cat=" +
5ef071e0 1157 param_escape(title);
da1f74c9 1158
5ef071e0
AD
1159 new Ajax.Request("backend.php", {
1160 parameters: query,
1161 onComplete: function(transport) {
1162 notify('');
1163 updateFeedList();
1164 } });
1165 }
5ba53dde 1166
a349077c 1167 } catch (e) {
5ef071e0 1168 exception_error("createCategory", e);
a349077c 1169 }
9c483746 1170}
a3656a41 1171
8ffd2011
AD
1172function showInactiveFeeds() {
1173 try {
bc6fa236 1174 var query = "backend.php?op=pref-feeds&method=inactiveFeeds";
8ffd2011
AD
1175
1176 if (dijit.byId("inactiveFeedsDlg"))
1177 dijit.byId("inactiveFeedsDlg").destroyRecursive();
1178
1179 dialog = new dijit.Dialog({
1180 id: "inactiveFeedsDlg",
1181 title: __("Feeds without recent updates"),
1182 style: "width: 600px",
1183 getSelectedFeeds: function() {
1184 return getSelectedTableRowIds("prefInactiveFeedList");
1185 },
1186 removeSelected: function() {
1187 var sel_rows = this.getSelectedFeeds();
1188
1189 console.log(sel_rows);
1190
1191 if (sel_rows.length > 0) {
1192 var ok = confirm(__("Remove selected feeds?"));
1193
1194 if (ok) {
1195 notify_progress("Removing selected feeds...", true);
1196
f30ef1fa 1197 var query = "?op=pref-feeds&method=remove&ids="+
8ffd2011
AD
1198 param_escape(sel_rows.toString());
1199
1200 new Ajax.Request("backend.php", {
1201 parameters: query,
1202 onComplete: function(transport) {
1203 notify('');
1204 dialog.hide();
1205 updateFeedList();
1206 } });
1207 }
1208
1209 } else {
1210 alert(__("No feeds are selected."));
1211 }
1212 },
1213 execute: function() {
1214 if (this.validate()) {
1215 }
1216 },
1217 href: query});
1218
1219 dialog.show();
1220
1221 } catch (e) {
1222 exception_error("showInactiveFeeds", e);
1223 }
1224
1225}
1226
ef7b7bbd
MK
1227function opmlRegenKey() {
1228
1229 try {
1230 var ok = confirm(__("Replace current OPML publishing address with a new one?"));
fb5662de 1231
ef7b7bbd 1232 if (ok) {
fb5662de 1233
ef7b7bbd 1234 notify_progress("Trying to change address...", true);
fb5662de 1235
f30ef1fa 1236 var query = "?op=rpc&method=regenOPMLKey";
fb5662de 1237
ef7b7bbd
MK
1238 new Ajax.Request("backend.php", {
1239 parameters: query,
1240 onComplete: function(transport) {
91d16ff1
AD
1241 var reply = JSON.parse(transport.responseText);
1242
1243 var new_link = reply.link;
fb5662de 1244
ef7b7bbd 1245 var e = $('pub_opml_url');
fb5662de 1246
ef7b7bbd 1247 if (new_link) {
91d16ff1
AD
1248 e.href = new_link;
1249 e.innerHTML = new_link;
fb5662de 1250
ef7b7bbd
MK
1251 new Effect.Highlight(e);
1252
1253 notify('');
fb5662de 1254
ef7b7bbd
MK
1255 } else {
1256 notify_error("Could not change feed URL.");
1257 }
1258 } });
1259 }
1260 } catch (e) {
1261 exception_error("opmlRegenKey", e);
1262 }
1263 return false;
1264}
c4a36709
AD
1265
1266function feedActionChange() {
1267 try {
acac8448 1268 var chooser = $("feedActionChooser");
c4a36709
AD
1269 var opid = chooser[chooser.selectedIndex].value;
1270
1271 chooser.selectedIndex = 0;
1272 feedActionGo(opid);
1273 } catch (e) {
1274 exception_error("feedActionChange", e);
1275 }
1276}
1277
fb5662de 1278function feedActionGo(op) {
c4a36709
AD
1279 try {
1280 if (op == "facEdit") {
cd935c42
AD
1281
1282 var rows = getSelectedFeeds();
1283
1284 if (rows.length > 1) {
1285 editSelectedFeeds();
1286 } else {
1287 editSelectedFeed();
1288 }
c4a36709
AD
1289 }
1290
1291 if (op == "facClear") {
1292 clearSelectedFeeds();
1293 }
1294
1295 if (op == "facPurge") {
1296 purgeSelectedFeeds();
1297 }
1298
e88a65f4
AD
1299 if (op == "facEditCats") {
1300 editFeedCats();
1301 }
1302
fee840fb
AD
1303 if (op == "facRescore") {
1304 rescoreSelectedFeeds();
1305 }
1306
c4a36709
AD
1307 if (op == "facUnsubscribe") {
1308 removeSelectedFeeds();
1309 }
1310
1311 } catch (e) {
1312 exception_error("feedActionGo", e);
1313
1314 }
1315}
1316
1317function clearFeedArticles(feed_id) {
1318
1319 notify_progress("Clearing feed...");
1320
f30ef1fa 1321 var query = "?op=pref-feeds&quiet=1&method=clear&id=" + feed_id;
c4a36709 1322
b4e75b2a
AD
1323 new Ajax.Request("backend.php", {
1324 parameters: query,
c4a36709
AD
1325 onComplete: function(transport) {
1326 notify('');
1327 } });
1328
1329 return false;
1330}
1331
fee840fb
AD
1332function rescoreSelectedFeeds() {
1333
fee840fb
AD
1334 var sel_rows = getSelectedFeeds();
1335
1336 if (sel_rows.length > 0) {
1337
ef1b0366
AD
1338 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1339 var ok = confirm(__("Rescore articles in selected feeds?"));
fee840fb
AD
1340
1341 if (ok) {
3df4869b 1342 notify_progress("Rescoring selected feeds...", true);
fb5662de 1343
f30ef1fa 1344 var query = "?op=pref-feeds&method=rescore&quiet=1&ids="+
60715b53
AD
1345 param_escape(sel_rows.toString());
1346
b4e75b2a
AD
1347 new Ajax.Request("backend.php", {
1348 parameters: query,
60715b53
AD
1349 onComplete: function(transport) {
1350 notify_callback2(transport);
1351 } });
1352
fee840fb
AD
1353 }
1354 } else {
1355 alert(__("No feeds are selected."));
1356 }
1357
1358 return false;
1359}
c4a36709 1360
95a948a5 1361function rescore_all_feeds() {
60715b53 1362 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
95a948a5 1363
60715b53
AD
1364 if (ok) {
1365 notify_progress("Rescoring feeds...", true);
95a948a5 1366
f30ef1fa 1367 var query = "?op=pref-feeds&method=rescoreAll&quiet=1";
60715b53 1368
b4e75b2a
AD
1369 new Ajax.Request("backend.php", {
1370 parameters: query,
60715b53
AD
1371 onComplete: function(transport) {
1372 notify_callback2(transport);
1373 } });
1374 }
a80b05ea 1375}
a44db887 1376
b8776a07
AD
1377function labelColorReset() {
1378 try {
1379 var labels = getSelectedLabels();
1380
f695cdb2
AD
1381 if (labels.length > 0) {
1382 var ok = confirm(__("Reset selected labels to default colors?"));
b8776a07 1383
f695cdb2 1384 if (ok) {
cbe50c80 1385 var query = "?op=pref-labels&method=colorreset&ids="+
f695cdb2 1386 param_escape(labels.toString());
b8776a07 1387
f695cdb2
AD
1388 new Ajax.Request("backend.php", {
1389 parameters: query,
1390 onComplete: function(transport) {
cbe50c80 1391 updateLabelList();
b8776a07 1392 } });
f695cdb2
AD
1393 }
1394
1395 } else {
1396 alert(__("No labels are selected."));
b8776a07
AD
1397 }
1398
1399 } catch (e) {
1400 exception_error("labelColorReset", e);
1401 }
1402}
1403
b6ba48c1 1404
a5819bb3
AD
1405function inPreferences() {
1406 return true;
1407}
d9084cf2
AD
1408
1409function editProfiles() {
22988692
AD
1410 try {
1411
1412 if (dijit.byId("profileEditDlg"))
1413 dijit.byId("profileEditDlg").destroyRecursive();
1414
3f363052 1415 var query = "backend.php?op=dlg&method=editPrefProfiles";
22988692
AD
1416
1417 dialog = new dijit.Dialog({
1418 id: "profileEditDlg",
1419 title: __("Settings Profiles"),
1420 style: "width: 600px",
1421 getSelectedProfiles: function() {
1422 return getSelectedTableRowIds("prefFeedProfileList");
1423 },
1424 removeSelected: function() {
1425 var sel_rows = this.getSelectedProfiles();
fb5662de
AD
1426
1427 if (sel_rows.length > 0) {
22988692 1428 var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
fb5662de 1429
22988692
AD
1430 if (ok) {
1431 notify_progress("Removing selected profiles...", true);
fb5662de 1432
f30ef1fa 1433 var query = "?op=rpc&method=remprofiles&ids="+
22988692 1434 param_escape(sel_rows.toString());
fb5662de 1435
22988692
AD
1436 new Ajax.Request("backend.php", {
1437 parameters: query,
1438 onComplete: function(transport) {
1439 notify('');
1440 editProfiles();
1441 } });
fb5662de 1442
22988692 1443 }
fb5662de
AD
1444
1445 } else {
1446 alert(__("No profiles are selected."));
22988692
AD
1447 }
1448 },
1449 activateProfile: function() {
1450 var sel_rows = this.getSelectedProfiles();
fb5662de 1451
22988692 1452 if (sel_rows.length == 1) {
fb5662de 1453
22988692 1454 var ok = confirm(__("Activate selected profile?"));
fb5662de 1455
22988692
AD
1456 if (ok) {
1457 notify_progress("Loading, please wait...");
fb5662de 1458
f30ef1fa 1459 var query = "?op=rpc&method=setprofile&id="+
22988692 1460 param_escape(sel_rows.toString());
fb5662de 1461
22988692
AD
1462 new Ajax.Request("backend.php", {
1463 parameters: query,
1464 onComplete: function(transport) {
1465 window.location.reload();
1466 } });
1467 }
fb5662de 1468
22988692
AD
1469 } else {
1470 alert(__("Please choose a profile to activate."));
fb5662de
AD
1471 }
1472 },
22988692
AD
1473 addProfile: function() {
1474 if (this.validate()) {
1475 notify_progress("Creating profile...", true);
1476
f30ef1fa 1477 var query = "?op=rpc&method=addprofile&title=" +
22988692
AD
1478 param_escape(dialog.attr('value').newprofile);
1479
1480 new Ajax.Request("backend.php", {
1481 parameters: query,
1482 onComplete: function(transport) {
1483 notify('');
1484 editProfiles();
1485 } });
1486
1487 }
1488 },
1489 execute: function() {
1490 if (this.validate()) {
1491 }
1492 },
1493 href: query});
1494
1495 dialog.show();
1496 } catch (e) {
1497 exception_error("editProfiles", e);
1498 }
d9084cf2
AD
1499}
1500
1501function activatePrefProfile() {
1502
1503 var sel_rows = getSelectedFeedCats();
1504
1505 if (sel_rows.length == 1) {
1506
1507 var ok = confirm(__("Activate selected profile?"));
1508
1509 if (ok) {
1510 notify_progress("Loading, please wait...");
fb5662de 1511
f30ef1fa 1512 var query = "?op=rpc&method=setprofile&id="+
d9084cf2
AD
1513 param_escape(sel_rows.toString());
1514
1515 new Ajax.Request("backend.php", {
1516 parameters: query,
1517 onComplete: function(transport) {
1518 window.location.reload();
1519 } });
1520 }
1521
1522 } else {
1523 alert(__("Please choose a profile to activate."));
1524 }
1525
1526 return false;
1527}
1528
8d86f15f
AD
1529function clearFeedAccessKeys() {
1530
1531 var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
1532
1533 if (ok) {
1534 notify_progress("Clearing URLs...");
1535
f30ef1fa 1536 var query = "?op=rpc&method=clearKeys";
8d86f15f
AD
1537
1538 new Ajax.Request("backend.php", {
1539 parameters: query,
fb5662de 1540 onComplete: function(transport) {
8d86f15f
AD
1541 notify_info("Generated URLs cleared.");
1542 } });
1543 }
fb5662de 1544
8d86f15f
AD
1545 return false;
1546}
1547
83cd33fc
AD
1548function clearArticleAccessKeys() {
1549
1550 var ok = confirm(__("This will invalidate all previously shared article URLs. Continue?"));
1551
1552 if (ok) {
1553 notify_progress("Clearing URLs...");
1554
f30ef1fa 1555 var query = "?op=rpc&method=clearArticleKeys";
83cd33fc
AD
1556
1557 new Ajax.Request("backend.php", {
1558 parameters: query,
1559 onComplete: function(transport) {
1560 notify_info("Shared URLs cleared.");
1561 } });
1562 }
1563
1564 return false;
1565}
7b8a143f
AD
1566function resetFeedOrder() {
1567 try {
1568 notify_progress("Loading, please wait...");
1569
1570 new Ajax.Request("backend.php", {
f30ef1fa 1571 parameters: "?op=pref-feeds&method=feedsortreset",
7b8a143f 1572 onComplete: function(transport) {
fb5662de 1573 updateFeedList();
7b8a143f
AD
1574 } });
1575
1576
1577 } catch (e) {
1578 exception_error("resetFeedOrder");
1579 }
1580}
1581
1582function resetCatOrder() {
1583 try {
1584 notify_progress("Loading, please wait...");
1585
1586 new Ajax.Request("backend.php", {
f30ef1fa 1587 parameters: "?op=pref-feeds&method=catsortreset",
7b8a143f 1588 onComplete: function(transport) {
fb5662de 1589 updateFeedList();
7b8a143f
AD
1590 } });
1591
1592
1593 } catch (e) {
1594 exception_error("resetCatOrder");
1595 }
1596}
1597
5b7bd238
AD
1598function toggleHiddenFeedCats() {
1599 try {
1600 notify_progress("Loading, please wait...");
1601
1602 new Ajax.Request("backend.php", {
1603 parameters: "?op=pref-feeds&method=togglehiddenfeedcats",
1604 onComplete: function(transport) {
1605 updateFeedList();
1606 } });
1607
1608 } catch (e) {
1609 exception_error("toggleHiddenFeedCats");
1610 }
1611}
1612
7b8a143f
AD
1613function editCat(id, item, event) {
1614 try {
1615 var new_name = prompt(__('Rename category to:'), item.name);
1616
1617 if (new_name && new_name != item.name) {
1618
1619 notify_progress("Loading, please wait...");
1620
1621 new Ajax.Request("backend.php", {
1622 parameters: {
fb5662de 1623 op: 'pref-feeds',
f30ef1fa 1624 method: 'renamecat',
7b8a143f
AD
1625 id: id,
1626 title: new_name,
1627 },
1628 onComplete: function(transport) {
fb5662de 1629 updateFeedList();
7b8a143f
AD
1630 } });
1631 }
1632
1633 } catch (e) {
1634 exception_error("editCat", e);
1635 }
1636}
fb8b2153
AD
1637
1638function editLabel(id, event) {
1639 try {
f30ef1fa 1640 var query = "backend.php?op=pref-labels&method=edit&id=" +
fb8b2153
AD
1641 param_escape(id);
1642
48b05a29
AD
1643 if (dijit.byId("labelEditDlg"))
1644 dijit.byId("labelEditDlg").destroyRecursive();
1645
1646 dialog = new dijit.Dialog({
1647 id: "labelEditDlg",
1648 title: __("Label Editor"),
1649 style: "width: 600px",
05acc0d6
AD
1650 setLabelColor: function(id, fg, bg) {
1651
1652 var kind = '';
1653 var color = '';
fb5662de 1654
05acc0d6
AD
1655 if (fg && bg) {
1656 kind = 'both';
1657 } else if (fg) {
1658 kind = 'fg';
1659 color = fg;
1660 } else if (bg) {
1661 kind = 'bg';
1662 color = bg;
1663 }
fb5662de 1664
cbe50c80 1665 var query = "?op=pref-labels&method=colorset&kind="+kind+
fb5662de 1666 "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
05acc0d6 1667 "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
fb5662de 1668
05acc0d6 1669 // console.log(query);
fb5662de 1670
05acc0d6 1671 var e = $("LICID-" + id);
fb5662de
AD
1672
1673 if (e) {
05acc0d6
AD
1674 if (fg) e.style.color = fg;
1675 if (bg) e.style.backgroundColor = bg;
1676 }
fb5662de 1677
05acc0d6
AD
1678 new Ajax.Request("backend.php", { parameters: query });
1679
1680 updateFilterList();
1681 },
48b05a29
AD
1682 execute: function() {
1683 if (this.validate()) {
48b05a29
AD
1684 var caption = this.attr('value').caption;
1685 var fg_color = this.attr('value').fg_color;
1686 var bg_color = this.attr('value').bg_color;
1687 var query = dojo.objectToQuery(this.attr('value'));
1688
1689 dijit.byId('labelTree').setNameById(id, caption);
05acc0d6 1690 this.setLabelColor(id, fg_color, bg_color);
48b05a29
AD
1691 this.hide();
1692
1693 new Ajax.Request("backend.php", {
1694 parameters: query,
1695 onComplete: function(transport) {
fb5662de 1696 updateFilterList();
48b05a29
AD
1697 } });
1698 }
1699 },
1700 href: query});
fb8b2153 1701
48b05a29 1702 dialog.show();
fb8b2153
AD
1703
1704 } catch (e) {
1705 exception_error("editLabel", e);
1706 }
1707}
018caf6f 1708
88e4e597
AD
1709
1710function customizeCSS() {
1711 try {
3f363052 1712 var query = "backend.php?op=dlg&method=customizeCSS";
88e4e597
AD
1713
1714 if (dijit.byId("cssEditDlg"))
1715 dijit.byId("cssEditDlg").destroyRecursive();
1716
1717 dialog = new dijit.Dialog({
1718 id: "cssEditDlg",
1719 title: __("Customize stylesheet"),
1720 style: "width: 600px",
1721 execute: function() {
1722 notify_progress('Saving data...', true);
1723 new Ajax.Request("backend.php", {
1724 parameters: dojo.objectToQuery(this.attr('value')),
fb5662de 1725 onComplete: function(transport) {
88e4e597
AD
1726 notify('');
1727 window.location.reload();
1728 } });
1729
1730 },
1731 href: query});
1732
1733 dialog.show();
1734
1735 } catch (e) {
1736 exception_error("customizeCSS", e);
1737 }
1738}
3d72afa1
AD
1739
1740function insertSSLserial(value) {
1741 try {
1742 dijit.byId("SSL_CERT_SERIAL").attr('value', value);
1743 } catch (e) {
1744 exception_error("insertSSLcerial", e);
1745 }
1746}
373266eb 1747
41f68571
AD
1748function gotoExportOpml(filename, settings) {
1749 tmp = settings ? 1 : 0;
d75409bf 1750 document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
41f68571
AD
1751}
1752
1753
33f0fdd0
AD
1754function batchSubscribe() {
1755 try {
1756 var query = "backend.php?op=dlg&method=batchSubscribe";
1757
c714cee7
AD
1758 // overlapping widgets
1759 if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
1760 if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
33f0fdd0
AD
1761
1762 var dialog = new dijit.Dialog({
1763 id: "batchSubDlg",
1764 title: __("Batch subscribe"),
1765 style: "width: 600px",
1766 execute: function() {
1767 if (this.validate()) {
1768 console.log(dojo.objectToQuery(this.attr('value')));
1769
1770 notify_progress(__("Subscribing to feeds..."), true);
1771
1772 new Ajax.Request("backend.php", {
1773 parameters: dojo.objectToQuery(this.attr('value')),
1774 onComplete: function(transport) {
4b298c86
AD
1775 notify("");
1776 updateFeedList();
1777 dialog.hide();
33f0fdd0
AD
1778 } });
1779 }
1780 },
1781 href: query});
1782
1783 dialog.show();
1784 } catch (e) {
1785 exception_error("batchSubscribe", e);
1786 }
1787}
55f34b81 1788
27211afe 1789
f9ebb32c
AD
1790function toggleAdvancedPrefs() {
1791 try {
1792 notify_progress("Loading, please wait...");
1793
1794 new Ajax.Request("backend.php", {
1795 parameters: "?op=pref-prefs&method=toggleadvanced",
1796 onComplete: function(transport) {
1797 updatePrefsList();
1798 } });
1799
1800 } catch (e) {
1801 exception_error("toggleAdvancedPrefs", e);
1802 }
1803}
5d9abb1e
AD
1804
1805function clearPluginData(name) {
1806 try {
1807 if (confirm(__("Clear stored data for this plugin?"))) {
1808 notify_progress("Loading, please wait...");
1809
1810 new Ajax.Request("backend.php", {
1811 parameters: "?op=pref-prefs&method=clearplugindata&name=" + param_escape(name),
1812 onComplete: function(transport) {
1813 notify('');
1814 updatePrefsList();
1815 } });
1816 }
1817 } catch (e) {
1818 exception_error("clearPluginData", e);
1819 }
1820}