]>
Commit | Line | Data |
---|---|---|
007bda35 AD |
1 | var xmlhttp = false; |
2 | ||
91ff844a | 3 | var active_feed_cat = false; |
f5a50b25 | 4 | var active_tab = false; |
c6232e43 | 5 | var feed_to_expand = false; |
f5a50b25 | 6 | |
a58069db | 7 | var xmlhttp = Ajax.getTransport(); |
007bda35 | 8 | |
a7565293 AD |
9 | var init_params = new Array(); |
10 | ||
e513a74a | 11 | var caller_subop = false; |
7a09510c | 12 | var sanity_check_done = false; |
746dcf42 | 13 | var hotkey_prefix = false; |
7a09510c | 14 | |
288487e4 AD |
15 | function infobox_callback() { |
16 | if (xmlhttp.readyState == 4) { | |
17 | infobox_callback2(xmlhttp); | |
18 | } | |
19 | } | |
20 | ||
21 | function infobox_submit_callback() { | |
22 | if (xmlhttp.readyState == 4) { | |
23 | infobox_submit_callback2(xmlhttp); | |
24 | } | |
25 | } | |
26 | ||
27 | ||
e4f4b46f | 28 | function replace_pubkey_callback() { |
c6232e43 AD |
29 | if (xmlhttp.readyState == 4) { |
30 | try { | |
e4f4b46f AD |
31 | var link = document.getElementById("pubGenAddress"); |
32 | ||
33 | if (xmlhttp.responseXML) { | |
34 | ||
945c243e AD |
35 | var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0]; |
36 | ||
37 | if (new_link) { | |
38 | link.href = new_link.firstChild.nodeValue; | |
e635d56a | 39 | //link.innerHTML = new_link.firstChild.nodeValue; |
945c243e | 40 | |
3076c7b8 AD |
41 | new Effect.Highlight(link); |
42 | ||
e635d56a | 43 | notify_info("Published feed URL changed."); |
945c243e | 44 | } else { |
e635d56a | 45 | notify_error("Could not change feed URL."); |
945c243e | 46 | } |
e4f4b46f AD |
47 | |
48 | } else { | |
e635d56a | 49 | notify_error("Could not change feed URL."); |
e4f4b46f | 50 | } |
c6232e43 | 51 | } catch (e) { |
e4f4b46f | 52 | exception_error("replace_pubkey_callback", e); |
c6232e43 AD |
53 | } |
54 | } | |
945c243e | 55 | } |
c6232e43 | 56 | |
e4f4b46f | 57 | function expand_feed_callback() { |
bc0ed820 AD |
58 | if (xmlhttp.readyState == 4) { |
59 | try { | |
e4f4b46f | 60 | var container = document.getElementById("BRDET-" + feed_to_expand); |
bc0ed820 | 61 | container.innerHTML=xmlhttp.responseText; |
34a01a20 | 62 | // container.style.display = "block"; |
051c4d56 | 63 | Effect.Appear(container, {duration : 0.5}); |
bc0ed820 | 64 | } catch (e) { |
e4f4b46f | 65 | exception_error("expand_feed_callback", e); |
bc0ed820 AD |
66 | } |
67 | } | |
68 | } | |
69 | ||
007bda35 | 70 | function feedlist_callback() { |
007bda35 | 71 | if (xmlhttp.readyState == 4) { |
47c6c988 AD |
72 | try { |
73 | var container = document.getElementById('prefContent'); | |
74 | container.innerHTML=xmlhttp.responseText; | |
a7f22b70 | 75 | selectTab("feedConfig", true); |
e513a74a AD |
76 | |
77 | if (caller_subop) { | |
78 | var tuple = caller_subop.split(":"); | |
79 | if (tuple[0] == 'editFeed') { | |
80 | window.setTimeout('editFeed('+tuple[1]+')', 100); | |
81 | } | |
82 | ||
83 | caller_subop = false; | |
84 | } | |
23943c9b AD |
85 | if (typeof correctPNG != 'undefined') { |
86 | correctPNG(); | |
87 | } | |
7f74a9da | 88 | notify(""); |
08827aaf AD |
89 | remove_splash(); |
90 | ||
47c6c988 AD |
91 | } catch (e) { |
92 | exception_error("feedlist_callback", e); | |
961513a3 | 93 | } |
007bda35 AD |
94 | } |
95 | } | |
96 | ||
442d77f1 AD |
97 | /* stub for subscription dialog */ |
98 | ||
288487e4 | 99 | function dlg_frefresh_callback(transport) { |
442d77f1 | 100 | |
288487e4 AD |
101 | try { |
102 | var container = document.getElementById('prefContent'); | |
103 | container.innerHTML=transport.responseText; | |
104 | selectTab("feedConfig", true); | |
442d77f1 | 105 | |
288487e4 AD |
106 | if (caller_subop) { |
107 | var tuple = caller_subop.split(":"); | |
108 | if (tuple[0] == 'editFeed') { | |
109 | window.setTimeout('editFeed('+tuple[1]+')', 100); | |
110 | } | |
442d77f1 | 111 | |
288487e4 | 112 | caller_subop = false; |
442d77f1 | 113 | } |
288487e4 AD |
114 | if (typeof correctPNG != 'undefined') { |
115 | correctPNG(); | |
116 | } | |
117 | notify(""); | |
118 | } catch (e) { | |
119 | exception_error("feedlist_callback", e); | |
442d77f1 | 120 | } |
288487e4 | 121 | |
442d77f1 AD |
122 | } |
123 | ||
a0d53889 | 124 | function filterlist_callback() { |
f5a50b25 | 125 | var container = document.getElementById('prefContent'); |
a0d53889 AD |
126 | if (xmlhttp.readyState == 4) { |
127 | container.innerHTML=xmlhttp.responseText; | |
23943c9b AD |
128 | if (typeof correctPNG != 'undefined') { |
129 | correctPNG(); | |
130 | } | |
7f74a9da | 131 | notify(""); |
08827aaf | 132 | remove_splash(); |
a0d53889 AD |
133 | } |
134 | } | |
135 | ||
48f0adb0 | 136 | function labellist_callback() { |
ceb30ba4 AD |
137 | |
138 | try { | |
139 | ||
140 | var container = document.getElementById('prefContent'); | |
141 | if (xmlhttp.readyState == 4) { | |
142 | closeInfoBox(); | |
143 | container.innerHTML=xmlhttp.responseText; | |
144 | ||
145 | if (document.getElementById("prefLabelList")) { | |
146 | var elems = document.getElementById("prefLabelList").getElementsByTagName("SPAN"); | |
147 | ||
148 | for (var i = 0; i < elems.length; i++) { | |
149 | if (elems[i].id && elems[i].id.match("LILT-")) { | |
150 | ||
151 | var id = elems[i].id.replace("LILT-", ""); | |
152 | new Ajax.InPlaceEditor(elems[i], | |
9c5e85fe AD |
153 | 'backend.php?op=pref-labels&subop=save&id=' + id, |
154 | {cols: 20, rows: 1}); | |
ceb30ba4 AD |
155 | } |
156 | } | |
48f0adb0 | 157 | } |
ceb30ba4 AD |
158 | |
159 | if (typeof correctPNG != 'undefined') { | |
160 | correctPNG(); | |
48f0adb0 | 161 | } |
ceb30ba4 AD |
162 | notify(""); |
163 | remove_splash(); | |
48f0adb0 | 164 | } |
ceb30ba4 AD |
165 | |
166 | } catch (e) { | |
167 | exception_error("labellist_callback", e); | |
48f0adb0 AD |
168 | } |
169 | } | |
4255b24c | 170 | |
c6232e43 AD |
171 | function feed_browser_callback() { |
172 | var container = document.getElementById('prefContent'); | |
173 | if (xmlhttp.readyState == 4) { | |
174 | container.innerHTML=xmlhttp.responseText; | |
7f74a9da | 175 | notify(""); |
08827aaf | 176 | remove_splash(); |
c6232e43 AD |
177 | } |
178 | } | |
179 | ||
e6cb77a0 AD |
180 | function userlist_callback() { |
181 | var container = document.getElementById('prefContent'); | |
182 | if (xmlhttp.readyState == 4) { | |
183 | container.innerHTML=xmlhttp.responseText; | |
7f74a9da | 184 | notify(""); |
08827aaf | 185 | remove_splash(); |
e6cb77a0 AD |
186 | } |
187 | } | |
188 | ||
4255b24c AD |
189 | function prefslist_callback() { |
190 | var container = document.getElementById('prefContent'); | |
191 | if (xmlhttp.readyState == 4) { | |
4255b24c | 192 | container.innerHTML=xmlhttp.responseText; |
7f74a9da | 193 | notify(""); |
08827aaf | 194 | remove_splash(); |
4255b24c AD |
195 | } |
196 | } | |
197 | ||
b1895692 AD |
198 | function gethelp_callback() { |
199 | var container = document.getElementById('prefHelpBox'); | |
200 | if (xmlhttp.readyState == 4) { | |
201 | ||
202 | container.innerHTML = xmlhttp.responseText; | |
203 | container.style.display = "block"; | |
204 | ||
205 | } | |
206 | } | |
4255b24c | 207 | |
0e091d38 | 208 | function notify_callback() { |
0e091d38 | 209 | if (xmlhttp.readyState == 4) { |
42c32916 AD |
210 | notify_info(xmlhttp.responseText); |
211 | } | |
0e091d38 AD |
212 | } |
213 | ||
b652c1b7 AD |
214 | function prefs_reset_callback() { |
215 | if (xmlhttp.readyState == 4) { | |
216 | notify_info(xmlhttp.responseText); | |
217 | selectTab(); | |
218 | } | |
219 | } | |
220 | ||
d95bd220 AD |
221 | |
222 | function changepass_callback() { | |
42395d28 AD |
223 | try { |
224 | if (xmlhttp.readyState == 4) { | |
225 | ||
226 | if (xmlhttp.responseText.indexOf("ERROR: ") == 0) { | |
227 | notify_error(xmlhttp.responseText.replace("ERROR: ", "")); | |
228 | } else { | |
229 | notify_info(xmlhttp.responseText); | |
230 | var warn = document.getElementById("default_pass_warning"); | |
231 | if (warn) warn.style.display = "none"; | |
232 | } | |
233 | ||
234 | document.forms['change_pass_form'].reset(); | |
d95bd220 | 235 | |
42395d28 AD |
236 | } |
237 | } catch (e) { | |
238 | exception_error("changepass_callback", e); | |
239 | } | |
d95bd220 AD |
240 | } |
241 | ||
11f083e7 AD |
242 | function infobox_feed_cat_callback() { |
243 | if (xmlhttp.readyState == 4) { | |
244 | try { | |
245 | ||
246 | infobox_callback(); | |
247 | ||
248 | if (document.getElementById("prefFeedCatList")) { | |
249 | var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN"); | |
250 | ||
251 | for (var i = 0; i < elems.length; i++) { | |
252 | if (elems[i].id && elems[i].id.match("FCATT-")) { | |
253 | var cat_id = elems[i].id.replace("FCATT-", ""); | |
254 | ||
255 | new Ajax.InPlaceEditor(elems[i], | |
256 | 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id); | |
257 | } | |
258 | } | |
259 | } | |
260 | ||
261 | } catch (e) { | |
262 | exception_error("infobox_feed_cat_callback", e); | |
263 | } | |
264 | } | |
265 | } | |
266 | ||
b83c7545 | 267 | function updateFeedList(sort_key) { |
007bda35 | 268 | |
c0e5a40e | 269 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
270 | printLockingError(); |
271 | return | |
272 | } | |
273 | ||
f932bc9f AD |
274 | var feed_search = document.getElementById("feed_search"); |
275 | var search = ""; | |
276 | if (feed_search) { search = feed_search.value; } | |
277 | ||
400b60d8 AD |
278 | var slat = document.getElementById("show_last_article_times"); |
279 | ||
280 | var slat_checked = false; | |
281 | if (slat) { | |
282 | slat_checked = slat.checked; | |
283 | } | |
284 | ||
b83c7545 | 285 | xmlhttp.open("GET", "backend.php?op=pref-feeds" + |
f932bc9f | 286 | "&sort=" + param_escape(sort_key) + |
400b60d8 | 287 | "&slat=" + param_escape(slat_checked) + |
f932bc9f | 288 | "&search=" + param_escape(search), true); |
007bda35 AD |
289 | xmlhttp.onreadystatechange=feedlist_callback; |
290 | xmlhttp.send(null); | |
291 | ||
292 | } | |
293 | ||
79ec0f2f | 294 | function updateUsersList(sort_key) { |
e6cb77a0 AD |
295 | |
296 | if (!xmlhttp_ready(xmlhttp)) { | |
297 | printLockingError(); | |
298 | return | |
299 | } | |
300 | ||
a5bd7bf0 AD |
301 | var user_search = document.getElementById("user_search"); |
302 | var search = ""; | |
303 | if (user_search) { search = user_search.value; } | |
304 | ||
79ec0f2f | 305 | xmlhttp.open("GET", "backend.php?op=pref-users&sort=" |
a5bd7bf0 AD |
306 | + param_escape(sort_key) + |
307 | "&search=" + param_escape(search), true); | |
e6cb77a0 AD |
308 | xmlhttp.onreadystatechange=userlist_callback; |
309 | xmlhttp.send(null); | |
310 | ||
311 | } | |
312 | ||
48f0adb0 AD |
313 | function addLabel() { |
314 | ||
ceb30ba4 AD |
315 | try { |
316 | ||
48f0adb0 AD |
317 | if (!xmlhttp_ready(xmlhttp)) { |
318 | printLockingError(); | |
319 | return | |
320 | } | |
321 | ||
ceb30ba4 | 322 | var caption = prompt(__("Please enter label caption:"), ""); |
48f0adb0 | 323 | |
4264f0b5 AD |
324 | if (caption == null) { |
325 | return false; | |
326 | } | |
327 | ||
ceb30ba4 | 328 | if (caption == "") { |
89cb787e | 329 | alert(__("Can't create label: missing caption.")); |
f156fd00 | 330 | return false; |
de435974 AD |
331 | } |
332 | ||
6068d33b AD |
333 | // we can be called from some other tab |
334 | active_tab = "labelConfig"; | |
335 | ||
ceb30ba4 AD |
336 | var query = "caption=" + param_escape(caption); |
337 | ||
f156fd00 AD |
338 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true); |
339 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
340 | xmlhttp.send(null); | |
ceb30ba4 AD |
341 | |
342 | } catch (e) { | |
343 | exception_error("addLabel", e); | |
344 | } | |
de435974 | 345 | } |
48f0adb0 | 346 | |
71ad3959 AD |
347 | function addFeed() { |
348 | ||
c0e5a40e | 349 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
350 | printLockingError(); |
351 | return | |
352 | } | |
353 | ||
331900c6 AD |
354 | var link = document.getElementById("fadd_link"); |
355 | ||
83fe4d6d | 356 | if (link.value.length == 0) { |
f3977cf5 | 357 | alert(__("Error: No feed URL given.")); |
605f7d46 | 358 | } else if (!isValidURL(link.value)) { |
f3977cf5 | 359 | alert(__("Error: Invalid feed URL.")); |
331900c6 | 360 | } else { |
42c32916 | 361 | notify_progress("Adding feed..."); |
331900c6 | 362 | |
e513a74a | 363 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" + |
331900c6 AD |
364 | param_escape(link.value), true); |
365 | xmlhttp.onreadystatechange=feedlist_callback; | |
366 | xmlhttp.send(null); | |
367 | ||
368 | link.value = ""; | |
369 | ||
370 | } | |
371 | ||
372 | } | |
373 | ||
91ff844a AD |
374 | function addFeedCat() { |
375 | ||
376 | if (!xmlhttp_ready(xmlhttp)) { | |
377 | printLockingError(); | |
378 | return | |
379 | } | |
380 | ||
381 | var cat = document.getElementById("fadd_cat"); | |
382 | ||
383 | if (cat.value.length == 0) { | |
f3977cf5 | 384 | alert(__("Can't add category: no name specified.")); |
91ff844a | 385 | } else { |
42c32916 | 386 | notify_progress("Adding feed category..."); |
91ff844a | 387 | |
9c483746 | 388 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" + |
91ff844a | 389 | param_escape(cat.value), true); |
9c483746 | 390 | xmlhttp.onreadystatechange=infobox_callback; |
91ff844a AD |
391 | xmlhttp.send(null); |
392 | ||
393 | link.value = ""; | |
394 | ||
395 | } | |
396 | ||
397 | } | |
e6cb77a0 AD |
398 | function addUser() { |
399 | ||
400 | if (!xmlhttp_ready(xmlhttp)) { | |
401 | printLockingError(); | |
402 | return | |
403 | } | |
404 | ||
405 | var sqlexp = document.getElementById("uadd_box"); | |
406 | ||
407 | if (sqlexp.value.length == 0) { | |
89cb787e | 408 | alert(__("Can't add user: no login specified.")); |
e6cb77a0 | 409 | } else { |
42c32916 | 410 | notify_progress("Adding user..."); |
e6cb77a0 AD |
411 | |
412 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" + | |
413 | param_escape(sqlexp.value), true); | |
414 | ||
415 | xmlhttp.onreadystatechange=userlist_callback; | |
416 | xmlhttp.send(null); | |
417 | ||
418 | sqlexp.value = ""; | |
419 | } | |
420 | ||
421 | } | |
422 | ||
e6cb77a0 AD |
423 | function editUser(id) { |
424 | ||
425 | if (!xmlhttp_ready(xmlhttp)) { | |
426 | printLockingError(); | |
427 | return | |
428 | } | |
429 | ||
6068d33b AD |
430 | disableHotkeys(); |
431 | ||
9e31e1b9 AD |
432 | notify_progress("Loading, please wait..."); |
433 | ||
3c5783b7 AD |
434 | selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false); |
435 | selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true); | |
e6cb77a0 AD |
436 | |
437 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" + | |
438 | param_escape(id), true); | |
3c5783b7 | 439 | xmlhttp.onreadystatechange=infobox_callback; |
e6cb77a0 AD |
440 | xmlhttp.send(null); |
441 | ||
442 | } | |
443 | ||
a0d53889 AD |
444 | function editFilter(id) { |
445 | ||
446 | if (!xmlhttp_ready(xmlhttp)) { | |
447 | printLockingError(); | |
448 | return | |
449 | } | |
450 | ||
6068d33b AD |
451 | disableHotkeys(); |
452 | ||
9e31e1b9 AD |
453 | notify_progress("Loading, please wait..."); |
454 | ||
38bb1ceb | 455 | // document.getElementById("create_filter_btn").disabled = true; |
4220b0bd | 456 | |
07164479 AD |
457 | selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); |
458 | selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); | |
a0d53889 | 459 | |
07164479 AD |
460 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true); |
461 | xmlhttp.onreadystatechange=infobox_callback; | |
a0d53889 | 462 | xmlhttp.send(null); |
a0d53889 AD |
463 | } |
464 | ||
331900c6 AD |
465 | function editFeed(feed) { |
466 | ||
508a81e1 AD |
467 | // notify("Editing feed..."); |
468 | ||
c0e5a40e | 469 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
470 | printLockingError(); |
471 | return | |
472 | } | |
331900c6 | 473 | |
6068d33b AD |
474 | disableHotkeys(); |
475 | ||
9e31e1b9 AD |
476 | notify_progress("Loading, please wait..."); |
477 | ||
38bb1ceb | 478 | /* document.getElementById("subscribe_to_feed_btn").disabled = true; |
a349077c AD |
479 | |
480 | try { | |
481 | document.getElementById("top25_feeds_btn").disabled = true; | |
482 | } catch (e) { | |
483 | // this button is not always available, no-op if not found | |
38bb1ceb | 484 | } */ |
a349077c | 485 | |
673d54ca | 486 | // clean selection from all rows & select row being edited |
0ea4fb50 | 487 | selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); |
6c12c809 | 488 | selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); |
0ea4fb50 AD |
489 | |
490 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" + | |
3c5783b7 | 491 | param_escape(feed), true); |
0ea4fb50 AD |
492 | |
493 | xmlhttp.onreadystatechange=infobox_callback; | |
331900c6 AD |
494 | xmlhttp.send(null); |
495 | ||
496 | } | |
497 | ||
91ff844a | 498 | function editFeedCat(cat) { |
48f0adb0 | 499 | |
91ff844a AD |
500 | if (!xmlhttp_ready(xmlhttp)) { |
501 | printLockingError(); | |
502 | return | |
48f0adb0 AD |
503 | } |
504 | ||
6068d33b AD |
505 | disableHotkeys(); |
506 | ||
9e31e1b9 AD |
507 | notify_progress("Loading, please wait..."); |
508 | ||
91ff844a | 509 | active_feed_cat = cat; |
e6cb77a0 | 510 | |
9c483746 | 511 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" + |
91ff844a | 512 | param_escape(cat), true); |
9c483746 | 513 | xmlhttp.onreadystatechange=infobox_callback; |
91ff844a | 514 | xmlhttp.send(null); |
e6cb77a0 | 515 | |
e6cb77a0 AD |
516 | } |
517 | ||
91ff844a AD |
518 | function getSelectedLabels() { |
519 | return getSelectedTableRowIds("prefLabelList", "LILRR"); | |
520 | } | |
48f0adb0 | 521 | |
91ff844a AD |
522 | function getSelectedUsers() { |
523 | return getSelectedTableRowIds("prefUserList", "UMRR"); | |
a0d53889 AD |
524 | } |
525 | ||
83fe4d6d | 526 | function getSelectedFeeds() { |
91ff844a AD |
527 | return getSelectedTableRowIds("prefFeedList", "FEEDR"); |
528 | } | |
331900c6 | 529 | |
91ff844a AD |
530 | function getSelectedFilters() { |
531 | return getSelectedTableRowIds("prefFilterList", "FILRR"); | |
532 | } | |
331900c6 | 533 | |
91ff844a AD |
534 | function getSelectedFeedCats() { |
535 | return getSelectedTableRowIds("prefFeedCatList", "FCATR"); | |
83fe4d6d AD |
536 | } |
537 | ||
c0ae0fdb AD |
538 | function getSelectedFeedsFromBrowser() { |
539 | ||
540 | var list = document.getElementById("browseFeedList"); | |
541 | if (!list) list = document.getElementById("browseBigFeedList"); | |
542 | ||
543 | var selected = new Array(); | |
544 | ||
545 | for (i = 0; i < list.childNodes.length; i++) { | |
546 | var child = list.childNodes[i]; | |
547 | if (child.id && child.id.match("FBROW-")) { | |
548 | var id = child.id.replace("FBROW-", ""); | |
549 | ||
550 | var cb = document.getElementById("FBCHK-" + id); | |
551 | ||
552 | if (cb.checked) { | |
553 | selected.push(id); | |
554 | } | |
555 | } | |
556 | } | |
557 | ||
558 | return selected; | |
559 | } | |
560 | ||
48f0adb0 AD |
561 | function removeSelectedLabels() { |
562 | ||
563 | if (!xmlhttp_ready(xmlhttp)) { | |
564 | printLockingError(); | |
565 | return | |
566 | } | |
567 | ||
568 | var sel_rows = getSelectedLabels(); | |
569 | ||
570 | if (sel_rows.length > 0) { | |
571 | ||
f56e3080 | 572 | var ok = confirm(__("Remove selected labels?")); |
48f0adb0 | 573 | |
69668465 | 574 | if (ok) { |
42c32916 | 575 | notify_progress("Removing selected labels..."); |
69668465 AD |
576 | |
577 | xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+ | |
578 | param_escape(sel_rows.toString()), true); | |
579 | xmlhttp.onreadystatechange=labellist_callback; | |
580 | xmlhttp.send(null); | |
581 | } | |
48f0adb0 | 582 | } else { |
89cb787e | 583 | alert(__("No labels are selected.")); |
48f0adb0 | 584 | } |
90ac84df AD |
585 | |
586 | return false; | |
48f0adb0 AD |
587 | } |
588 | ||
e6cb77a0 AD |
589 | function removeSelectedUsers() { |
590 | ||
591 | if (!xmlhttp_ready(xmlhttp)) { | |
592 | printLockingError(); | |
593 | return | |
594 | } | |
595 | ||
596 | var sel_rows = getSelectedUsers(); | |
597 | ||
598 | if (sel_rows.length > 0) { | |
599 | ||
f56e3080 | 600 | var ok = confirm(__("Remove selected users?")); |
e6cb77a0 | 601 | |
69668465 | 602 | if (ok) { |
42c32916 | 603 | notify_progress("Removing selected users..."); |
69668465 AD |
604 | |
605 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+ | |
606 | param_escape(sel_rows.toString()), true); | |
607 | xmlhttp.onreadystatechange=userlist_callback; | |
608 | xmlhttp.send(null); | |
609 | } | |
e6cb77a0 AD |
610 | |
611 | } else { | |
89cb787e | 612 | alert(__("No users are selected.")); |
e6cb77a0 | 613 | } |
90ac84df AD |
614 | |
615 | return false; | |
e6cb77a0 AD |
616 | } |
617 | ||
48f0adb0 AD |
618 | function removeSelectedFilters() { |
619 | ||
620 | if (!xmlhttp_ready(xmlhttp)) { | |
621 | printLockingError(); | |
622 | return | |
623 | } | |
624 | ||
625 | var sel_rows = getSelectedFilters(); | |
626 | ||
627 | if (sel_rows.length > 0) { | |
628 | ||
f56e3080 | 629 | var ok = confirm(__("Remove selected filters?")); |
48f0adb0 | 630 | |
69668465 | 631 | if (ok) { |
42c32916 | 632 | notify_progress("Removing selected filters..."); |
69668465 AD |
633 | |
634 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
635 | param_escape(sel_rows.toString()), true); | |
636 | xmlhttp.onreadystatechange=filterlist_callback; | |
637 | xmlhttp.send(null); | |
638 | } | |
48f0adb0 | 639 | } else { |
89cb787e | 640 | alert(__("No filters are selected.")); |
48f0adb0 | 641 | } |
90ac84df AD |
642 | |
643 | return false; | |
48f0adb0 AD |
644 | } |
645 | ||
646 | ||
83fe4d6d AD |
647 | function removeSelectedFeeds() { |
648 | ||
c0e5a40e | 649 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
650 | printLockingError(); |
651 | return | |
652 | } | |
653 | ||
83fe4d6d AD |
654 | var sel_rows = getSelectedFeeds(); |
655 | ||
331900c6 AD |
656 | if (sel_rows.length > 0) { |
657 | ||
f56e3080 | 658 | var ok = confirm(__("Unsubscribe from selected feeds?")); |
331900c6 | 659 | |
69668465 AD |
660 | if (ok) { |
661 | ||
42c32916 | 662 | notify_progress("Unsubscribing from selected feeds..."); |
69668465 AD |
663 | |
664 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
665 | param_escape(sel_rows.toString()), true); | |
666 | xmlhttp.onreadystatechange=feedlist_callback; | |
667 | xmlhttp.send(null); | |
668 | } | |
71ad3959 | 669 | |
71ad3959 | 670 | } else { |
331900c6 | 671 | |
89cb787e | 672 | alert(__("No feeds are selected.")); |
331900c6 | 673 | |
71ad3959 | 674 | } |
90ac84df AD |
675 | |
676 | return false; | |
71ad3959 | 677 | } |
007bda35 | 678 | |
c4a36709 AD |
679 | function clearSelectedFeeds() { |
680 | ||
681 | if (!xmlhttp_ready(xmlhttp)) { | |
682 | printLockingError(); | |
683 | return | |
684 | } | |
685 | ||
686 | var sel_rows = getSelectedFeeds(); | |
687 | ||
688 | if (sel_rows.length > 1) { | |
689 | alert(__("Please select only one feed.")); | |
690 | return; | |
691 | } | |
692 | ||
693 | if (sel_rows.length > 0) { | |
694 | ||
695 | var ok = confirm(__("Erase all non-starred articles in selected feed?")); | |
696 | ||
697 | if (ok) { | |
698 | notify_progress("Clearing selected feed..."); | |
699 | clearFeedArticles(sel_rows[0]); | |
700 | } | |
701 | ||
702 | } else { | |
703 | ||
704 | alert(__("No feeds are selected.")); | |
705 | ||
706 | } | |
707 | ||
708 | return false; | |
709 | } | |
710 | ||
e88a65f4 AD |
711 | function purgeSelectedFeeds() { |
712 | ||
713 | if (!xmlhttp_ready(xmlhttp)) { | |
714 | printLockingError(); | |
715 | return | |
716 | } | |
717 | ||
718 | var sel_rows = getSelectedFeeds(); | |
719 | ||
720 | if (sel_rows.length > 0) { | |
721 | ||
722 | var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0"); | |
723 | ||
724 | if (pr != undefined) { | |
725 | notify_progress("Purging selected feed..."); | |
726 | ||
727 | var query = "backend.php?op=rpc&subop=purge&ids="+ | |
728 | param_escape(sel_rows.toString()) + "&days=" + pr; | |
729 | ||
730 | debug(query); | |
731 | ||
732 | new Ajax.Request(query, { | |
733 | onComplete: function(transport) { | |
734 | notify(''); | |
735 | } }); | |
736 | } | |
737 | ||
738 | } else { | |
739 | ||
740 | alert(__("No feeds are selected.")); | |
741 | ||
742 | } | |
743 | ||
744 | return false; | |
745 | } | |
746 | ||
91ff844a AD |
747 | function removeSelectedFeedCats() { |
748 | ||
749 | if (!xmlhttp_ready(xmlhttp)) { | |
750 | printLockingError(); | |
751 | return | |
752 | } | |
753 | ||
754 | var sel_rows = getSelectedFeedCats(); | |
755 | ||
756 | if (sel_rows.length > 0) { | |
757 | ||
f56e3080 | 758 | var ok = confirm(__("Remove selected categories?")); |
91ff844a | 759 | |
69668465 | 760 | if (ok) { |
42c32916 | 761 | notify_progress("Removing selected categories..."); |
69668465 | 762 | |
9c483746 | 763 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+ |
69668465 | 764 | param_escape(sel_rows.toString()), true); |
9c483746 | 765 | xmlhttp.onreadystatechange=infobox_callback; |
69668465 AD |
766 | xmlhttp.send(null); |
767 | } | |
91ff844a AD |
768 | |
769 | } else { | |
770 | ||
89cb787e | 771 | alert(__("No categories are selected.")); |
91ff844a AD |
772 | |
773 | } | |
774 | ||
90ac84df | 775 | return false; |
91ff844a AD |
776 | } |
777 | ||
508a81e1 AD |
778 | function feedEditCancel() { |
779 | ||
c0e5a40e | 780 | if (!xmlhttp_ready(xmlhttp)) { |
508a81e1 AD |
781 | printLockingError(); |
782 | return | |
783 | } | |
784 | ||
a349077c | 785 | try { |
57f734c8 | 786 | document.getElementById("subscribe_to_feed_btn").disabled = false; |
a349077c AD |
787 | document.getElementById("top25_feeds_btn").disabled = false; |
788 | } catch (e) { | |
789 | // this button is not always available, no-op if not found | |
790 | } | |
791 | ||
327a3bbe AD |
792 | closeInfoBox(); |
793 | ||
673d54ca | 794 | selectPrefRows('feed', false); // cleanup feed selection |
508a81e1 | 795 | |
90ac84df | 796 | return false; |
508a81e1 AD |
797 | } |
798 | ||
91ff844a AD |
799 | function feedCatEditCancel() { |
800 | ||
801 | if (!xmlhttp_ready(xmlhttp)) { | |
802 | printLockingError(); | |
803 | return | |
804 | } | |
805 | ||
806 | active_feed_cat = false; | |
807 | ||
0ceded7a | 808 | // notify("Operation cancelled."); |
91ff844a | 809 | |
9c483746 AD |
810 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); |
811 | xmlhttp.onreadystatechange=infobox_callback; | |
91ff844a AD |
812 | xmlhttp.send(null); |
813 | ||
90ac84df | 814 | return false; |
91ff844a AD |
815 | } |
816 | ||
603c27f8 AD |
817 | function feedEditSave() { |
818 | ||
47c6c988 | 819 | try { |
47c6c988 AD |
820 | |
821 | if (!xmlhttp_ready(xmlhttp)) { | |
822 | printLockingError(); | |
823 | return | |
824 | } | |
ad815c71 | 825 | |
14f69488 | 826 | // FIXME: add parameter validation |
e3c99f3b | 827 | |
14f69488 | 828 | var query = Form.serialize("edit_feed_form"); |
b0da3a7b | 829 | |
42c32916 | 830 | notify_progress("Saving feed..."); |
673d54ca | 831 | |
47c6c988 AD |
832 | xmlhttp.open("POST", "backend.php", true); |
833 | xmlhttp.onreadystatechange=feedlist_callback; | |
834 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
14f69488 AD |
835 | xmlhttp.send(query); |
836 | ||
59a543f0 AD |
837 | closeInfoBox(); |
838 | ||
c14b5566 AD |
839 | return false; |
840 | ||
47c6c988 AD |
841 | } catch (e) { |
842 | exception_error("feedEditSave", e); | |
b0da3a7b | 843 | } |
508a81e1 AD |
844 | } |
845 | ||
5ddadb4c AD |
846 | function feedCatEditSave() { |
847 | ||
848 | if (!xmlhttp_ready(xmlhttp)) { | |
849 | printLockingError(); | |
850 | return | |
851 | } | |
852 | ||
42c32916 | 853 | notify_progress("Saving category..."); |
5ddadb4c | 854 | |
0666e120 AD |
855 | var query = Form.serialize("feed_cat_edit_form"); |
856 | ||
857 | xmlhttp.open("GET", "backend.php?" + query, true); | |
9c483746 | 858 | xmlhttp.onreadystatechange=infobox_callback; |
5ddadb4c AD |
859 | xmlhttp.send(null); |
860 | ||
861 | active_feed_cat = false; | |
862 | ||
90ac84df | 863 | return false; |
5ddadb4c AD |
864 | } |
865 | ||
e6cb77a0 AD |
866 | function userEditCancel() { |
867 | ||
868 | if (!xmlhttp_ready(xmlhttp)) { | |
869 | printLockingError(); | |
870 | return | |
871 | } | |
872 | ||
3c5783b7 | 873 | selectPrefRows('user', false); // cleanup feed selection |
3c5783b7 | 874 | closeInfoBox(); |
90ac84df AD |
875 | |
876 | return false; | |
e6cb77a0 | 877 | } |
48f0adb0 | 878 | |
a0d53889 AD |
879 | function filterEditCancel() { |
880 | ||
881 | if (!xmlhttp_ready(xmlhttp)) { | |
882 | printLockingError(); | |
883 | return | |
884 | } | |
4220b0bd | 885 | |
57f734c8 AD |
886 | try { |
887 | document.getElementById("create_filter_btn").disabled = false; | |
888 | selectPrefRows('filter', false); // cleanup feed selection | |
889 | } catch (e) { } | |
890 | ||
07164479 | 891 | closeInfoBox(); |
90ac84df AD |
892 | |
893 | return false; | |
a0d53889 AD |
894 | } |
895 | ||
e6cb77a0 AD |
896 | function userEditSave() { |
897 | ||
e6cb77a0 AD |
898 | if (!xmlhttp_ready(xmlhttp)) { |
899 | printLockingError(); | |
900 | return | |
901 | } | |
902 | ||
3c5783b7 | 903 | var login = document.forms["user_edit_form"].login.value; |
e6cb77a0 AD |
904 | |
905 | if (login.length == 0) { | |
89cb787e | 906 | alert(__("Login field cannot be blank.")); |
e6cb77a0 AD |
907 | return; |
908 | } | |
3c5783b7 | 909 | |
42c32916 | 910 | notify_progress("Saving user..."); |
4220b0bd AD |
911 | |
912 | closeInfoBox(); | |
913 | ||
3c5783b7 AD |
914 | var query = Form.serialize("user_edit_form"); |
915 | ||
916 | xmlhttp.open("GET", "backend.php?" + query, true); | |
dbd9e2f1 | 917 | xmlhttp.onreadystatechange=userlist_callback; |
e6cb77a0 | 918 | xmlhttp.send(null); |
90ac84df AD |
919 | |
920 | return false; | |
e6cb77a0 AD |
921 | } |
922 | ||
923 | ||
a0d53889 AD |
924 | function filterEditSave() { |
925 | ||
a0d53889 AD |
926 | if (!xmlhttp_ready(xmlhttp)) { |
927 | printLockingError(); | |
928 | return | |
929 | } | |
930 | ||
9ee3ac59 | 931 | /* if (!is_opera()) { |
7c620da8 AD |
932 | var reg_exp = document.forms["filter_edit_form"].reg_exp.value; |
933 | ||
934 | if (reg_exp.length == 0) { | |
935 | alert("Filter expression field cannot be blank."); | |
936 | return; | |
937 | } | |
9ee3ac59 | 938 | } */ |
a0d53889 | 939 | |
42c32916 | 940 | notify_progress("Saving filter..."); |
a0d53889 | 941 | |
7e939457 | 942 | var query = Form.serialize("filter_edit_form"); |
dbd9e2f1 | 943 | |
07164479 AD |
944 | closeInfoBox(); |
945 | ||
4220b0bd AD |
946 | document.getElementById("create_filter_btn").disabled = false; |
947 | ||
7e939457 | 948 | xmlhttp.open("GET", "backend.php?" + query, true); |
a0d53889 | 949 | xmlhttp.onreadystatechange=filterlist_callback; |
7e939457 | 950 | xmlhttp.send(null); |
a0d53889 | 951 | |
90ac84df | 952 | return false; |
a0d53889 AD |
953 | } |
954 | ||
a0d53889 | 955 | |
e6cb77a0 AD |
956 | function editSelectedUser() { |
957 | var rows = getSelectedUsers(); | |
958 | ||
959 | if (rows.length == 0) { | |
f3977cf5 | 960 | alert(__("No users are selected.")); |
e6cb77a0 AD |
961 | return; |
962 | } | |
963 | ||
964 | if (rows.length > 1) { | |
f3977cf5 | 965 | alert(__("Please select only one user.")); |
e6cb77a0 AD |
966 | return; |
967 | } | |
968 | ||
dbd9e2f1 AD |
969 | notify(""); |
970 | ||
e6cb77a0 AD |
971 | editUser(rows[0]); |
972 | } | |
973 | ||
974 | function resetSelectedUserPass() { | |
975 | var rows = getSelectedUsers(); | |
976 | ||
977 | if (rows.length == 0) { | |
f3977cf5 | 978 | alert(__("No users are selected.")); |
e6cb77a0 AD |
979 | return; |
980 | } | |
981 | ||
982 | if (rows.length > 1) { | |
f3977cf5 | 983 | alert(__("Please select only one user.")); |
e6cb77a0 AD |
984 | return; |
985 | } | |
986 | ||
f3977cf5 | 987 | var ok = confirm(__("Reset password of selected user?")); |
e6cb77a0 | 988 | |
69668465 | 989 | if (ok) { |
42c32916 | 990 | notify_progress("Resetting password for selected user..."); |
69668465 AD |
991 | |
992 | var id = rows[0]; | |
993 | ||
994 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" + | |
995 | param_escape(id), true); | |
996 | xmlhttp.onreadystatechange=userlist_callback; | |
997 | xmlhttp.send(null); | |
998 | } | |
e6cb77a0 AD |
999 | } |
1000 | ||
717f5e64 | 1001 | function selectedUserDetails() { |
e6cb77a0 | 1002 | |
1a7572cb AD |
1003 | if (!xmlhttp_ready(xmlhttp)) { |
1004 | printLockingError(); | |
1005 | return | |
1006 | } | |
1007 | ||
717f5e64 AD |
1008 | var rows = getSelectedUsers(); |
1009 | ||
1010 | if (rows.length == 0) { | |
f3977cf5 | 1011 | alert(__("No users are selected.")); |
717f5e64 AD |
1012 | return; |
1013 | } | |
1014 | ||
1015 | if (rows.length > 1) { | |
f3977cf5 | 1016 | alert(__("Please select only one user.")); |
717f5e64 AD |
1017 | return; |
1018 | } | |
1019 | ||
0077a65c | 1020 | notify_progress("Loading, please wait..."); |
717f5e64 | 1021 | |
0077a65c | 1022 | var id = rows[0]; |
dbd9e2f1 | 1023 | |
5a437c88 | 1024 | xmlhttp.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id, true); |
c6c3a07f AD |
1025 | xmlhttp.onreadystatechange=infobox_callback; |
1026 | xmlhttp.send(null); | |
1027 | ||
1028 | } | |
1029 | ||
1030 | function selectedFeedDetails() { | |
1031 | ||
1032 | if (!xmlhttp_ready(xmlhttp)) { | |
1033 | printLockingError(); | |
1034 | return | |
1035 | } | |
1036 | ||
1037 | var rows = getSelectedFeeds(); | |
1038 | ||
1039 | if (rows.length == 0) { | |
f3977cf5 | 1040 | alert(__("No feeds are selected.")); |
c6c3a07f AD |
1041 | return; |
1042 | } | |
1043 | ||
01b3e191 | 1044 | if (rows.length > 1) { |
f3977cf5 | 1045 | alert(__("Please select only one feed.")); |
01b3e191 AD |
1046 | return; |
1047 | } | |
c6c3a07f | 1048 | |
df268d47 | 1049 | // var id = rows[0]; |
c6c3a07f | 1050 | |
dbd9e2f1 AD |
1051 | notify(""); |
1052 | ||
df268d47 AD |
1053 | xmlhttp.open("GET", "backend.php?op=feed-details&id=" + |
1054 | param_escape(rows.toString()), true); | |
c6c3a07f | 1055 | xmlhttp.onreadystatechange=infobox_callback; |
1a7572cb | 1056 | xmlhttp.send(null); |
717f5e64 AD |
1057 | |
1058 | } | |
a0d53889 AD |
1059 | |
1060 | function editSelectedFilter() { | |
1061 | var rows = getSelectedFilters(); | |
1062 | ||
1063 | if (rows.length == 0) { | |
f3977cf5 | 1064 | alert(__("No filters are selected.")); |
a0d53889 AD |
1065 | return; |
1066 | } | |
1067 | ||
1068 | if (rows.length > 1) { | |
f3977cf5 | 1069 | alert(__("Please select only one filter.")); |
a0d53889 AD |
1070 | return; |
1071 | } | |
1072 | ||
dbd9e2f1 AD |
1073 | notify(""); |
1074 | ||
a0d53889 AD |
1075 | editFilter(rows[0]); |
1076 | ||
1077 | } | |
1078 | ||
1079 | ||
508a81e1 AD |
1080 | function editSelectedFeed() { |
1081 | var rows = getSelectedFeeds(); | |
1082 | ||
1083 | if (rows.length == 0) { | |
f3977cf5 | 1084 | alert(__("No feeds are selected.")); |
508a81e1 AD |
1085 | return; |
1086 | } | |
1087 | ||
1088 | if (rows.length > 1) { | |
f3977cf5 | 1089 | alert(__("Please select one feed.")); |
508a81e1 AD |
1090 | return; |
1091 | } | |
1092 | ||
dbd9e2f1 AD |
1093 | notify(""); |
1094 | ||
508a81e1 | 1095 | editFeed(rows[0]); |
91ff844a AD |
1096 | |
1097 | } | |
1098 | ||
758e1c4a AD |
1099 | function editSelectedFeeds() { |
1100 | ||
1101 | if (!xmlhttp_ready(xmlhttp)) { | |
1102 | printLockingError(); | |
1103 | return | |
1104 | } | |
1105 | ||
1106 | var rows = getSelectedFeeds(); | |
1107 | ||
1108 | if (rows.length == 0) { | |
1109 | alert(__("No feeds are selected.")); | |
1110 | return; | |
1111 | } | |
1112 | ||
1113 | notify(""); | |
1114 | ||
1115 | disableHotkeys(); | |
1116 | ||
1117 | notify_progress("Loading, please wait..."); | |
1118 | ||
1119 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" + | |
1120 | param_escape(rows.toString()), true); | |
1121 | ||
1122 | xmlhttp.onreadystatechange=infobox_callback; | |
1123 | xmlhttp.send(null); | |
1124 | ||
1125 | } | |
1126 | ||
91ff844a AD |
1127 | function editSelectedFeedCat() { |
1128 | var rows = getSelectedFeedCats(); | |
1129 | ||
1130 | if (rows.length == 0) { | |
f3977cf5 | 1131 | alert(__("No categories are selected.")); |
91ff844a AD |
1132 | return; |
1133 | } | |
1134 | ||
1135 | if (rows.length > 1) { | |
f3977cf5 | 1136 | alert(__("Please select only one category.")); |
91ff844a AD |
1137 | return; |
1138 | } | |
1139 | ||
1140 | notify(""); | |
1141 | ||
1142 | editFeedCat(rows[0]); | |
508a81e1 AD |
1143 | |
1144 | } | |
1145 | ||
eec498c3 | 1146 | function piggie(enable) { |
13ad9102 | 1147 | if (enable) { |
d437c8cf | 1148 | debug("I LOVEDED IT!"); |
1cac3c31 | 1149 | var piggie = document.getElementById("piggie"); |
33377ef3 | 1150 | |
537625c6 AD |
1151 | Element.show(piggie); |
1152 | Position.Center(piggie); | |
1153 | Effect.Puff(piggie); | |
1154 | ||
508a81e1 | 1155 | } |
508a81e1 AD |
1156 | } |
1157 | ||
9f311df6 AD |
1158 | function validateOpmlImport() { |
1159 | ||
1160 | var opml_file = document.getElementById("opml_file"); | |
1161 | ||
1162 | if (opml_file.value.length == 0) { | |
f3977cf5 | 1163 | alert(__("No OPML file to upload.")); |
9f311df6 AD |
1164 | return false; |
1165 | } else { | |
1166 | return true; | |
1167 | } | |
1168 | } | |
1169 | ||
0e317f9d | 1170 | function updateFilterList(sort_key) { |
a0d53889 AD |
1171 | |
1172 | if (!xmlhttp_ready(xmlhttp)) { | |
1173 | printLockingError(); | |
1174 | return | |
1175 | } | |
1176 | ||
9c87d75c AD |
1177 | var filter_search = document.getElementById("filter_search"); |
1178 | var search = ""; | |
1179 | if (filter_search) { search = filter_search.value; } | |
1180 | ||
e161a2cc | 1181 | xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + |
9c87d75c AD |
1182 | param_escape(sort_key) + |
1183 | "&search=" + param_escape(search), true); | |
a0d53889 AD |
1184 | xmlhttp.onreadystatechange=filterlist_callback; |
1185 | xmlhttp.send(null); | |
1186 | ||
1187 | } | |
1188 | ||
e161a2cc | 1189 | function updateLabelList(sort_key) { |
48f0adb0 AD |
1190 | |
1191 | if (!xmlhttp_ready(xmlhttp)) { | |
1192 | printLockingError(); | |
1193 | return | |
1194 | } | |
1195 | ||
112d2aec AD |
1196 | var label_search = document.getElementById("label_search"); |
1197 | var search = ""; | |
1198 | if (label_search) { search = label_search.value; } | |
1199 | ||
e161a2cc | 1200 | xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + |
112d2aec AD |
1201 | param_escape(sort_key) + |
1202 | "&search=" + param_escape(search), true); | |
48f0adb0 AD |
1203 | xmlhttp.onreadystatechange=labellist_callback; |
1204 | xmlhttp.send(null); | |
48f0adb0 AD |
1205 | } |
1206 | ||
4255b24c AD |
1207 | function updatePrefsList() { |
1208 | ||
1209 | if (!xmlhttp_ready(xmlhttp)) { | |
1210 | printLockingError(); | |
1211 | return | |
1212 | } | |
1213 | ||
4255b24c AD |
1214 | xmlhttp.open("GET", "backend.php?op=pref-prefs", true); |
1215 | xmlhttp.onreadystatechange=prefslist_callback; | |
1216 | xmlhttp.send(null); | |
1217 | ||
1218 | } | |
1219 | ||
e513a74a | 1220 | function selectTab(id, noupdate, subop) { |
a7f22b70 AD |
1221 | |
1222 | // alert(id); | |
48f0adb0 | 1223 | |
b2caf812 | 1224 | if (!id) id = active_tab; |
7f74a9da | 1225 | |
b2caf812 | 1226 | try { |
59a543f0 | 1227 | |
b2caf812 AD |
1228 | if (!xmlhttp_ready(xmlhttp)) { |
1229 | printLockingError(); | |
1230 | return | |
a7f22b70 | 1231 | } |
f5a50b25 | 1232 | |
a422968f AD |
1233 | try { |
1234 | var c = document.getElementById('prefContent'); | |
1235 | c.scrollTop = 0; | |
1236 | } catch (e) { }; | |
1237 | ||
b2caf812 | 1238 | if (!noupdate) { |
f5a50b25 | 1239 | |
b2caf812 AD |
1240 | debug("selectTab: " + id + "(NU: " + noupdate + ")"); |
1241 | ||
9e31e1b9 | 1242 | notify_progress("Loading, please wait..."); |
b2caf812 AD |
1243 | |
1244 | // close active infobox if needed | |
1245 | closeInfoBox(); | |
1246 | ||
1247 | // clean up all current selections, just in case | |
1248 | active_feed_cat = false; | |
d15f8675 AD |
1249 | |
1250 | // Effect.Fade("prefContent", {duration: 1, to: 0.01, | |
1251 | // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } ); | |
1252 | ||
b2caf812 AD |
1253 | if (id == "feedConfig") { |
1254 | updateFeedList(); | |
1255 | } else if (id == "filterConfig") { | |
1256 | updateFilterList(); | |
1257 | } else if (id == "labelConfig") { | |
1258 | updateLabelList(); | |
1259 | } else if (id == "genConfig") { | |
1260 | updatePrefsList(); | |
1261 | } else if (id == "userConfig") { | |
1262 | updateUsersList(); | |
1263 | } else if (id == "feedBrowser") { | |
1264 | updateBigFeedBrowser(); | |
1265 | } | |
f5a50b25 | 1266 | } |
6068d33b AD |
1267 | |
1268 | /* clean selection from all tabs */ | |
b2caf812 | 1269 | |
6068d33b AD |
1270 | var tabs_holder = document.getElementById("prefTabs"); |
1271 | var tab = tabs_holder.firstChild; | |
1272 | ||
1273 | while (tab) { | |
1274 | if (tab.className && tab.className.match("prefsTabSelected")) { | |
b2caf812 AD |
1275 | tab.className = "prefsTab"; |
1276 | } | |
6068d33b | 1277 | tab = tab.nextSibling; |
f5a50b25 | 1278 | } |
6068d33b AD |
1279 | |
1280 | /* mark new tab as selected */ | |
1281 | ||
b2caf812 AD |
1282 | tab = document.getElementById(id + "Tab"); |
1283 | ||
1284 | if (tab) { | |
1285 | if (!tab.className.match("Selected")) { | |
1286 | tab.className = tab.className + "Selected"; | |
1287 | } | |
1288 | } | |
1289 | ||
b2caf812 | 1290 | active_tab = id; |
f5a50b25 | 1291 | |
b2caf812 AD |
1292 | } catch (e) { |
1293 | exception_error("selectTab", e); | |
a7565293 | 1294 | } |
a7565293 AD |
1295 | } |
1296 | ||
1297 | function backend_sanity_check_callback() { | |
f5a50b25 | 1298 | |
a7565293 AD |
1299 | if (xmlhttp.readyState == 4) { |
1300 | ||
1301 | try { | |
7a09510c AD |
1302 | |
1303 | if (sanity_check_done) { | |
81352b54 AD |
1304 | fatalError(11, "Sanity check request received twice. This can indicate "+ |
1305 | "presence of Firebug or some other disrupting extension. "+ | |
1306 | "Please disable it and try again."); | |
7a09510c AD |
1307 | return; |
1308 | } | |
1309 | ||
a7565293 AD |
1310 | if (!xmlhttp.responseXML) { |
1311 | fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText); | |
1312 | return; | |
1313 | } | |
1314 | ||
1315 | var reply = xmlhttp.responseXML.firstChild.firstChild; | |
1316 | ||
1317 | if (!reply) { | |
1318 | fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText); | |
1319 | return; | |
1320 | } | |
1321 | ||
1322 | var error_code = reply.getAttribute("error-code"); | |
1323 | ||
1324 | if (error_code && error_code != 0) { | |
1325 | return fatalError(error_code, reply.getAttribute("error-msg")); | |
1326 | } | |
1327 | ||
1328 | debug("sanity check ok"); | |
1329 | ||
1330 | var params = reply.nextSibling; | |
1331 | ||
1332 | if (params) { | |
1333 | debug('reading init-params...'); | |
1334 | var param = params.firstChild; | |
1335 | ||
1336 | while (param) { | |
1337 | var k = param.getAttribute("key"); | |
1338 | var v = param.getAttribute("value"); | |
1339 | debug(k + " => " + v); | |
1340 | init_params[k] = v; | |
1341 | param = param.nextSibling; | |
1342 | } | |
1343 | } | |
1344 | ||
7a09510c AD |
1345 | sanity_check_done = true; |
1346 | ||
a7565293 AD |
1347 | init_second_stage(); |
1348 | ||
1349 | } catch (e) { | |
1350 | exception_error("backend_sanity_check_callback", e); | |
1351 | } | |
1352 | } | |
1353 | } | |
1354 | ||
1355 | function init_second_stage() { | |
1356 | ||
b2caf812 AD |
1357 | try { |
1358 | active_tab = getInitParam("prefs_active_tab"); | |
fe8d2059 | 1359 | if (!active_tab || active_tab == '0') active_tab = "genConfig"; |
4da47970 | 1360 | |
d437c8cf AD |
1361 | document.onkeydown = pref_hotkey_handler; |
1362 | ||
e513a74a AD |
1363 | var tab = getURLParam('tab'); |
1364 | ||
1365 | caller_subop = getURLParam('subop'); | |
1366 | ||
1367 | if (tab) { | |
1368 | active_tab = tab; | |
1369 | } | |
1370 | ||
b2caf812 AD |
1371 | if (navigator.userAgent.match("Opera")) { |
1372 | setTimeout("selectTab()", 500); | |
1373 | } else { | |
1374 | selectTab(active_tab); | |
1375 | } | |
1376 | notify(""); | |
08827aaf AD |
1377 | |
1378 | loading_set_progress(60); | |
1379 | ||
b2caf812 AD |
1380 | } catch (e) { |
1381 | exception_error("init_second_stage", e); | |
1382 | } | |
a0d53889 AD |
1383 | } |
1384 | ||
007bda35 | 1385 | function init() { |
e2ec66a8 | 1386 | |
7719618b AD |
1387 | try { |
1388 | ||
97dcd654 AD |
1389 | if (arguments.callee.done) return; |
1390 | arguments.callee.done = true; | |
1391 | ||
a7565293 | 1392 | if (getURLParam('debug')) { |
8836613c | 1393 | Element.show("debug_output"); |
a7565293 AD |
1394 | debug('debug mode activated'); |
1395 | } | |
1396 | ||
7719618b AD |
1397 | // IE kludge |
1398 | if (!xmlhttp) { | |
1399 | document.getElementById("prefContent").innerHTML = | |
1400 | "<b>Fatal error:</b> This program needs XmlHttpRequest " + | |
1401 | "to function properly. Your browser doesn't seem to support it."; | |
1402 | return; | |
1403 | } | |
4da47970 | 1404 | |
08827aaf AD |
1405 | loading_set_progress(30); |
1406 | ||
a7565293 AD |
1407 | xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true); |
1408 | xmlhttp.onreadystatechange=backend_sanity_check_callback; | |
1409 | xmlhttp.send(null); | |
1410 | ||
7719618b AD |
1411 | } catch (e) { |
1412 | exception_error("init", e); | |
e2ec66a8 | 1413 | } |
007bda35 | 1414 | } |
b1895692 | 1415 | |
f932bc9f AD |
1416 | function categorizeSelectedFeeds() { |
1417 | ||
1418 | if (!xmlhttp_ready(xmlhttp)) { | |
1419 | printLockingError(); | |
1420 | return | |
1421 | } | |
1422 | ||
1423 | var sel_rows = getSelectedFeeds(); | |
1424 | ||
1425 | var cat_sel = document.getElementById("sfeed_set_fcat"); | |
79f3553b | 1426 | var cat_id = cat_sel[cat_sel.selectedIndex].value; |
f932bc9f AD |
1427 | |
1428 | if (sel_rows.length > 0) { | |
1429 | ||
42c32916 | 1430 | notify_progress("Changing category of selected feeds..."); |
f932bc9f AD |
1431 | |
1432 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+ | |
1433 | param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true); | |
1434 | xmlhttp.onreadystatechange=feedlist_callback; | |
1435 | xmlhttp.send(null); | |
1436 | ||
1437 | } else { | |
1438 | ||
f3977cf5 | 1439 | alert(__("No feeds are selected.")); |
f932bc9f AD |
1440 | |
1441 | } | |
1442 | ||
1443 | } | |
69668465 AD |
1444 | |
1445 | function validatePrefsReset() { | |
b652c1b7 AD |
1446 | try { |
1447 | var ok = confirm(__("Reset to defaults?")); | |
1448 | ||
1449 | if (ok) { | |
1450 | ||
1451 | var query = Form.serialize("pref_prefs_form"); | |
1452 | query = query + "&subop=reset-config"; | |
1453 | debug(query); | |
1454 | ||
1455 | xmlhttp.open("POST", "backend.php", true); | |
1456 | xmlhttp.onreadystatechange=prefs_reset_callback; | |
1457 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1458 | xmlhttp.send(query); | |
1459 | } | |
1460 | ||
1461 | } catch (e) { | |
1462 | exception_error("validatePrefsSave", e); | |
1463 | } | |
1464 | ||
1465 | return false; | |
1466 | ||
69668465 | 1467 | } |
f9cb39ac | 1468 | |
6311acbe | 1469 | function browseFeeds(limit) { |
f9cb39ac AD |
1470 | |
1471 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true); | |
1472 | xmlhttp.onreadystatechange=infobox_callback; | |
1473 | xmlhttp.send(null); | |
1474 | ||
1475 | } | |
a0476535 AD |
1476 | |
1477 | function feedBrowserSubscribe() { | |
1478 | try { | |
a0476535 | 1479 | |
c0ae0fdb | 1480 | var selected = getSelectedFeedsFromBrowser(); |
a0476535 AD |
1481 | |
1482 | if (selected.length > 0) { | |
1483 | closeInfoBox(); | |
1484 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+ | |
1485 | param_escape(selected.toString()), true); | |
1486 | xmlhttp.onreadystatechange=feedlist_callback; | |
1487 | xmlhttp.send(null); | |
1488 | } else { | |
89cb787e | 1489 | alert(__("No feeds are selected.")); |
a0476535 AD |
1490 | } |
1491 | ||
1492 | } catch (e) { | |
1493 | exception_error("feedBrowserSubscribe", e); | |
1494 | } | |
1495 | } | |
c6232e43 | 1496 | |
ce8de904 AD |
1497 | function updateBigFeedBrowserBtn() { |
1498 | notify_progress("Loading, please wait..."); | |
1499 | return updateBigFeedBrowser(); | |
1500 | } | |
1501 | ||
1502 | function updateBigFeedBrowser(limit, from_button) { | |
c6232e43 AD |
1503 | |
1504 | if (!xmlhttp_ready(xmlhttp)) { | |
1505 | printLockingError(); | |
1506 | return | |
1507 | } | |
1508 | ||
6311acbe AD |
1509 | var query = "backend.php?op=pref-feed-browser"; |
1510 | ||
1511 | var limit_sel = document.getElementById("feedBrowserLimit"); | |
1512 | ||
1513 | if (limit_sel) { | |
1514 | var limit = limit_sel[limit_sel.selectedIndex].value; | |
1515 | query = query + "&limit=" + param_escape(limit); | |
1516 | } | |
1517 | ||
1518 | xmlhttp.open("GET", query, true); | |
c6232e43 AD |
1519 | xmlhttp.onreadystatechange=feed_browser_callback; |
1520 | xmlhttp.send(null); | |
c6232e43 AD |
1521 | } |
1522 | ||
c2b2aee0 | 1523 | function browserToggleExpand(id) { |
c6232e43 AD |
1524 | try { |
1525 | /* if (feed_to_expand && feed_to_expand != id) { | |
1526 | var d = document.getElementById("BRDET-" + feed_to_expand); | |
1527 | d.style.display = "none"; | |
1528 | } */ | |
c2b2aee0 | 1529 | |
ff725e9b AD |
1530 | if (!xmlhttp_ready(xmlhttp)) { |
1531 | printLockingError(); | |
1532 | return | |
1533 | } | |
1534 | ||
051c4d56 AD |
1535 | /* if (feed_to_expand && id != feed_to_expand) { |
1536 | Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5}); | |
1537 | } */ | |
c2b2aee0 | 1538 | |
051c4d56 | 1539 | var d = document.getElementById("BRDET-" + id); |
c6232e43 | 1540 | |
34a01a20 | 1541 | if (Element.visible(d)) { |
051c4d56 | 1542 | Effect.Fade(d, {duration : 0.5}); |
34a01a20 | 1543 | } else { |
c2b2aee0 | 1544 | feed_to_expand = id; |
c6232e43 | 1545 | |
c2b2aee0 AD |
1546 | xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id=" |
1547 | + param_escape(id), true); | |
1548 | xmlhttp.onreadystatechange=expand_feed_callback; | |
1549 | xmlhttp.send(null); | |
1550 | } | |
c6232e43 AD |
1551 | |
1552 | } catch (e) { | |
34a01a20 | 1553 | exception_error("browserToggleExpand", e); |
c6232e43 AD |
1554 | } |
1555 | } | |
64dc5976 | 1556 | |
ce3bf408 AD |
1557 | function selectPrefRows(kind, select) { |
1558 | ||
1559 | if (kind) { | |
1560 | var opbarid = false; | |
1561 | var nchk = false; | |
1562 | var nrow = false; | |
1563 | var lname = false; | |
1564 | ||
1565 | if (kind == "feed") { | |
1566 | opbarid = "feedOpToolbar"; | |
1567 | nrow = "FEEDR-"; | |
1568 | nchk = "FRCHK-"; | |
1569 | lname = "prefFeedList"; | |
1570 | } else if (kind == "fcat") { | |
1571 | opbarid = "catOpToolbar"; | |
1572 | nrow = "FCATR-"; | |
9c483746 | 1573 | nchk = "FCCHK-"; |
ce3bf408 AD |
1574 | lname = "prefFeedCatList"; |
1575 | } else if (kind == "filter") { | |
1576 | opbarid = "filterOpToolbar"; | |
1577 | nrow = "FILRR-"; | |
1578 | nchk = "FICHK-"; | |
1579 | lname = "prefFilterList"; | |
1580 | } else if (kind == "label") { | |
1581 | opbarid = "labelOpToolbar"; | |
1582 | nrow = "LILRR-"; | |
a4dbc524 | 1583 | nchk = "LICHK-"; |
ce3bf408 AD |
1584 | lname = "prefLabelList"; |
1585 | } else if (kind == "user") { | |
1586 | opbarid = "userOpToolbar"; | |
1587 | nrow = "UMRR-"; | |
1588 | nchk = "UMCHK-"; | |
1589 | lname = "prefUserList"; | |
1590 | } | |
1591 | ||
1592 | if (opbarid) { | |
1593 | selectTableRowsByIdPrefix(lname, nrow, nchk, select); | |
1594 | disableContainerChildren(opbarid, !select); | |
1595 | } | |
1596 | ||
1597 | } | |
1598 | } | |
1599 | ||
1600 | ||
1601 | function toggleSelectPrefRow(sender, kind) { | |
1602 | ||
1603 | toggleSelectRow(sender); | |
1604 | ||
1605 | if (kind) { | |
1606 | var opbarid = false; | |
1607 | var nsel = -1; | |
1608 | ||
1609 | if (kind == "feed") { | |
1610 | opbarid = "feedOpToolbar"; | |
1611 | nsel = getSelectedFeeds(); | |
1612 | } else if (kind == "fcat") { | |
1613 | opbarid = "catOpToolbar"; | |
1614 | nsel = getSelectedFeedCats(); | |
1615 | } else if (kind == "filter") { | |
1616 | opbarid = "filterOpToolbar"; | |
1617 | nsel = getSelectedFilters(); | |
1618 | } else if (kind == "label") { | |
1619 | opbarid = "labelOpToolbar"; | |
1620 | nsel = getSelectedLabels(); | |
1621 | } else if (kind == "user") { | |
1622 | opbarid = "userOpToolbar"; | |
1623 | nsel = getSelectedUsers(); | |
1624 | } | |
1625 | ||
1626 | if (opbarid && nsel != -1) { | |
1627 | disableContainerChildren(opbarid, nsel == false); | |
1628 | } | |
1629 | ||
1630 | } | |
1631 | } | |
1632 | ||
c0ae0fdb AD |
1633 | function toggleSelectFBListRow(sender) { |
1634 | toggleSelectListRow(sender); | |
1635 | disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0); | |
1636 | } | |
d437c8cf AD |
1637 | |
1638 | var seq = ""; | |
1639 | ||
1640 | function pref_hotkey_handler(e) { | |
1641 | try { | |
1642 | ||
1643 | var keycode; | |
746dcf42 AD |
1644 | var shift_key = false; |
1645 | ||
1646 | try { | |
1647 | shift_key = e.shiftKey; | |
1648 | } catch (e) { | |
1649 | ||
1650 | } | |
1651 | ||
d437c8cf AD |
1652 | if (window.event) { |
1653 | keycode = window.event.keyCode; | |
1654 | } else if (e) { | |
1655 | keycode = e.which; | |
1656 | } | |
746dcf42 | 1657 | |
eec498c3 AD |
1658 | var keychar = String.fromCharCode(keycode); |
1659 | ||
746dcf42 AD |
1660 | if (keycode == 27) { // escape |
1661 | if (Element.visible("hotkey_help_overlay")) { | |
1662 | Element.hide("hotkey_help_overlay"); | |
1663 | } | |
1664 | hotkey_prefix = false; | |
1665 | closeInfoBox(); | |
1666 | } | |
1667 | ||
1668 | if (!hotkeys_enabled) { | |
1669 | debug("hotkeys disabled"); | |
1670 | return; | |
1671 | } | |
1672 | ||
1673 | if (keycode == 16) return; // ignore lone shift | |
1674 | ||
6068d33b AD |
1675 | if ((keycode == 67 || keycode == 71) && !hotkey_prefix) { |
1676 | hotkey_prefix = keycode; | |
eec498c3 | 1677 | debug("KP: PREFIX=" + keycode + " CHAR=" + keychar); |
6068d33b AD |
1678 | return; |
1679 | } | |
1680 | ||
746dcf42 AD |
1681 | if (Element.visible("hotkey_help_overlay")) { |
1682 | Element.hide("hotkey_help_overlay"); | |
1683 | } | |
1684 | ||
d437c8cf AD |
1685 | if (keycode == 13 || keycode == 27) { |
1686 | seq = ""; | |
1687 | } else { | |
1688 | seq = seq + "" + keycode; | |
1689 | } | |
1690 | ||
746dcf42 | 1691 | /* Global hotkeys */ |
d437c8cf | 1692 | |
746dcf42 AD |
1693 | if (!hotkey_prefix) { |
1694 | ||
1695 | if (keycode == 68 && shift_key) { // d | |
8836613c AD |
1696 | if (!Element.visible("debug_output")) { |
1697 | Element.show("debug_output"); | |
746dcf42 AD |
1698 | debug('debug mode activated'); |
1699 | } else { | |
8836613c | 1700 | Element.hide("debug_output"); |
746dcf42 | 1701 | } |
746dcf42 AD |
1702 | return; |
1703 | } | |
1704 | ||
eec498c3 | 1705 | if ((keycode == 191 || keychar == '?') && shift_key) { // ? |
746dcf42 | 1706 | if (!Element.visible("hotkey_help_overlay")) { |
86deaa0e AD |
1707 | //Element.show("hotkey_help_overlay"); |
1708 | Effect.Appear("hotkey_help_overlay", {duration : 0.3}); | |
746dcf42 AD |
1709 | } else { |
1710 | Element.hide("hotkey_help_overlay"); | |
1711 | } | |
eec498c3 | 1712 | return false; |
746dcf42 AD |
1713 | } |
1714 | ||
eec498c3 | 1715 | if (keycode == 191 || keychar == '/') { // / |
477402d8 AD |
1716 | var search_boxes = new Array("label_search", |
1717 | "feed_search", "filter_search", "user_search"); | |
1718 | ||
1719 | for (var i = 0; i < search_boxes.length; i++) { | |
1720 | var elem = document.getElementById(search_boxes[i]); | |
1721 | if (elem) { | |
eec498c3 AD |
1722 | focus_element(search_boxes[i]); |
1723 | return false; | |
477402d8 AD |
1724 | } |
1725 | } | |
477402d8 | 1726 | } |
6068d33b AD |
1727 | } |
1728 | ||
1729 | /* Prefix c */ | |
1730 | ||
1731 | if (hotkey_prefix == 67) { // c | |
1732 | hotkey_prefix = false; | |
1733 | ||
1734 | if (keycode == 70) { // f | |
eec498c3 AD |
1735 | displayDlg("quickAddFilter"); |
1736 | return false; | |
6068d33b AD |
1737 | } |
1738 | ||
1739 | if (keycode == 83) { // s | |
eec498c3 AD |
1740 | displayDlg("quickAddFeed"); |
1741 | return false; | |
6068d33b AD |
1742 | } |
1743 | ||
ceb30ba4 | 1744 | /* if (keycode == 76) { // l |
eec498c3 AD |
1745 | displayDlg("quickAddLabel"); |
1746 | return false; | |
ceb30ba4 | 1747 | } */ |
6068d33b AD |
1748 | |
1749 | if (keycode == 85) { // u | |
1750 | // no-op | |
1751 | } | |
1752 | ||
57f734c8 | 1753 | if (keycode == 67) { // c |
eec498c3 AD |
1754 | editFeedCats(); |
1755 | return false; | |
57f734c8 AD |
1756 | } |
1757 | ||
a80b05ea | 1758 | if (keycode == 84 && shift_key) { // T |
eec498c3 AD |
1759 | browseFeeds(); |
1760 | return false; | |
a80b05ea AD |
1761 | } |
1762 | ||
6068d33b AD |
1763 | } |
1764 | ||
1765 | /* Prefix g */ | |
1766 | ||
1767 | if (hotkey_prefix == 71) { // g | |
1768 | ||
1769 | hotkey_prefix = false; | |
1770 | ||
1771 | if (keycode == 49 && document.getElementById("genConfigTab")) { // 1 | |
746dcf42 | 1772 | selectTab("genConfig"); |
eec498c3 | 1773 | return false; |
746dcf42 AD |
1774 | } |
1775 | ||
1776 | if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2 | |
eec498c3 AD |
1777 | selectTab("feedConfig"); |
1778 | return false; | |
746dcf42 AD |
1779 | } |
1780 | ||
1781 | if (keycode == 51 && document.getElementById("feedBrowserTab")) { // 3 | |
eec498c3 AD |
1782 | selectTab("feedBrowser"); |
1783 | return false; | |
746dcf42 AD |
1784 | } |
1785 | ||
1786 | if (keycode == 52 && document.getElementById("filterConfigTab")) { // 4 | |
eec498c3 AD |
1787 | selectTab("filterConfig"); |
1788 | return false; | |
746dcf42 AD |
1789 | } |
1790 | ||
1791 | if (keycode == 53 && document.getElementById("labelConfigTab")) { // 5 | |
eec498c3 AD |
1792 | selectTab("labelConfig"); |
1793 | return false; | |
746dcf42 AD |
1794 | } |
1795 | ||
1796 | if (keycode == 54 && document.getElementById("userConfigTab")) { // 6 | |
eec498c3 AD |
1797 | selectTab("userConfig"); |
1798 | return false; | |
746dcf42 AD |
1799 | } |
1800 | ||
8d727bfc AD |
1801 | if (keycode == 88) { // x |
1802 | return gotoMain(); | |
1803 | } | |
1804 | ||
746dcf42 AD |
1805 | } |
1806 | ||
1807 | if (document.getElementById("piggie")) { | |
1808 | ||
1809 | if (seq.match("807371717369")) { | |
1810 | seq = ""; | |
eec498c3 | 1811 | piggie(true); |
746dcf42 | 1812 | } else { |
eec498c3 | 1813 | piggie(false); |
746dcf42 AD |
1814 | } |
1815 | } | |
1816 | ||
1817 | if (hotkey_prefix) { | |
eec498c3 | 1818 | debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar); |
d437c8cf | 1819 | } else { |
eec498c3 | 1820 | debug("KP: CODE=" + keycode + " CHAR=" + keychar); |
d437c8cf | 1821 | } |
d437c8cf AD |
1822 | |
1823 | } catch (e) { | |
1824 | exception_error("pref_hotkey_handler", e); | |
1825 | } | |
1826 | } | |
1827 | ||
9c483746 AD |
1828 | function editFeedCats() { |
1829 | if (!xmlhttp_ready(xmlhttp)) { | |
1830 | printLockingError(); | |
1831 | return | |
1832 | } | |
1833 | ||
a349077c AD |
1834 | document.getElementById("subscribe_to_feed_btn").disabled = true; |
1835 | ||
1836 | try { | |
1837 | document.getElementById("top25_feeds_btn").disabled = true; | |
1838 | } catch (e) { | |
1839 | // this button is not always available, no-op if not found | |
1840 | } | |
1841 | ||
9c483746 | 1842 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true); |
11f083e7 | 1843 | xmlhttp.onreadystatechange=infobox_feed_cat_callback; |
9c483746 AD |
1844 | xmlhttp.send(null); |
1845 | } | |
a3656a41 AD |
1846 | |
1847 | function showFeedsWithErrors() { | |
1848 | displayDlg('feedUpdateErrors'); | |
1849 | } | |
073ca0e6 | 1850 | |
d95bd220 AD |
1851 | function changeUserPassword() { |
1852 | ||
1853 | try { | |
1854 | ||
1855 | if (!xmlhttp_ready(xmlhttp)) { | |
1856 | printLockingError(); | |
1857 | return false; | |
1858 | } | |
1859 | ||
ae661a8c AD |
1860 | var f = document.forms["change_pass_form"]; |
1861 | ||
1862 | if (f) { | |
1863 | if (f.OLD_PASSWORD.value == "") { | |
1864 | new Effect.Highlight(f.OLD_PASSWORD); | |
1865 | notify_error("Old password cannot be blank."); | |
1866 | return false; | |
1867 | } | |
1868 | ||
1869 | if (f.NEW_PASSWORD.value == "") { | |
1870 | new Effect.Highlight(f.NEW_PASSWORD); | |
1871 | notify_error("New password cannot be blank."); | |
1872 | return false; | |
1873 | } | |
1874 | ||
1875 | if (f.CONFIRM_PASSWORD.value == "") { | |
1876 | new Effect.Highlight(f.CONFIRM_PASSWORD); | |
1877 | notify_error("Entered passwords do not match."); | |
1878 | return false; | |
1879 | } | |
1880 | ||
1881 | if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) { | |
1882 | new Effect.Highlight(f.CONFIRM_PASSWORD); | |
1883 | new Effect.Highlight(f.NEW_PASSWORD); | |
1884 | notify_error("Entered passwords do not match."); | |
1885 | return false; | |
1886 | } | |
1887 | ||
1888 | } | |
1889 | ||
d95bd220 AD |
1890 | var query = Form.serialize("change_pass_form"); |
1891 | ||
1892 | notify_progress("Trying to change password..."); | |
1893 | ||
1894 | xmlhttp.open("POST", "backend.php", true); | |
1895 | xmlhttp.onreadystatechange=changepass_callback; | |
1896 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1897 | xmlhttp.send(query); | |
1898 | ||
1899 | } catch (e) { | |
1900 | exception_error("changeUserPassword", e); | |
1901 | } | |
1902 | ||
1903 | return false; | |
1904 | } | |
073ca0e6 | 1905 | |
42395d28 AD |
1906 | function changeUserEmail() { |
1907 | ||
1908 | try { | |
1909 | ||
1910 | if (!xmlhttp_ready(xmlhttp)) { | |
1911 | printLockingError(); | |
1912 | return false; | |
1913 | } | |
1914 | ||
1915 | var query = Form.serialize("change_email_form"); | |
1916 | ||
1917 | notify_progress("Trying to change e-mail..."); | |
1918 | ||
1919 | xmlhttp.open("POST", "backend.php", true); | |
1920 | xmlhttp.onreadystatechange=notify_callback; | |
1921 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1922 | xmlhttp.send(query); | |
1923 | ||
1924 | } catch (e) { | |
1925 | exception_error("changeUserPassword", e); | |
1926 | } | |
1927 | ||
1928 | return false; | |
1929 | ||
1930 | } | |
400b60d8 AD |
1931 | |
1932 | function feedlistToggleSLAT() { | |
1933 | notify_progress("Loading, please wait..."); | |
1934 | updateFeedList() | |
1935 | } | |
bc0ed820 | 1936 | |
e4f4b46f AD |
1937 | function pubRegenKey() { |
1938 | ||
bc0ed820 AD |
1939 | if (!xmlhttp_ready(xmlhttp)) { |
1940 | printLockingError(); | |
e4f4b46f | 1941 | return false; |
bc0ed820 AD |
1942 | } |
1943 | ||
f56e3080 | 1944 | var ok = confirm(__("Replace current publishing address with a new one?")); |
bc0ed820 | 1945 | |
e4f4b46f AD |
1946 | if (ok) { |
1947 | ||
1948 | notify_progress("Trying to change address..."); | |
1949 | ||
945c243e | 1950 | xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey"); |
e4f4b46f AD |
1951 | xmlhttp.onreadystatechange=replace_pubkey_callback; |
1952 | xmlhttp.send(null); | |
1953 | } | |
1954 | ||
1955 | return false; | |
945c243e | 1956 | } |
b652c1b7 | 1957 | |
e635d56a AD |
1958 | function pubToClipboard() { |
1959 | ||
1960 | try { | |
1961 | ||
1962 | if (!xmlhttp_ready(xmlhttp)) { | |
1963 | printLockingError(); | |
1964 | return false; | |
1965 | } | |
1966 | ||
1967 | var link = document.getElementById("pubGenAddress"); | |
1968 | alert(link.href); | |
1969 | ||
1970 | } catch (e) { | |
1971 | exception_error("pubToClipboard", e); | |
1972 | } | |
1973 | ||
1974 | return false; | |
1975 | } | |
1976 | ||
b652c1b7 AD |
1977 | function validatePrefsSave() { |
1978 | try { | |
1979 | ||
1980 | var ok = confirm(__("Save current configuration?")); | |
1981 | ||
1982 | if (ok) { | |
1983 | ||
1984 | var query = Form.serialize("pref_prefs_form"); | |
1985 | query = query + "&subop=save-config"; | |
1986 | debug(query); | |
1987 | ||
1988 | xmlhttp.open("POST", "backend.php", true); | |
1989 | xmlhttp.onreadystatechange=notify_callback; | |
1990 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
1991 | xmlhttp.send(query); | |
1992 | } | |
1993 | ||
1994 | } catch (e) { | |
1995 | exception_error("validatePrefsSave", e); | |
1996 | } | |
1997 | ||
1998 | return false; | |
1999 | } | |
c4a36709 AD |
2000 | |
2001 | function feedActionChange() { | |
2002 | try { | |
2003 | var chooser = document.getElementById("feedActionChooser"); | |
2004 | var opid = chooser[chooser.selectedIndex].value; | |
2005 | ||
2006 | chooser.selectedIndex = 0; | |
2007 | feedActionGo(opid); | |
2008 | } catch (e) { | |
2009 | exception_error("feedActionChange", e); | |
2010 | } | |
2011 | } | |
2012 | ||
2013 | function feedActionGo(op) { | |
2014 | try { | |
2015 | if (op == "facEdit") { | |
cd935c42 AD |
2016 | |
2017 | var rows = getSelectedFeeds(); | |
2018 | ||
2019 | if (rows.length > 1) { | |
2020 | editSelectedFeeds(); | |
2021 | } else { | |
2022 | editSelectedFeed(); | |
2023 | } | |
c4a36709 AD |
2024 | } |
2025 | ||
2026 | if (op == "facClear") { | |
2027 | clearSelectedFeeds(); | |
2028 | } | |
2029 | ||
2030 | if (op == "facPurge") { | |
2031 | purgeSelectedFeeds(); | |
2032 | } | |
2033 | ||
e88a65f4 AD |
2034 | if (op == "facEditCats") { |
2035 | editFeedCats(); | |
2036 | } | |
2037 | ||
fee840fb AD |
2038 | if (op == "facRescore") { |
2039 | rescoreSelectedFeeds(); | |
2040 | } | |
2041 | ||
c4a36709 AD |
2042 | if (op == "facUnsubscribe") { |
2043 | removeSelectedFeeds(); | |
2044 | } | |
2045 | ||
2046 | } catch (e) { | |
2047 | exception_error("feedActionGo", e); | |
2048 | ||
2049 | } | |
2050 | } | |
2051 | ||
2052 | function clearFeedArticles(feed_id) { | |
2053 | ||
2054 | notify_progress("Clearing feed..."); | |
2055 | ||
2056 | var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id; | |
2057 | ||
2058 | new Ajax.Request(query, { | |
2059 | onComplete: function(transport) { | |
2060 | notify(''); | |
2061 | } }); | |
2062 | ||
2063 | return false; | |
2064 | } | |
2065 | ||
fee840fb AD |
2066 | function rescoreSelectedFeeds() { |
2067 | ||
2068 | if (!xmlhttp_ready(xmlhttp)) { | |
2069 | printLockingError(); | |
2070 | return | |
2071 | } | |
2072 | ||
2073 | var sel_rows = getSelectedFeeds(); | |
2074 | ||
2075 | if (sel_rows.length > 0) { | |
2076 | ||
ef1b0366 AD |
2077 | //var ok = confirm(__("Rescore last 100 articles in selected feeds?")); |
2078 | var ok = confirm(__("Rescore articles in selected feeds?")); | |
fee840fb AD |
2079 | |
2080 | if (ok) { | |
3df4869b | 2081 | notify_progress("Rescoring selected feeds...", true); |
fee840fb AD |
2082 | |
2083 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+ | |
2084 | param_escape(sel_rows.toString()), true); | |
2085 | xmlhttp.onreadystatechange=notify_callback; | |
2086 | xmlhttp.send(null); | |
2087 | } | |
2088 | } else { | |
2089 | alert(__("No feeds are selected.")); | |
2090 | } | |
2091 | ||
2092 | return false; | |
2093 | } | |
c4a36709 | 2094 | |
95a948a5 AD |
2095 | function rescore_all_feeds() { |
2096 | var ok = confirm(__("Rescore all articles? This operation may take a lot of time.")); | |
2097 | ||
2098 | if (ok) { | |
3df4869b | 2099 | notify_progress("Rescoring feeds...", true); |
95a948a5 AD |
2100 | |
2101 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true); | |
2102 | xmlhttp.onreadystatechange=notify_callback; | |
2103 | xmlhttp.send(null); | |
2104 | } | |
a80b05ea | 2105 | } |
a44db887 AD |
2106 | |
2107 | function removeFilter(id, title) { | |
2108 | ||
2109 | if (!xmlhttp_ready(xmlhttp)) { | |
2110 | printLockingError(); | |
2111 | return | |
2112 | } | |
2113 | ||
2114 | var msg = __("Remove filter %s?").replace("%s", title); | |
2115 | ||
2116 | var ok = confirm(msg); | |
2117 | ||
2118 | if (ok) { | |
2119 | closeInfoBox(); | |
2120 | ||
2121 | notify_progress("Removing filter..."); | |
2122 | ||
2123 | xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ | |
2124 | param_escape(id), true); | |
2125 | xmlhttp.onreadystatechange=filterlist_callback; | |
2126 | xmlhttp.send(null); | |
2127 | } | |
2128 | ||
2129 | return false; | |
2130 | } | |
2131 | ||
c8d5dcfe AD |
2132 | function unsubscribeFeed(id, title) { |
2133 | ||
2134 | if (!xmlhttp_ready(xmlhttp)) { | |
2135 | printLockingError(); | |
2136 | return | |
2137 | } | |
2138 | ||
2139 | var msg = __("Unsubscribe from %s?").replace("%s", title); | |
2140 | ||
2141 | var ok = confirm(msg); | |
2142 | ||
2143 | if (ok) { | |
2144 | closeInfoBox(); | |
2145 | ||
2146 | notify_progress("Removing feed..."); | |
2147 | ||
2148 | xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ | |
2149 | param_escape(id), true); | |
2150 | xmlhttp.onreadystatechange=filterlist_callback; | |
2151 | xmlhttp.send(null); | |
2152 | } | |
2153 | ||
2154 | return false; | |
2155 | ||
2156 | return false; | |
2157 | ||
2158 | } | |
2159 | ||
758e1c4a AD |
2160 | function feedsEditSave() { |
2161 | try { | |
2162 | ||
2163 | if (!xmlhttp_ready(xmlhttp)) { | |
2164 | printLockingError(); | |
2165 | return | |
2166 | } | |
2167 | ||
cd935c42 | 2168 | var ok = confirm(__("Save changes to selected feeds?")); |
758e1c4a | 2169 | |
b0f015a2 AD |
2170 | if (ok) { |
2171 | ||
5d538f4f AD |
2172 | var f = document.forms["batch_edit_feed_form"]; |
2173 | ||
b0f015a2 | 2174 | var query = Form.serialize("batch_edit_feed_form"); |
5d538f4f AD |
2175 | |
2176 | /* Form.serialize ignores unchecked checkboxes */ | |
2177 | ||
cd935c42 | 2178 | if (!query.match("&hidden=") && |
5d538f4f AD |
2179 | f.hidden.disabled == false) { |
2180 | query = query + "&hidden=false"; | |
2181 | } | |
2182 | ||
cd935c42 | 2183 | if (!query.match("&rtl_content=") && |
5d538f4f AD |
2184 | f.rtl_content.disabled == false) { |
2185 | query = query + "&rtl_content=false"; | |
2186 | } | |
2187 | ||
cd935c42 | 2188 | if (!query.match("&private=") && |
5d538f4f AD |
2189 | f.private.disabled == false) { |
2190 | query = query + "&private=false"; | |
2191 | } | |
2192 | ||
cd935c42 | 2193 | if (!query.match("&cache_images=") && |
5d538f4f AD |
2194 | f.cache_images.disabled == false) { |
2195 | query = query + "&cache_images=false"; | |
2196 | } | |
2197 | ||
cd935c42 | 2198 | if (!query.match("&include_in_digest=") && |
5d538f4f AD |
2199 | f.include_in_digest.disabled == false) { |
2200 | query = query + "&include_in_digest=false"; | |
2201 | } | |
b0f015a2 AD |
2202 | |
2203 | closeInfoBox(); | |
2204 | ||
2205 | notify_progress("Saving feeds..."); | |
2206 | ||
2207 | xmlhttp.open("POST", "backend.php", true); | |
2208 | xmlhttp.onreadystatechange=feedlist_callback; | |
2209 | xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
2210 | xmlhttp.send(query); | |
2211 | } | |
758e1c4a AD |
2212 | |
2213 | return false; | |
2214 | } catch (e) { | |
2215 | exception_error("feedsEditSave", e); | |
2216 | } | |
2217 | } | |
2218 | ||
2219 | function batchFeedsToggleField(cb, elem, label) { | |
2220 | try { | |
2221 | var f = document.forms["batch_edit_feed_form"]; | |
2222 | var l = document.getElementById(label); | |
2223 | ||
2224 | if (cb.checked) { | |
2225 | f[elem].disabled = false; | |
2226 | ||
2227 | if (l) { | |
2228 | l.className = ""; | |
2229 | }; | |
2230 | ||
2231 | // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5", | |
2232 | // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } ); | |
2233 | ||
2234 | } else { | |
2235 | f[elem].disabled = true; | |
2236 | ||
2237 | if (l) { | |
2238 | l.className = "insensitive"; | |
2239 | }; | |
2240 | ||
2241 | } | |
2242 | } catch (e) { | |
2243 | exception_error("batchFeedsToggleField", e); | |
2244 | } | |
2245 | } | |
2246 |