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