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