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