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