]>
Commit | Line | Data |
---|---|---|
4508e310 AD |
1 | /* global dijit, __ */ |
2 | ||
8572e010 AD |
3 | let hotkey_prefix = false; |
4 | let hotkey_prefix_pressed = false; | |
7a09510c | 5 | |
8572e010 | 6 | let seq = ""; |
a998dbef | 7 | |
66665fba AD |
8 | function notify_callback2(transport, sticky) { |
9 | notify_info(transport.responseText, sticky); | |
60715b53 AD |
10 | } |
11 | ||
05185108 | 12 | function updateFeedList() { |
16270276 | 13 | |
424e28db AD |
14 | const user_search = $("feed_search"); |
15 | let search = ""; | |
16270276 AD |
16 | if (user_search) { search = user_search.value; } |
17 | ||
ef129fed AD |
18 | xhrPost("backend.php", { op: "pref-feeds", search: search }, (transport) => { |
19 | dijit.byId('feedConfigTab').attr('content', transport.responseText); | |
20 | selectTab("feedConfig", true); | |
21 | notify(""); | |
22 | }); | |
007bda35 AD |
23 | } |
24 | ||
f9c1f8b0 | 25 | function checkInactiveFeeds() { |
ef129fed AD |
26 | xhrPost("backend.php", { op: "pref-feeds", method: "getinactivefeeds" }, (transport) => { |
27 | if (parseInt(transport.responseText) > 0) { | |
28 | Element.show(dijit.byId("pref_feeds_inactive_btn").domNode); | |
1bfe1d7b AD |
29 | } |
30 | }); | |
f9c1f8b0 | 31 | } |
373266eb | 32 | |
79ec0f2f | 33 | function updateUsersList(sort_key) { |
424e28db | 34 | const user_search = $("user_search"); |
ef129fed | 35 | const search = user_search ? user_search.value : ""; |
fb5662de | 36 | |
ef129fed | 37 | const query = { op: "pref-users", sort: sort_key, search: search }; |
e6cb77a0 | 38 | |
ef129fed AD |
39 | xhrPost("backend.php", query, (transport) => { |
40 | dijit.byId('userConfigTab').attr('content', transport.responseText); | |
41 | selectTab("userConfig", true) | |
42 | notify(""); | |
1bfe1d7b | 43 | }); |
e6cb77a0 AD |
44 | } |
45 | ||
e6cb77a0 | 46 | function addUser() { |
424e28db | 47 | const login = prompt(__("Please enter login:"), ""); |
e6cb77a0 | 48 | |
1bfe1d7b AD |
49 | if (login == null) { |
50 | return false; | |
51 | } | |
fb5662de | 52 | |
1bfe1d7b AD |
53 | if (login == "") { |
54 | alert(__("Can't create user: no login specified.")); | |
55 | return false; | |
56 | } | |
fb5662de | 57 | |
1bfe1d7b | 58 | notify_progress("Adding user..."); |
fb5662de | 59 | |
ef129fed AD |
60 | xhrPost("backend.php", { op: "pref-users", method: "add", login: login }, (transport) => { |
61 | notify_callback2(transport); | |
62 | updateUsersList(); | |
63 | }); | |
e6cb77a0 | 64 | |
e6cb77a0 AD |
65 | } |
66 | ||
05185108 | 67 | function editUser(id) { |
e6cb77a0 | 68 | |
424e28db | 69 | const query = "backend.php?op=pref-users&method=edit&id=" + |
1bfe1d7b | 70 | param_escape(id); |
222a61c2 | 71 | |
1bfe1d7b AD |
72 | if (dijit.byId("userEditDlg")) |
73 | dijit.byId("userEditDlg").destroyRecursive(); | |
222a61c2 | 74 | |
9dc5524d | 75 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
76 | id: "userEditDlg", |
77 | title: __("User Editor"), | |
78 | style: "width: 600px", | |
79 | execute: function () { | |
80 | if (this.validate()) { | |
81 | notify_progress("Saving data...", true); | |
222a61c2 | 82 | |
ef129fed AD |
83 | xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { |
84 | dialog.hide(); | |
85 | updateUsersList(); | |
86 | }); | |
1bfe1d7b AD |
87 | } |
88 | }, | |
89 | href: query | |
90 | }); | |
fb5662de | 91 | |
1bfe1d7b | 92 | dialog.show(); |
e6cb77a0 AD |
93 | } |
94 | ||
261226a3 | 95 | function editFilter(id) { |
261226a3 | 96 | |
424e28db | 97 | const query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id); |
261226a3 | 98 | |
1bfe1d7b AD |
99 | if (dijit.byId("feedEditDlg")) |
100 | dijit.byId("feedEditDlg").destroyRecursive(); | |
261226a3 | 101 | |
1bfe1d7b AD |
102 | if (dijit.byId("filterEditDlg")) |
103 | dijit.byId("filterEditDlg").destroyRecursive(); | |
ec630524 | 104 | |
9dc5524d | 105 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
106 | id: "filterEditDlg", |
107 | title: __("Edit Filter"), | |
108 | style: "width: 600px", | |
ec630524 | 109 | |
1bfe1d7b | 110 | test: function () { |
424e28db | 111 | const query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test"; |
fb5662de | 112 | |
1bfe1d7b AD |
113 | editFilterTest(query); |
114 | }, | |
115 | selectRules: function (select) { | |
116 | $$("#filterDlg_Matches input[type=checkbox]").each(function (e) { | |
117 | e.checked = select; | |
118 | if (select) | |
119 | e.parentNode.addClassName("Selected"); | |
120 | else | |
121 | e.parentNode.removeClassName("Selected"); | |
122 | }); | |
123 | }, | |
124 | selectActions: function (select) { | |
125 | $$("#filterDlg_Actions input[type=checkbox]").each(function (e) { | |
126 | e.checked = select; | |
90e4e726 | 127 | |
1bfe1d7b AD |
128 | if (select) |
129 | e.parentNode.addClassName("Selected"); | |
130 | else | |
131 | e.parentNode.removeClassName("Selected"); | |
fb5662de | 132 | |
1bfe1d7b AD |
133 | }); |
134 | }, | |
135 | editRule: function (e) { | |
424e28db AD |
136 | const li = e.parentNode; |
137 | const rule = li.getElementsByTagName("INPUT")[1].value; | |
1bfe1d7b AD |
138 | addFilterRule(li, rule); |
139 | }, | |
140 | editAction: function (e) { | |
424e28db AD |
141 | const li = e.parentNode; |
142 | const action = li.getElementsByTagName("INPUT")[1].value; | |
1bfe1d7b AD |
143 | addFilterAction(li, action); |
144 | }, | |
145 | removeFilter: function () { | |
424e28db | 146 | const msg = __("Remove filter?"); |
1bfe1d7b AD |
147 | |
148 | if (confirm(msg)) { | |
149 | this.hide(); | |
90e4e726 | 150 | |
1bfe1d7b | 151 | notify_progress("Removing filter..."); |
90e4e726 | 152 | |
ef129fed | 153 | const query = { op: "pref-filters", method: "remove", ids: this.attr('value').id }; |
141fb6e3 | 154 | |
ef129fed AD |
155 | xhrPost("backend.php", query, () => { |
156 | updateFilterList(); | |
1bfe1d7b AD |
157 | }); |
158 | } | |
159 | }, | |
160 | addAction: function () { | |
161 | addFilterAction(); | |
162 | }, | |
163 | addRule: function () { | |
164 | addFilterRule(); | |
165 | }, | |
166 | deleteAction: function () { | |
167 | $$("#filterDlg_Actions li[class*=Selected]").each(function (e) { | |
168 | e.parentNode.removeChild(e) | |
169 | }); | |
170 | }, | |
171 | deleteRule: function () { | |
172 | $$("#filterDlg_Matches li[class*=Selected]").each(function (e) { | |
173 | e.parentNode.removeChild(e) | |
174 | }); | |
175 | }, | |
176 | execute: function () { | |
177 | if (this.validate()) { | |
141fb6e3 | 178 | |
1bfe1d7b | 179 | notify_progress("Saving data...", true); |
6aff7845 | 180 | |
ef129fed AD |
181 | xhrPost("backend.php", dojo.formToObject("filter_edit_form"), () => { |
182 | dialog.hide(); | |
183 | updateFilterList(); | |
1bfe1d7b AD |
184 | }); |
185 | } | |
186 | }, | |
187 | href: query | |
188 | }); | |
a0d53889 | 189 | |
1bfe1d7b | 190 | dialog.show(); |
a0d53889 AD |
191 | } |
192 | ||
1bfe1d7b | 193 | |
91ff844a | 194 | function getSelectedLabels() { |
424e28db AD |
195 | const tree = dijit.byId("labelTree"); |
196 | const items = tree.model.getCheckedItems(); | |
197 | const rv = []; | |
fb8b2153 AD |
198 | |
199 | items.each(function(item) { | |
200 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
201 | }); | |
202 | ||
203 | return rv; | |
91ff844a | 204 | } |
48f0adb0 | 205 | |
91ff844a | 206 | function getSelectedUsers() { |
e69fb880 | 207 | return getSelectedTableRowIds("prefUserList"); |
a0d53889 AD |
208 | } |
209 | ||
83fe4d6d | 210 | function getSelectedFeeds() { |
424e28db AD |
211 | const tree = dijit.byId("feedTree"); |
212 | const items = tree.model.getCheckedItems(); | |
213 | const rv = []; | |
1985a5e0 AD |
214 | |
215 | items.each(function(item) { | |
7c227bb3 AD |
216 | if (item.id[0].match("FEED:")) |
217 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
1985a5e0 AD |
218 | }); |
219 | ||
220 | return rv; | |
91ff844a | 221 | } |
331900c6 | 222 | |
fd26d5bf | 223 | function getSelectedCategories() { |
424e28db AD |
224 | const tree = dijit.byId("feedTree"); |
225 | const items = tree.model.getCheckedItems(); | |
226 | const rv = []; | |
fd26d5bf AD |
227 | |
228 | items.each(function(item) { | |
229 | if (item.id[0].match("CAT:")) | |
230 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
231 | }); | |
232 | ||
233 | return rv; | |
234 | } | |
235 | ||
91ff844a | 236 | function getSelectedFilters() { |
424e28db AD |
237 | const tree = dijit.byId("filterTree"); |
238 | const items = tree.model.getCheckedItems(); | |
239 | const rv = []; | |
a740f4b5 AD |
240 | |
241 | items.each(function(item) { | |
242 | rv.push(tree.model.store.getValue(item, 'bare_id')); | |
243 | }); | |
244 | ||
245 | return rv; | |
246 | ||
91ff844a | 247 | } |
331900c6 | 248 | |
48f0adb0 AD |
249 | function removeSelectedLabels() { |
250 | ||
424e28db | 251 | const sel_rows = getSelectedLabels(); |
48f0adb0 AD |
252 | |
253 | if (sel_rows.length > 0) { | |
254 | ||
424e28db | 255 | const ok = confirm(__("Remove selected labels?")); |
48f0adb0 | 256 | |
69668465 | 257 | if (ok) { |
42c32916 | 258 | notify_progress("Removing selected labels..."); |
fb5662de | 259 | |
ef129fed AD |
260 | const query = { op: "pref-labels", method: "remove", |
261 | ids: sel_rows.toString() }; | |
a796bfc1 | 262 | |
ef129fed AD |
263 | xhrPost("backend.php", query, () => { |
264 | updateLabelList(); | |
265 | }); | |
69668465 | 266 | } |
48f0adb0 | 267 | } else { |
89cb787e | 268 | alert(__("No labels are selected.")); |
48f0adb0 | 269 | } |
90ac84df AD |
270 | |
271 | return false; | |
48f0adb0 AD |
272 | } |
273 | ||
e6cb77a0 AD |
274 | function removeSelectedUsers() { |
275 | ||
424e28db | 276 | const sel_rows = getSelectedUsers(); |
fb5662de | 277 | |
1bfe1d7b | 278 | if (sel_rows.length > 0) { |
fb5662de | 279 | |
424e28db | 280 | const ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed.")); |
fb5662de | 281 | |
1bfe1d7b AD |
282 | if (ok) { |
283 | notify_progress("Removing selected users..."); | |
fb5662de | 284 | |
ef129fed AD |
285 | const query = { op: "pref-users", method: "remove", |
286 | ids: sel_rows.toString() }; | |
fb5662de | 287 | |
ef129fed AD |
288 | xhrPost("backend.php", query, () => { |
289 | updateUsersList(); | |
1bfe1d7b | 290 | }); |
69668465 | 291 | } |
e6cb77a0 | 292 | |
1bfe1d7b AD |
293 | } else { |
294 | alert(__("No users are selected.")); | |
e6cb77a0 | 295 | } |
90ac84df AD |
296 | |
297 | return false; | |
e6cb77a0 AD |
298 | } |
299 | ||
48f0adb0 AD |
300 | function removeSelectedFilters() { |
301 | ||
424e28db | 302 | const sel_rows = getSelectedFilters(); |
fb5662de | 303 | |
1bfe1d7b | 304 | if (sel_rows.length > 0) { |
fb5662de | 305 | |
424e28db | 306 | const ok = confirm(__("Remove selected filters?")); |
fb5662de | 307 | |
1bfe1d7b AD |
308 | if (ok) { |
309 | notify_progress("Removing selected filters..."); | |
fb5662de | 310 | |
ef129fed AD |
311 | const query = { op: "pref-filters", method: "remove", |
312 | ids: sel_rows.toString() }; | |
fb5662de | 313 | |
ef129fed AD |
314 | xhrPost("backend.php", query, () => { |
315 | updateFilterList(); | |
1bfe1d7b | 316 | }); |
69668465 | 317 | } |
1bfe1d7b AD |
318 | } else { |
319 | alert(__("No filters are selected.")); | |
48f0adb0 | 320 | } |
90ac84df AD |
321 | |
322 | return false; | |
48f0adb0 AD |
323 | } |
324 | ||
83fe4d6d AD |
325 | function removeSelectedFeeds() { |
326 | ||
424e28db | 327 | const sel_rows = getSelectedFeeds(); |
fb5662de | 328 | |
1bfe1d7b | 329 | if (sel_rows.length > 0) { |
fb5662de | 330 | |
424e28db | 331 | const ok = confirm(__("Unsubscribe from selected feeds?")); |
fb5662de | 332 | |
1bfe1d7b | 333 | if (ok) { |
fb5662de | 334 | |
1bfe1d7b | 335 | notify_progress("Unsubscribing from selected feeds...", true); |
b6a6e262 | 336 | |
ef129fed AD |
337 | const query = { op: "pref-feeds", method: "remove", |
338 | ids: sel_rows.toString() }; | |
fb5662de | 339 | |
ef129fed AD |
340 | xhrPost("backend.php", query, () => { |
341 | updateFeedList(); | |
1bfe1d7b | 342 | }); |
69668465 | 343 | } |
71ad3959 | 344 | |
1bfe1d7b AD |
345 | } else { |
346 | alert(__("No feeds are selected.")); | |
71ad3959 | 347 | } |
fb5662de | 348 | |
90ac84df | 349 | return false; |
71ad3959 | 350 | } |
007bda35 | 351 | |
e6cb77a0 | 352 | function editSelectedUser() { |
424e28db | 353 | const rows = getSelectedUsers(); |
e6cb77a0 AD |
354 | |
355 | if (rows.length == 0) { | |
f3977cf5 | 356 | alert(__("No users are selected.")); |
e6cb77a0 AD |
357 | return; |
358 | } | |
359 | ||
360 | if (rows.length > 1) { | |
f3977cf5 | 361 | alert(__("Please select only one user.")); |
e6cb77a0 AD |
362 | return; |
363 | } | |
364 | ||
dbd9e2f1 AD |
365 | notify(""); |
366 | ||
e6cb77a0 AD |
367 | editUser(rows[0]); |
368 | } | |
369 | ||
370 | function resetSelectedUserPass() { | |
e6cb77a0 | 371 | |
424e28db | 372 | const rows = getSelectedUsers(); |
fb5662de | 373 | |
1bfe1d7b AD |
374 | if (rows.length == 0) { |
375 | alert(__("No users are selected.")); | |
376 | return; | |
377 | } | |
fb5662de | 378 | |
1bfe1d7b AD |
379 | if (rows.length > 1) { |
380 | alert(__("Please select only one user.")); | |
381 | return; | |
382 | } | |
fb5662de | 383 | |
424e28db | 384 | const ok = confirm(__("Reset password of selected user?")); |
fb5662de | 385 | |
1bfe1d7b AD |
386 | if (ok) { |
387 | notify_progress("Resetting password for selected user..."); | |
fb5662de | 388 | |
424e28db | 389 | const id = rows[0]; |
fb5662de | 390 | |
ef129fed AD |
391 | xhrPost("backend.php", { op: "pref-users", method: "resetPass", id: id }, (transport) => { |
392 | notify_info(transport.responseText, true); | |
1bfe1d7b | 393 | }); |
fbf7d545 | 394 | |
69668465 | 395 | } |
e6cb77a0 AD |
396 | } |
397 | ||
717f5e64 | 398 | function selectedUserDetails() { |
e6cb77a0 | 399 | |
424e28db | 400 | const rows = getSelectedUsers(); |
fb5662de | 401 | |
1bfe1d7b AD |
402 | if (rows.length == 0) { |
403 | alert(__("No users are selected.")); | |
404 | return; | |
405 | } | |
fb5662de | 406 | |
1bfe1d7b AD |
407 | if (rows.length > 1) { |
408 | alert(__("Please select only one user.")); | |
409 | return; | |
410 | } | |
fb5662de | 411 | |
ef129fed | 412 | const query = "backend.php?op=pref-users&method=userdetails&id=" + param_escape(rows[0]); |
d9afd9b2 | 413 | |
1bfe1d7b AD |
414 | if (dijit.byId("userDetailsDlg")) |
415 | dijit.byId("userDetailsDlg").destroyRecursive(); | |
d9afd9b2 | 416 | |
9dc5524d | 417 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
418 | id: "userDetailsDlg", |
419 | title: __("User details"), | |
420 | style: "width: 600px", | |
421 | execute: function () { | |
422 | dialog.hide(); | |
423 | }, | |
424 | href: query | |
425 | }); | |
717f5e64 | 426 | |
1bfe1d7b | 427 | dialog.show(); |
c6c3a07f AD |
428 | } |
429 | ||
a0d53889 AD |
430 | |
431 | function editSelectedFilter() { | |
424e28db | 432 | const rows = getSelectedFilters(); |
a0d53889 AD |
433 | |
434 | if (rows.length == 0) { | |
f3977cf5 | 435 | alert(__("No filters are selected.")); |
a0d53889 AD |
436 | return; |
437 | } | |
438 | ||
439 | if (rows.length > 1) { | |
f3977cf5 | 440 | alert(__("Please select only one filter.")); |
a0d53889 AD |
441 | return; |
442 | } | |
443 | ||
dbd9e2f1 AD |
444 | notify(""); |
445 | ||
a0d53889 AD |
446 | editFilter(rows[0]); |
447 | ||
448 | } | |
449 | ||
6aff7845 | 450 | function joinSelectedFilters() { |
424e28db | 451 | const rows = getSelectedFilters(); |
6aff7845 AD |
452 | |
453 | if (rows.length == 0) { | |
454 | alert(__("No filters are selected.")); | |
455 | return; | |
456 | } | |
457 | ||
424e28db | 458 | const ok = confirm(__("Combine selected filters?")); |
6aff7845 AD |
459 | |
460 | if (ok) { | |
461 | notify_progress("Joining filters..."); | |
462 | ||
ef129fed AD |
463 | xhrPost("backend.php", { op: "pref-filters", method: "join", ids: rows.toString() }, () => { |
464 | updateFilterList(); | |
465 | }); | |
6aff7845 AD |
466 | } |
467 | } | |
a0d53889 | 468 | |
508a81e1 | 469 | function editSelectedFeed() { |
424e28db | 470 | const rows = getSelectedFeeds(); |
508a81e1 AD |
471 | |
472 | if (rows.length == 0) { | |
f3977cf5 | 473 | alert(__("No feeds are selected.")); |
508a81e1 AD |
474 | return; |
475 | } | |
476 | ||
477 | if (rows.length > 1) { | |
1e5548db | 478 | return editSelectedFeeds(); |
508a81e1 AD |
479 | } |
480 | ||
dbd9e2f1 AD |
481 | notify(""); |
482 | ||
951906dc | 483 | editFeed(rows[0], {}); |
91ff844a AD |
484 | |
485 | } | |
486 | ||
758e1c4a | 487 | function editSelectedFeeds() { |
424e28db | 488 | const rows = getSelectedFeeds(); |
758e1c4a | 489 | |
1bfe1d7b AD |
490 | if (rows.length == 0) { |
491 | alert(__("No feeds are selected.")); | |
492 | return; | |
493 | } | |
05acc0d6 | 494 | |
1bfe1d7b | 495 | notify_progress("Loading, please wait..."); |
05acc0d6 | 496 | |
424e28db | 497 | const query = "backend.php?op=pref-feeds&method=editfeeds&ids=" + |
1bfe1d7b | 498 | param_escape(rows.toString()); |
755c8f95 | 499 | |
1bfe1d7b | 500 | console.log(query); |
755c8f95 | 501 | |
1bfe1d7b AD |
502 | if (dijit.byId("feedEditDlg")) |
503 | dijit.byId("feedEditDlg").destroyRecursive(); | |
755c8f95 | 504 | |
1bfe1d7b AD |
505 | new Ajax.Request("backend.php", { |
506 | parameters: query, | |
507 | onComplete: function (transport) { | |
755c8f95 | 508 | |
1bfe1d7b | 509 | notify(""); |
fb5662de | 510 | |
9dc5524d | 511 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
512 | id: "feedEditDlg", |
513 | title: __("Edit Multiple Feeds"), | |
514 | style: "width: 600px", | |
515 | getChildByName: function (name) { | |
424e28db | 516 | let rv = null; |
1bfe1d7b AD |
517 | this.getChildren().each( |
518 | function (child) { | |
519 | if (child.name == name) { | |
520 | rv = child; | |
521 | return; | |
755c8f95 | 522 | } |
1bfe1d7b AD |
523 | }); |
524 | return rv; | |
525 | }, | |
526 | toggleField: function (checkbox, elem, label) { | |
527 | this.getChildByName(elem).attr('disabled', !checkbox.checked); | |
528 | ||
529 | if ($(label)) | |
530 | if (checkbox.checked) | |
531 | $(label).removeClassName('insensitive'); | |
532 | else | |
533 | $(label).addClassName('insensitive'); | |
534 | ||
535 | }, | |
536 | execute: function () { | |
537 | if (this.validate() && confirm(__("Save changes to selected feeds?"))) { | |
ef129fed AD |
538 | const query = this.attr('value'); |
539 | ||
540 | //console.log(query); return; | |
1bfe1d7b AD |
541 | |
542 | /* Form.serialize ignores unchecked checkboxes */ | |
543 | ||
ef129fed | 544 | /*if (!query.match("&private=") && |
1bfe1d7b | 545 | this.getChildByName('private').attr('disabled') == false) { |
ef129fed | 546 | query.private = "false"; |
1bfe1d7b | 547 | } |
fb5662de | 548 | |
1bfe1d7b AD |
549 | try { |
550 | if (!query.match("&cache_images=") && | |
551 | this.getChildByName('cache_images').attr('disabled') == false) { | |
ef129fed | 552 | query.cache_images = "false"; |
755c8f95 | 553 | } |
1bfe1d7b AD |
554 | } catch (e) { |
555 | } | |
05acc0d6 | 556 | |
1bfe1d7b AD |
557 | try { |
558 | if (!query.match("&hide_images=") && | |
559 | this.getChildByName('hide_images').attr('disabled') == false) { | |
ef129fed | 560 | query.hide_images = "false"; |
755c8f95 | 561 | } |
1bfe1d7b AD |
562 | } catch (e) { |
563 | } | |
dd04ea81 | 564 | |
1bfe1d7b AD |
565 | if (!query.match("&include_in_digest=") && |
566 | this.getChildByName('include_in_digest').attr('disabled') == false) { | |
ef129fed | 567 | query.include_in_digest = "false"; |
1bfe1d7b | 568 | } |
dd04ea81 | 569 | |
1bfe1d7b AD |
570 | if (!query.match("&always_display_enclosures=") && |
571 | this.getChildByName('always_display_enclosures').attr('disabled') == false) { | |
ef129fed | 572 | query.always_display_enclosures = "false"; |
1bfe1d7b | 573 | } |
fb5662de | 574 | |
1bfe1d7b AD |
575 | if (!query.match("&mark_unread_on_update=") && |
576 | this.getChildByName('mark_unread_on_update').attr('disabled') == false) { | |
ef129fed AD |
577 | query.mark_unread_on_update = "false"; |
578 | }*/ | |
05acc0d6 | 579 | |
1bfe1d7b | 580 | notify_progress("Saving data...", true); |
758e1c4a | 581 | |
ef129fed AD |
582 | xhrPost("backend.php", query, () => { |
583 | dialog.hide(); | |
584 | updateFeedList(); | |
1bfe1d7b AD |
585 | }); |
586 | } | |
587 | }, | |
588 | content: transport.responseText | |
589 | }); | |
758e1c4a | 590 | |
1bfe1d7b | 591 | dialog.show(); |
e1218480 | 592 | |
1bfe1d7b AD |
593 | } |
594 | }); | |
595 | } | |
e1218480 | 596 | |
1bfe1d7b AD |
597 | function opmlImportComplete(iframe) { |
598 | if (!iframe.contentDocument.body.innerHTML) return false; | |
599 | ||
600 | Element.show(iframe); | |
601 | ||
602 | notify(''); | |
603 | ||
604 | if (dijit.byId('opmlImportDlg')) | |
605 | dijit.byId('opmlImportDlg').destroyRecursive(); | |
606 | ||
424e28db | 607 | const content = iframe.contentDocument.body.innerHTML; |
1bfe1d7b | 608 | |
424e28db | 609 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
610 | id: "opmlImportDlg", |
611 | title: __("OPML Import"), | |
612 | style: "width: 600px", | |
613 | onCancel: function () { | |
12b7b90c | 614 | window.location.reload(); |
1bfe1d7b AD |
615 | }, |
616 | execute: function () { | |
12b7b90c | 617 | window.location.reload(); |
1bfe1d7b AD |
618 | }, |
619 | content: content | |
620 | }); | |
e1218480 | 621 | |
1bfe1d7b | 622 | dialog.show(); |
e1218480 AD |
623 | } |
624 | ||
b6a6e262 | 625 | function opmlImport() { |
fb5662de | 626 | |
424e28db | 627 | const opml_file = $("opml_file"); |
9f311df6 AD |
628 | |
629 | if (opml_file.value.length == 0) { | |
d2d75353 | 630 | alert(__("Please choose an OPML file first.")); |
9f311df6 AD |
631 | return false; |
632 | } else { | |
4d7cd9ed | 633 | notify_progress("Importing, please wait...", true); |
55f34b81 AD |
634 | |
635 | Element.show("upload_iframe"); | |
636 | ||
9f311df6 AD |
637 | return true; |
638 | } | |
639 | } | |
640 | ||
55f34b81 | 641 | |
05acc0d6 | 642 | function updateFilterList() { |
424e28db AD |
643 | const user_search = $("filter_search"); |
644 | let search = ""; | |
310fa2dd AD |
645 | if (user_search) { search = user_search.value; } |
646 | ||
05acc0d6 | 647 | new Ajax.Request("backend.php", { |
310fa2dd | 648 | parameters: "?op=pref-filters&search=" + param_escape(search), |
05acc0d6 | 649 | onComplete: function(transport) { |
66665fba AD |
650 | dijit.byId('filterConfigTab').attr('content', transport.responseText); |
651 | notify(""); | |
05acc0d6 | 652 | } }); |
a0d53889 AD |
653 | } |
654 | ||
05acc0d6 AD |
655 | function updateLabelList() { |
656 | new Ajax.Request("backend.php", { | |
657 | parameters: "?op=pref-labels", | |
658 | onComplete: function(transport) { | |
cbe50c80 AD |
659 | dijit.byId('labelConfigTab').attr('content', transport.responseText); |
660 | notify(""); | |
05acc0d6 | 661 | } }); |
48f0adb0 AD |
662 | } |
663 | ||
4255b24c | 664 | function updatePrefsList() { |
b4e75b2a | 665 | new Ajax.Request("backend.php", { |
05acc0d6 | 666 | parameters: "?op=pref-prefs", |
fb5662de | 667 | onComplete: function(transport) { |
cbe50c80 AD |
668 | dijit.byId('genConfigTab').attr('content', transport.responseText); |
669 | notify(""); | |
e9802ead | 670 | } }); |
4255b24c AD |
671 | } |
672 | ||
2cbdc95b AD |
673 | function updateSystemList() { |
674 | new Ajax.Request("backend.php", { | |
675 | parameters: "?op=pref-system", | |
676 | onComplete: function(transport) { | |
677 | dijit.byId('systemConfigTab').attr('content', transport.responseText); | |
678 | notify(""); | |
679 | } }); | |
680 | } | |
681 | ||
05185108 | 682 | function selectTab(id, noupdate) { |
1bfe1d7b AD |
683 | if (!noupdate) { |
684 | notify_progress("Loading, please wait..."); | |
d62796de | 685 | |
1bfe1d7b AD |
686 | if (id == "feedConfig") { |
687 | updateFeedList(); | |
688 | } else if (id == "filterConfig") { | |
689 | updateFilterList(); | |
690 | } else if (id == "labelConfig") { | |
691 | updateLabelList(); | |
692 | } else if (id == "genConfig") { | |
693 | updatePrefsList(); | |
694 | } else if (id == "userConfig") { | |
695 | updateUsersList(); | |
696 | } else if (id == "systemConfig") { | |
697 | updateSystemList(); | |
f5a50b25 | 698 | } |
fb5662de | 699 | |
424e28db | 700 | const tab = dijit.byId(id + "Tab"); |
1bfe1d7b AD |
701 | dijit.byId("pref-tabs").selectChild(tab); |
702 | ||
a7565293 | 703 | } |
a7565293 AD |
704 | } |
705 | ||
a7565293 | 706 | function init_second_stage() { |
1bfe1d7b AD |
707 | document.onkeydown = pref_hotkey_handler; |
708 | loading_set_progress(50); | |
709 | notify(""); | |
b01b1b38 | 710 | |
424e28db | 711 | let tab = getURLParam('tab'); |
b01b1b38 | 712 | |
1bfe1d7b AD |
713 | if (tab) { |
714 | tab = dijit.byId(tab + "Tab"); | |
715 | if (tab) dijit.byId("pref-tabs").selectChild(tab); | |
716 | } | |
b01b1b38 | 717 | |
424e28db | 718 | const method = getURLParam('method'); |
556e5b46 | 719 | |
1bfe1d7b | 720 | if (method == 'editFeed') { |
424e28db | 721 | const param = getURLParam('methodparam'); |
78935092 | 722 | |
1bfe1d7b | 723 | window.setTimeout(function() { editFeed(param) }, 100); |
b2caf812 | 724 | } |
1bfe1d7b AD |
725 | |
726 | setTimeout(hotkey_prefix_timeout, 5*1000); | |
a0d53889 AD |
727 | } |
728 | ||
007bda35 | 729 | function init() { |
1bfe1d7b AD |
730 | window.onerror = function (message, filename, lineno, colno, error) { |
731 | report_error(message, filename, lineno, colno, error); | |
732 | }; | |
733 | ||
734 | require(["dojo/_base/kernel", | |
735 | "dojo/ready", | |
736 | "dojo/parser", | |
737 | "dojo/_base/loader", | |
738 | "dojo/_base/html", | |
739 | "dijit/ColorPalette", | |
740 | "dijit/Dialog", | |
741 | "dijit/form/Button", | |
742 | "dijit/form/CheckBox", | |
743 | "dijit/form/DropDownButton", | |
744 | "dijit/form/FilteringSelect", | |
12b7b90c | 745 | "dijit/form/MultiSelect", |
1bfe1d7b AD |
746 | "dijit/form/Form", |
747 | "dijit/form/RadioButton", | |
748 | "dijit/form/ComboButton", | |
749 | "dijit/form/Select", | |
750 | "dijit/form/SimpleTextarea", | |
751 | "dijit/form/TextBox", | |
752 | "dijit/form/ValidationTextBox", | |
753 | "dijit/InlineEditBox", | |
754 | "dijit/layout/AccordionContainer", | |
755 | "dijit/layout/AccordionPane", | |
756 | "dijit/layout/BorderContainer", | |
757 | "dijit/layout/ContentPane", | |
758 | "dijit/layout/TabContainer", | |
759 | "dijit/Menu", | |
760 | "dijit/ProgressBar", | |
761 | "dijit/Toolbar", | |
762 | "dijit/Tree", | |
763 | "dijit/tree/dndSource", | |
764 | "dojo/data/ItemFileWriteStore", | |
a3e2f1a9 AD |
765 | "lib/CheckBoxStoreModel", |
766 | "lib/CheckBoxTree", | |
767 | "fox/PrefFeedStore", | |
768 | "fox/PrefFilterStore", | |
1bfe1d7b AD |
769 | "fox/PrefFeedTree", |
770 | "fox/PrefFilterTree", | |
771 | "fox/PrefLabelTree"], function (dojo, ready, parser) { | |
772 | ||
773 | ready(function () { | |
774 | try { | |
775 | parser.parse(); | |
776 | ||
777 | loading_set_progress(50); | |
778 | ||
424e28db | 779 | const clientTzOffset = new Date().getTimezoneOffset() * 60; |
e2ec66a8 | 780 | |
1bfe1d7b AD |
781 | new Ajax.Request("backend.php", { |
782 | parameters: { | |
783 | op: "rpc", method: "sanityCheck", | |
784 | clientTzOffset: clientTzOffset | |
785 | }, | |
786 | onComplete: function (transport) { | |
787 | backend_sanity_check_callback(transport); | |
788 | } | |
fd539f28 | 789 | }); |
1bfe1d7b AD |
790 | } catch (e) { |
791 | exception_error(e); | |
792 | } | |
793 | }); | |
794 | }); | |
007bda35 | 795 | } |
b1895692 | 796 | |
b652c1b7 | 797 | |
1bfe1d7b | 798 | function validatePrefsReset() { |
424e28db | 799 | const ok = confirm(__("Reset to defaults?")); |
b652c1b7 | 800 | |
1bfe1d7b | 801 | if (ok) { |
b652c1b7 | 802 | |
424e28db | 803 | const query = "?op=pref-prefs&method=resetconfig"; |
1bfe1d7b | 804 | console.log(query); |
e9802ead | 805 | |
1bfe1d7b AD |
806 | new Ajax.Request("backend.php", { |
807 | parameters: query, | |
808 | onComplete: function(transport) { | |
809 | updatePrefsList(); | |
810 | notify_info(transport.responseText); | |
811 | } }); | |
b652c1b7 | 812 | |
b652c1b7 AD |
813 | } |
814 | ||
815 | return false; | |
816 | ||
69668465 | 817 | } |
f9cb39ac | 818 | |
d437c8cf | 819 | function pref_hotkey_handler(e) { |
b8cb4d08 | 820 | |
1bfe1d7b | 821 | if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; |
18606807 | 822 | |
424e28db AD |
823 | let keycode = false; |
824 | let shift_key = false; | |
746dcf42 | 825 | |
424e28db | 826 | const cmdline = $('cmdline'); |
78935092 | 827 | |
1bfe1d7b AD |
828 | try { |
829 | shift_key = e.shiftKey; | |
830 | } catch (e) { | |
746dcf42 | 831 | |
1bfe1d7b | 832 | } |
746dcf42 | 833 | |
1bfe1d7b AD |
834 | if (window.event) { |
835 | keycode = window.event.keyCode; | |
836 | } else if (e) { | |
837 | keycode = e.which; | |
838 | } | |
746dcf42 | 839 | |
424e28db | 840 | let keychar = String.fromCharCode(keycode); |
eec498c3 | 841 | |
1bfe1d7b AD |
842 | if (keycode == 27) { // escape |
843 | hotkey_prefix = false; | |
844 | } | |
746dcf42 | 845 | |
1bfe1d7b AD |
846 | if (keycode == 16) return; // ignore lone shift |
847 | if (keycode == 17) return; // ignore lone ctrl | |
746dcf42 | 848 | |
1bfe1d7b | 849 | if (!shift_key) keychar = keychar.toLowerCase(); |
b8cb4d08 | 850 | |
1bfe1d7b | 851 | var hotkeys = getInitParam("hotkeys"); |
b8cb4d08 | 852 | |
1bfe1d7b | 853 | if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) { |
78935092 | 854 | |
424e28db AD |
855 | const date = new Date(); |
856 | const ts = Math.round(date.getTime() / 1000); | |
78935092 | 857 | |
1bfe1d7b AD |
858 | hotkey_prefix = keychar; |
859 | hotkey_prefix_pressed = ts; | |
78935092 | 860 | |
1bfe1d7b AD |
861 | cmdline.innerHTML = keychar; |
862 | Element.show(cmdline); | |
78935092 | 863 | |
1bfe1d7b AD |
864 | return true; |
865 | } | |
746dcf42 | 866 | |
1bfe1d7b | 867 | Element.hide(cmdline); |
78935092 | 868 | |
424e28db | 869 | let hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; |
1bfe1d7b AD |
870 | hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey; |
871 | hotkey_prefix = false; | |
8d727bfc | 872 | |
424e28db | 873 | let hotkey_action = false; |
1bfe1d7b | 874 | var hotkeys = getInitParam("hotkeys"); |
746dcf42 | 875 | |
424e28db | 876 | for (const sequence in hotkeys[1]) { |
1bfe1d7b AD |
877 | if (sequence == hotkey) { |
878 | hotkey_action = hotkeys[1][sequence]; | |
879 | break; | |
746dcf42 | 880 | } |
1bfe1d7b | 881 | } |
746dcf42 | 882 | |
1bfe1d7b | 883 | switch (hotkey_action) { |
b8cb4d08 AD |
884 | case "feed_subscribe": |
885 | quickAddFeed(); | |
4ba1f8bb | 886 | return false; |
b8cb4d08 AD |
887 | case "create_label": |
888 | addLabel(); | |
4ba1f8bb | 889 | return false; |
b8cb4d08 AD |
890 | case "create_filter": |
891 | quickAddFilter(); | |
4ba1f8bb | 892 | return false; |
b8cb4d08 AD |
893 | case "help_dialog": |
894 | //helpDialog("prefs"); | |
895 | return false; | |
896 | default: | |
897 | console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey); | |
d437c8cf AD |
898 | } |
899 | } | |
900 | ||
5ef071e0 | 901 | function removeCategory(id, item) { |
350468d0 | 902 | |
424e28db | 903 | const ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name)); |
da1f74c9 | 904 | |
1bfe1d7b | 905 | if (ok) { |
424e28db | 906 | const query = "?op=pref-feeds&method=removeCat&ids=" + |
1bfe1d7b | 907 | param_escape(id); |
fb5662de | 908 | |
1bfe1d7b | 909 | notify_progress("Removing category..."); |
fb5662de | 910 | |
1bfe1d7b AD |
911 | new Ajax.Request("backend.php", { |
912 | parameters: query, | |
913 | onComplete: function (transport) { | |
914 | notify(''); | |
915 | updateFeedList(); | |
5ef071e0 | 916 | } |
1bfe1d7b | 917 | }); |
5ef071e0 AD |
918 | } |
919 | } | |
fb5662de | 920 | |
fd26d5bf AD |
921 | function removeSelectedCategories() { |
922 | ||
424e28db | 923 | const sel_rows = getSelectedCategories(); |
fd26d5bf AD |
924 | |
925 | if (sel_rows.length > 0) { | |
926 | ||
424e28db | 927 | const ok = confirm(__("Remove selected categories?")); |
fd26d5bf AD |
928 | |
929 | if (ok) { | |
930 | notify_progress("Removing selected categories..."); | |
931 | ||
424e28db | 932 | const query = "?op=pref-feeds&method=removeCat&ids="+ |
fd26d5bf AD |
933 | param_escape(sel_rows.toString()); |
934 | ||
935 | new Ajax.Request("backend.php", { | |
936 | parameters: query, | |
937 | onComplete: function(transport) { | |
938 | updateFeedList(); | |
939 | } }); | |
940 | ||
941 | } | |
942 | } else { | |
943 | alert(__("No categories are selected.")); | |
944 | } | |
945 | ||
946 | return false; | |
947 | } | |
948 | ||
5ef071e0 | 949 | function createCategory() { |
424e28db | 950 | const title = prompt(__("Category title:")); |
fb5662de | 951 | |
1bfe1d7b | 952 | if (title) { |
da1f74c9 | 953 | |
1bfe1d7b | 954 | notify_progress("Creating category..."); |
da1f74c9 | 955 | |
424e28db | 956 | const query = "?op=pref-feeds&method=addCat&cat=" + |
1bfe1d7b | 957 | param_escape(title); |
da1f74c9 | 958 | |
1bfe1d7b AD |
959 | new Ajax.Request("backend.php", { |
960 | parameters: query, | |
961 | onComplete: function (transport) { | |
962 | notify(''); | |
963 | updateFeedList(); | |
964 | } | |
965 | }); | |
a349077c | 966 | } |
9c483746 | 967 | } |
a3656a41 | 968 | |
8ffd2011 | 969 | function showInactiveFeeds() { |
424e28db | 970 | const query = "backend.php?op=pref-feeds&method=inactiveFeeds"; |
8ffd2011 | 971 | |
1bfe1d7b AD |
972 | if (dijit.byId("inactiveFeedsDlg")) |
973 | dijit.byId("inactiveFeedsDlg").destroyRecursive(); | |
8ffd2011 | 974 | |
9dc5524d | 975 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
976 | id: "inactiveFeedsDlg", |
977 | title: __("Feeds without recent updates"), | |
978 | style: "width: 600px", | |
979 | getSelectedFeeds: function () { | |
980 | return getSelectedTableRowIds("prefInactiveFeedList"); | |
981 | }, | |
982 | removeSelected: function () { | |
424e28db | 983 | const sel_rows = this.getSelectedFeeds(); |
8ffd2011 | 984 | |
1bfe1d7b | 985 | console.log(sel_rows); |
8ffd2011 | 986 | |
1bfe1d7b | 987 | if (sel_rows.length > 0) { |
424e28db | 988 | const ok = confirm(__("Remove selected feeds?")); |
8ffd2011 | 989 | |
1bfe1d7b AD |
990 | if (ok) { |
991 | notify_progress("Removing selected feeds...", true); | |
8ffd2011 | 992 | |
424e28db | 993 | const query = "?op=pref-feeds&method=remove&ids=" + |
1bfe1d7b | 994 | param_escape(sel_rows.toString()); |
8ffd2011 | 995 | |
1bfe1d7b AD |
996 | new Ajax.Request("backend.php", { |
997 | parameters: query, | |
998 | onComplete: function (transport) { | |
999 | notify(''); | |
1000 | dialog.hide(); | |
1001 | updateFeedList(); | |
1002 | } | |
1003 | }); | |
8ffd2011 | 1004 | } |
8ffd2011 | 1005 | |
1bfe1d7b AD |
1006 | } else { |
1007 | alert(__("No feeds are selected.")); | |
1008 | } | |
1009 | }, | |
1010 | execute: function () { | |
1011 | if (this.validate()) { | |
1012 | } | |
1013 | }, | |
1014 | href: query | |
1015 | }); | |
8ffd2011 | 1016 | |
1bfe1d7b | 1017 | dialog.show(); |
8ffd2011 AD |
1018 | } |
1019 | ||
ef7b7bbd | 1020 | function opmlRegenKey() { |
424e28db | 1021 | const ok = confirm(__("Replace current OPML publishing address with a new one?")); |
ef7b7bbd | 1022 | |
1bfe1d7b | 1023 | if (ok) { |
fb5662de | 1024 | |
1bfe1d7b | 1025 | notify_progress("Trying to change address...", true); |
fb5662de | 1026 | |
424e28db | 1027 | const query = "?op=pref-feeds&method=regenOPMLKey"; |
fb5662de | 1028 | |
1bfe1d7b AD |
1029 | new Ajax.Request("backend.php", { |
1030 | parameters: query, | |
1031 | onComplete: function (transport) { | |
424e28db | 1032 | const reply = JSON.parse(transport.responseText); |
91d16ff1 | 1033 | |
424e28db | 1034 | const new_link = reply.link; |
fb5662de | 1035 | |
424e28db | 1036 | const e = $('pub_opml_url'); |
fb5662de | 1037 | |
1bfe1d7b AD |
1038 | if (new_link) { |
1039 | e.href = new_link; | |
1040 | e.innerHTML = new_link; | |
fb5662de | 1041 | |
1bfe1d7b | 1042 | new Effect.Highlight(e); |
ef7b7bbd | 1043 | |
1bfe1d7b | 1044 | notify(''); |
fb5662de | 1045 | |
1bfe1d7b AD |
1046 | } else { |
1047 | notify_error("Could not change feed URL."); | |
1048 | } | |
1049 | } | |
1050 | }); | |
ef7b7bbd MK |
1051 | } |
1052 | return false; | |
1053 | } | |
c4a36709 | 1054 | |
b8776a07 | 1055 | function labelColorReset() { |
424e28db | 1056 | const labels = getSelectedLabels(); |
b8776a07 | 1057 | |
1bfe1d7b | 1058 | if (labels.length > 0) { |
424e28db | 1059 | const ok = confirm(__("Reset selected labels to default colors?")); |
b8776a07 | 1060 | |
1bfe1d7b | 1061 | if (ok) { |
424e28db | 1062 | const query = "?op=pref-labels&method=colorreset&ids=" + |
1bfe1d7b | 1063 | param_escape(labels.toString()); |
f695cdb2 | 1064 | |
1bfe1d7b AD |
1065 | new Ajax.Request("backend.php", { |
1066 | parameters: query, | |
1067 | onComplete: function (transport) { | |
1068 | updateLabelList(); | |
1069 | } | |
1070 | }); | |
b8776a07 AD |
1071 | } |
1072 | ||
1bfe1d7b AD |
1073 | } else { |
1074 | alert(__("No labels are selected.")); | |
b8776a07 AD |
1075 | } |
1076 | } | |
1077 | ||
a5819bb3 AD |
1078 | function inPreferences() { |
1079 | return true; | |
1080 | } | |
d9084cf2 AD |
1081 | |
1082 | function editProfiles() { | |
22988692 | 1083 | |
1bfe1d7b AD |
1084 | if (dijit.byId("profileEditDlg")) |
1085 | dijit.byId("profileEditDlg").destroyRecursive(); | |
22988692 | 1086 | |
424e28db | 1087 | const query = "backend.php?op=pref-prefs&method=editPrefProfiles"; |
22988692 | 1088 | |
9dc5524d | 1089 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
1090 | id: "profileEditDlg", |
1091 | title: __("Settings Profiles"), | |
1092 | style: "width: 600px", | |
1093 | getSelectedProfiles: function () { | |
1094 | return getSelectedTableRowIds("prefFeedProfileList"); | |
1095 | }, | |
1096 | removeSelected: function () { | |
424e28db | 1097 | const sel_rows = this.getSelectedProfiles(); |
fb5662de | 1098 | |
1bfe1d7b | 1099 | if (sel_rows.length > 0) { |
424e28db | 1100 | const ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed.")); |
fb5662de | 1101 | |
1bfe1d7b AD |
1102 | if (ok) { |
1103 | notify_progress("Removing selected profiles...", true); | |
fb5662de | 1104 | |
ef129fed AD |
1105 | const query = { op: "rpc", method: "remprofiles", |
1106 | ids: sel_rows.toString() }; | |
fb5662de | 1107 | |
ef129fed AD |
1108 | xhrPost("backend.php", query, () => { |
1109 | notify(''); | |
1110 | editProfiles(); | |
1bfe1d7b | 1111 | }); |
22988692 | 1112 | } |
fb5662de | 1113 | |
1bfe1d7b AD |
1114 | } else { |
1115 | alert(__("No profiles are selected.")); | |
1116 | } | |
1117 | }, | |
1118 | activateProfile: function () { | |
424e28db | 1119 | const sel_rows = this.getSelectedProfiles(); |
fb5662de | 1120 | |
1bfe1d7b | 1121 | if (sel_rows.length == 1) { |
fb5662de | 1122 | |
424e28db | 1123 | const ok = confirm(__("Activate selected profile?")); |
fb5662de | 1124 | |
1bfe1d7b AD |
1125 | if (ok) { |
1126 | notify_progress("Loading, please wait..."); | |
fb5662de | 1127 | |
ef129fed AD |
1128 | xhrPost("backend.php", { op: "rpc", method: "setprofile", id: sel_rows.toString() }, () => { |
1129 | window.location.reload(); | |
1130 | }); | |
fb5662de | 1131 | } |
22988692 | 1132 | |
1bfe1d7b AD |
1133 | } else { |
1134 | alert(__("Please choose a profile to activate.")); | |
1135 | } | |
1136 | }, | |
1137 | addProfile: function () { | |
1138 | if (this.validate()) { | |
1139 | notify_progress("Creating profile...", true); | |
22988692 | 1140 | |
ef129fed | 1141 | const query = { op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile }; |
22988692 | 1142 | |
ef129fed AD |
1143 | xhrPost("backend.php", query, () => { |
1144 | notify(''); | |
1145 | editProfiles(); | |
1bfe1d7b | 1146 | }); |
22988692 | 1147 | |
1bfe1d7b AD |
1148 | } |
1149 | }, | |
1150 | execute: function () { | |
1151 | if (this.validate()) { | |
1152 | } | |
1153 | }, | |
1154 | href: query | |
1155 | }); | |
1156 | ||
1157 | dialog.show(); | |
d9084cf2 AD |
1158 | } |
1159 | ||
ef129fed | 1160 | /* |
d9084cf2 AD |
1161 | function activatePrefProfile() { |
1162 | ||
424e28db | 1163 | const sel_rows = getSelectedFeedCats(); |
d9084cf2 AD |
1164 | |
1165 | if (sel_rows.length == 1) { | |
1166 | ||
424e28db | 1167 | const ok = confirm(__("Activate selected profile?")); |
d9084cf2 AD |
1168 | |
1169 | if (ok) { | |
1170 | notify_progress("Loading, please wait..."); | |
fb5662de | 1171 | |
ef129fed AD |
1172 | xhrPost("backend.php", { op: "rpc", method: "setprofile", id: sel_rows.toString() }, () => { |
1173 | window.location.reload(); | |
1174 | }); | |
d9084cf2 AD |
1175 | } |
1176 | ||
1177 | } else { | |
1178 | alert(__("Please choose a profile to activate.")); | |
1179 | } | |
1180 | ||
1181 | return false; | |
ef129fed | 1182 | } */ |
d9084cf2 | 1183 | |
8d86f15f AD |
1184 | function clearFeedAccessKeys() { |
1185 | ||
424e28db | 1186 | const ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?")); |
8d86f15f AD |
1187 | |
1188 | if (ok) { | |
1189 | notify_progress("Clearing URLs..."); | |
1190 | ||
ef129fed AD |
1191 | xhrPost("backend.php", { op: "pref-feeds", method: "clearKeys" }, () => { |
1192 | notify_info("Generated URLs cleared."); | |
1193 | }); | |
8d86f15f | 1194 | } |
fb5662de | 1195 | |
8d86f15f AD |
1196 | return false; |
1197 | } | |
1198 | ||
a86ba0a6 | 1199 | function resetFilterOrder() { |
1bfe1d7b | 1200 | notify_progress("Loading, please wait..."); |
a86ba0a6 | 1201 | |
ef129fed AD |
1202 | xhrPost("backend.php", { op: "pref-filters", method: "filtersortreset" }, () => { |
1203 | updateFilterList(); | |
1204 | }); | |
a86ba0a6 AD |
1205 | } |
1206 | ||
1207 | ||
1bfe1d7b AD |
1208 | function resetFeedOrder() { |
1209 | notify_progress("Loading, please wait..."); | |
7b8a143f | 1210 | |
ef129fed AD |
1211 | xhrPost("backend.php", { op: "pref-feeds", method: "feedsortreset" }, () => { |
1212 | updateFeedList(); | |
1213 | }); | |
7b8a143f AD |
1214 | } |
1215 | ||
1216 | function resetCatOrder() { | |
1bfe1d7b | 1217 | notify_progress("Loading, please wait..."); |
7b8a143f | 1218 | |
ef129fed AD |
1219 | xhrPost("backend.php", { op: "pref-feeds", method: "catsortreset" }, () => { |
1220 | updateFeedList(); | |
1bfe1d7b | 1221 | }); |
7b8a143f AD |
1222 | } |
1223 | ||
05185108 | 1224 | function editCat(id, item) { |
424e28db | 1225 | const new_name = prompt(__('Rename category to:'), item.name); |
7b8a143f | 1226 | |
1bfe1d7b | 1227 | if (new_name && new_name != item.name) { |
7b8a143f | 1228 | |
1bfe1d7b | 1229 | notify_progress("Loading, please wait..."); |
7b8a143f | 1230 | |
ef129fed AD |
1231 | xhrPost("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => { |
1232 | updateFeedList(); | |
1bfe1d7b | 1233 | }); |
7b8a143f AD |
1234 | } |
1235 | } | |
fb8b2153 | 1236 | |
05185108 | 1237 | function editLabel(id) { |
424e28db | 1238 | const query = "backend.php?op=pref-labels&method=edit&id=" + |
1bfe1d7b AD |
1239 | param_escape(id); |
1240 | ||
1241 | if (dijit.byId("labelEditDlg")) | |
1242 | dijit.byId("labelEditDlg").destroyRecursive(); | |
1243 | ||
424e28db | 1244 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
1245 | id: "labelEditDlg", |
1246 | title: __("Label Editor"), | |
1247 | style: "width: 600px", | |
1248 | setLabelColor: function (id, fg, bg) { | |
1249 | ||
424e28db AD |
1250 | let kind = ''; |
1251 | let color = ''; | |
1bfe1d7b AD |
1252 | |
1253 | if (fg && bg) { | |
1254 | kind = 'both'; | |
1255 | } else if (fg) { | |
1256 | kind = 'fg'; | |
1257 | color = fg; | |
1258 | } else if (bg) { | |
1259 | kind = 'bg'; | |
1260 | color = bg; | |
1261 | } | |
fb5662de | 1262 | |
424e28db | 1263 | const e = $("LICID-" + id); |
fb5662de | 1264 | |
1bfe1d7b AD |
1265 | if (e) { |
1266 | if (fg) e.style.color = fg; | |
1267 | if (bg) e.style.backgroundColor = bg; | |
1268 | } | |
05acc0d6 | 1269 | |
ef129fed AD |
1270 | const query = { op: "pref-labels", method: "colorset", kind: kind, |
1271 | ids: id, fg: fg, bg: bg, color: color }; | |
1272 | ||
1273 | xhrPost("backend.php", query, () => { | |
1274 | updateFilterList(); // maybe there's labels in there | |
1275 | }); | |
48b05a29 | 1276 | |
1bfe1d7b AD |
1277 | }, |
1278 | execute: function () { | |
1279 | if (this.validate()) { | |
424e28db AD |
1280 | const caption = this.attr('value').caption; |
1281 | const fg_color = this.attr('value').fg_color; | |
1282 | const bg_color = this.attr('value').bg_color; | |
48b05a29 | 1283 | |
1bfe1d7b AD |
1284 | dijit.byId('labelTree').setNameById(id, caption); |
1285 | this.setLabelColor(id, fg_color, bg_color); | |
1286 | this.hide(); | |
fb8b2153 | 1287 | |
ef129fed AD |
1288 | xhrPost("backend.php", this.attr('value'), () => { |
1289 | updateFilterList(); // maybe there's labels in there | |
1bfe1d7b AD |
1290 | }); |
1291 | } | |
1292 | }, | |
1293 | href: query | |
1294 | }); | |
fb8b2153 | 1295 | |
1bfe1d7b | 1296 | dialog.show(); |
fb8b2153 | 1297 | } |
018caf6f | 1298 | |
88e4e597 AD |
1299 | |
1300 | function customizeCSS() { | |
424e28db | 1301 | const query = "backend.php?op=pref-prefs&method=customizeCSS"; |
88e4e597 | 1302 | |
1bfe1d7b AD |
1303 | if (dijit.byId("cssEditDlg")) |
1304 | dijit.byId("cssEditDlg").destroyRecursive(); | |
88e4e597 | 1305 | |
424e28db | 1306 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
1307 | id: "cssEditDlg", |
1308 | title: __("Customize stylesheet"), | |
1309 | style: "width: 600px", | |
1310 | execute: function () { | |
1311 | notify_progress('Saving data...', true); | |
ef129fed AD |
1312 | |
1313 | xhrPost("backend.php", this.attr('value'), () => { | |
1314 | window.location.reload(); | |
1bfe1d7b | 1315 | }); |
88e4e597 | 1316 | |
1bfe1d7b AD |
1317 | }, |
1318 | href: query | |
1319 | }); | |
88e4e597 | 1320 | |
1bfe1d7b | 1321 | dialog.show(); |
88e4e597 | 1322 | } |
3d72afa1 AD |
1323 | |
1324 | function insertSSLserial(value) { | |
1bfe1d7b | 1325 | dijit.byId("SSL_CERT_SERIAL").attr('value', value); |
3d72afa1 | 1326 | } |
373266eb | 1327 | |
41f68571 | 1328 | function gotoExportOpml(filename, settings) { |
424e28db | 1329 | const tmp = settings ? 1 : 0; |
d75409bf | 1330 | document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp; |
41f68571 AD |
1331 | } |
1332 | ||
1333 | ||
33f0fdd0 | 1334 | function batchSubscribe() { |
424e28db | 1335 | const query = "backend.php?op=pref-feeds&method=batchSubscribe"; |
33f0fdd0 | 1336 | |
1bfe1d7b AD |
1337 | // overlapping widgets |
1338 | if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); | |
1339 | if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); | |
33f0fdd0 | 1340 | |
9dc5524d | 1341 | const dialog = new dijit.Dialog({ |
1bfe1d7b AD |
1342 | id: "batchSubDlg", |
1343 | title: __("Batch subscribe"), | |
1344 | style: "width: 600px", | |
1345 | execute: function () { | |
1346 | if (this.validate()) { | |
1bfe1d7b | 1347 | notify_progress(__("Subscribing to feeds..."), true); |
33f0fdd0 | 1348 | |
ef129fed AD |
1349 | xhrPost("backend.php", this.attr('value'), () => { |
1350 | notify(""); | |
1351 | updateFeedList(); | |
1352 | dialog.hide(); | |
1bfe1d7b AD |
1353 | }); |
1354 | } | |
1355 | }, | |
1356 | href: query | |
1357 | }); | |
33f0fdd0 | 1358 | |
1bfe1d7b | 1359 | dialog.show(); |
33f0fdd0 | 1360 | } |
55f34b81 | 1361 | |
1bfe1d7b AD |
1362 | function clearPluginData(name) { |
1363 | if (confirm(__("Clear stored data for this plugin?"))) { | |
f9ebb32c AD |
1364 | notify_progress("Loading, please wait..."); |
1365 | ||
ef129fed AD |
1366 | xhrPost("backend.php", { op: "pref-prefs", method: "clearplugindata", name: name }, () => { |
1367 | notify(''); | |
1368 | updatePrefsList(); | |
1369 | }); | |
5d9abb1e AD |
1370 | } |
1371 | } | |
52e7b5a0 AD |
1372 | |
1373 | function clearSqlLog() { | |
1374 | ||
1375 | if (confirm(__("Clear all messages in the error log?"))) { | |
1376 | ||
1377 | notify_progress("Loading, please wait..."); | |
52e7b5a0 | 1378 | |
ef129fed AD |
1379 | xhrPost("backend.php", { op: "pref-system", method: "clearLog" }, () => { |
1380 | updateSystemList(); | |
1381 | }); | |
52e7b5a0 AD |
1382 | |
1383 | } | |
1384 | } | |
1385 | ||
ab235fc5 AD |
1386 | function updateSelectedPrompt() { |
1387 | // no-op shim for toggleSelectedRow() | |
1388 | } | |
e2e24799 | 1389 |