]> git.wh0rd.org - tt-rss.git/blame - tt-rss.js
fix viewCategory() for opera 9.20
[tt-rss.git] / tt-rss.js
CommitLineData
1cd17194 1var xmlhttp = false;
76798ff3 2var total_unread = 0;
525116d4 3var first_run = true;
8143ae1f 4var display_tags = false;
806a3d14 5var global_unread = -1;
21703604 6var active_title_text = "";
21703604 7var current_subtitle = "";
c6784aea 8var daemon_enabled = false;
0d51e25d 9var daemon_refresh_only = false;
15da5cc1 10var _qfd_deleted_feed = 0;
2bf6e0a8 11var firsttime_update = true;
c441662f 12var last_refetch = 0;
76b4eae1 13var cookie_lifetime = 0;
33d13e72 14var active_feed_id = 0;
0a6c4846 15var active_feed_is_cat = false;
9e397d0f 16var number_of_feeds = 0;
7a09510c 17var sanity_check_done = false;
15da5cc1 18
a58069db 19var xmlhttp = Ajax.getTransport();
abbe0154 20var xmlhttp_ctr = Ajax.getTransport();
1cd17194 21
1035fcec 22var init_params = new Object();
3ac2b520 23
1dc8dba0
AD
24var op_history = new Array();
25
0b126ac2
AD
26function tagsAreDisplayed() {
27 return display_tags;
28}
29
8143ae1f
AD
30function toggleTags() {
31 display_tags = !display_tags;
32
33 var p = document.getElementById("dispSwitchPrompt");
34
35 if (display_tags) {
709e7dc2 36 p.innerHTML = __("display feeds");
8143ae1f 37 } else {
709e7dc2 38 p.innerHTML = __("display tags");
8143ae1f
AD
39 }
40
42c32916 41 notify_progress("Loading, please wait...");
807f452a 42
8143ae1f
AD
43 updateFeedList();
44}
45
6de5d056 46function dlg_frefresh_callback() {
abbe0154 47 if (xmlhttp.readyState == 4) {
a58d997c 48// notify(xmlhttp.responseText);
abbe0154
AD
49
50 if (getActiveFeedId() == _qfd_deleted_feed) {
51 var h = document.getElementById("headlines-frame");
52 if (h) {
53 h.innerHTML = "<div class='whiteBox'>No feed selected.</div>";
54 }
55 }
56
0e9dd1ba 57 setTimeout('updateFeedList(false, false)', 50);
eff4997c 58 closeInfoBox();
c0e5a40e 59 }
1cd17194 60}
e2f8f7b4 61
8158c57a 62function refetch_callback() {
abbe0154 63 if (xmlhttp_ctr.readyState == 4) {
7719618b 64 try {
310da49d 65
c441662f
AD
66 var date = new Date();
67
68 last_refetch = date.getTime() / 1000;
69
3ac2f3c7 70 parse_counters_reply(xmlhttp_ctr, true);
71ad883b 71
0ee1d1a0
AD
72 debug("refetch_callback: done");
73
0d51e25d 74 if (!daemon_enabled && !daemon_refresh_only) {
42c32916 75 notify_info("All feeds updated.");
5a180505 76 updateTitle("");
4c059b7b 77 } else {
0f088bfc 78 //notify("");
c6784aea 79 }
7719618b
AD
80 } catch (e) {
81 exception_error("refetch_callback", e);
e2cb4c6d 82 updateTitle("");
7719618b 83 }
090e250b
AD
84 }
85}
1a66d16e 86
295f9b42
AD
87function backend_sanity_check_callback() {
88
89 if (xmlhttp.readyState == 4) {
295f9b42 90
7719618b 91 try {
7a09510c
AD
92
93 if (sanity_check_done) {
81352b54
AD
94 fatalError(11, "Sanity check request received twice. This can indicate "+
95 "presence of Firebug or some other disrupting extension. "+
96 "Please disable it and try again.");
7a09510c
AD
97 return;
98 }
99
7719618b 100 if (!xmlhttp.responseXML) {
462a192b 101 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
7719618b
AD
102 return;
103 }
295f9b42 104
3ac2b520 105 var reply = xmlhttp.responseXML.firstChild.firstChild;
7719618b
AD
106
107 if (!reply) {
af106b0e 108 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
7719618b
AD
109 return;
110 }
111
112 var error_code = reply.getAttribute("error-code");
113
114 if (error_code && error_code != 0) {
af106b0e 115 return fatalError(error_code, reply.getAttribute("error-msg"));
7719618b
AD
116 }
117
0ee1d1a0
AD
118 debug("sanity check ok");
119
3ac2b520
AD
120 var params = reply.nextSibling;
121
122 if (params) {
123 debug('reading init-params...');
124 var param = params.firstChild;
125
126 while (param) {
127 var k = param.getAttribute("key");
128 var v = param.getAttribute("value");
129 debug(k + " => " + v);
130 init_params[k] = v;
131 param = param.nextSibling;
132 }
133 }
134
7a09510c
AD
135 sanity_check_done = true;
136
7719618b 137 init_second_stage();
295f9b42 138
7719618b
AD
139 } catch (e) {
140 exception_error("backend_sanity_check_callback", e);
141 }
295f9b42
AD
142 }
143}
144
cb246176 145function scheduleFeedUpdate(force) {
525116d4 146
0d51e25d 147 if (!daemon_enabled && !daemon_refresh_only) {
42c32916 148 notify_progress("Updating feeds, please wait.", true);
c6784aea
AD
149 updateTitle("Updating");
150 }
55193822 151
cb246176
AD
152 var query_str = "backend.php?op=rpc&subop=";
153
154 if (force) {
c3b81db0 155 query_str = query_str + "forceUpdateAllFeeds";
cb246176 156 } else {
c3b81db0 157 query_str = query_str + "updateAllFeeds";
cb246176 158 }
525116d4 159
9826bd2e
AD
160 var omode;
161
b6104dee 162 if (firsttime_update && !navigator.userAgent.match("Opera")) {
2bf6e0a8
AD
163 firsttime_update = false;
164 omode = "T";
9826bd2e 165 } else {
2bf6e0a8 166 if (display_tags) {
cf4d339c 167 omode = "tl";
2bf6e0a8
AD
168 } else {
169 omode = "flc";
170 }
9826bd2e 171 }
2bf6e0a8 172
9826bd2e 173 query_str = query_str + "&omode=" + omode;
78ea1de0 174 query_str = query_str + "&uctr=" + global_unread;
9826bd2e 175
0ee1d1a0 176 debug("in scheduleFeedUpdate");
2bf6e0a8 177
c441662f
AD
178 var date = new Date();
179
89fbb3bc
AD
180 var timestamp = Math.round(date.getTime() / 1000);
181 query_str = query_str + "&ts=" + timestamp
182
abbe0154 183 if (!xmlhttp_ready(xmlhttp_ctr) && last_refetch < date.getTime() / 1000 - 60) {
a7565293 184 debug("<b>xmlhttp seems to be stuck, aborting</b>");
abbe0154 185 xmlhttp_ctr.abort();
c441662f
AD
186 }
187
52db9978
AD
188 debug("REFETCH query: " + query_str);
189
abbe0154
AD
190 if (xmlhttp_ready(xmlhttp_ctr)) {
191 xmlhttp_ctr.open("GET", query_str, true);
192 xmlhttp_ctr.onreadystatechange=refetch_callback;
193 xmlhttp_ctr.send(null);
525116d4 194 } else {
abbe0154 195 debug("xmlhttp_ctr busy");
bed0f18f 196 //printLockingError();
c0e5a40e 197 }
525116d4 198}
1cd17194 199
525116d4 200function updateFeedList(silent, fetch) {
c0e5a40e 201
1a66d16e
AD
202// if (silent != true) {
203// notify("Loading feed list...");
204// }
82baad4a 205
cf4d339c
AD
206 debug("<b>updateFeedList</b>");
207
331900c6
AD
208 var query_str = "backend.php?op=feeds";
209
8143ae1f
AD
210 if (display_tags) {
211 query_str = query_str + "&tags=1";
212 }
213
5c365f60 214 if (getActiveFeedId() && !activeFeedIsCat()) {
86741347 215 query_str = query_str + "&actid=" + getActiveFeedId();
175847de
AD
216 }
217
86173d9a
AD
218 var date = new Date();
219 var timestamp = Math.round(date.getTime() / 1000);
220 query_str = query_str + "&ts=" + timestamp
59b8192f 221
1a66d16e 222 if (fetch) query_str = query_str + "&fetch=yes";
e1123aee 223
6b4163cb
AD
224// var feeds_frame = document.getElementById("feeds-frame");
225// feeds_frame.src = query_str;
226
0e9dd1ba 227 debug("updateFeedList Q=" + query_str);
6b4163cb
AD
228
229 if (xmlhttp_ready(xmlhttp)) {
230 xmlhttp.open("GET", query_str, true);
231 xmlhttp.onreadystatechange=feedlist_callback;
232 xmlhttp.send(null);
233 } else {
234 debug("xmlhttp busy");
235 //printLockingError();
236 }
e1123aee 237
1a66d16e 238}
175847de 239
476cac42 240function catchupAllFeeds() {
076682aa 241
476cac42
AD
242 var query_str = "backend.php?op=feeds&subop=catchupAll";
243
42c32916 244 notify_progress("Marking all feeds as read...");
476cac42 245
ca2f46a7 246 debug("catchupAllFeeds Q=" + query_str);
1a66d16e 247
ca2f46a7
AD
248 if (xmlhttp_ready(xmlhttp)) {
249 xmlhttp.open("GET", query_str, true);
250 xmlhttp.onreadystatechange=feedlist_callback;
251 xmlhttp.send(null);
252 } else {
253 debug("xmlhttp busy");
254 //printLockingError();
255 }
476cac42 256
fc69e641 257 global_unread = 0;
21703604 258 updateTitle("");
fc69e641 259
476cac42 260}
1cd17194 261
767e2486 262function viewCurrentFeed(subop) {
1a66d16e 263
ec6e2fd3
AD
264// if (getActiveFeedId()) {
265 if (getActiveFeedId() != undefined) {
767e2486 266 viewfeed(getActiveFeedId(), subop);
033e47e0
AD
267 } else {
268 disableContainerChildren("headlinesToolbar", false, document);
ec6e2fd3 269// viewfeed(-1, subop); // FIXME
f0601b87 270 }
164f4738 271 return false; // block unneeded form submits
f0601b87
AD
272}
273
767e2486 274function viewfeed(feed, subop) {
db8d6f67 275 var f = window.frames["feeds-frame"];
767e2486 276 f.viewfeed(feed, subop);
9cfc649a
AD
277}
278
40d13c28 279function timeout() {
05732aa0 280 scheduleFeedUpdate(false);
f5de0d8d 281
3ac2b520 282 var refresh_time = getInitParam("feeds_frame_refresh");
f5de0d8d 283
3ac2b520 284 if (!refresh_time) refresh_time = 600;
f5de0d8d
AD
285
286 setTimeout("timeout()", refresh_time*1000);
ac53063a
AD
287}
288
c374a3fe 289function resetSearch() {
64c620ce
AD
290 var searchbox = document.getElementById("searchbox")
291
86741347 292 if (searchbox.value != "" && getActiveFeedId()) {
64c620ce 293 searchbox.value = "";
767e2486 294 viewfeed(getActiveFeedId(), "");
ac43eba1 295 }
c374a3fe 296}
ac53063a 297
86b682ce
AD
298function searchCancel() {
299 closeInfoBox(true);
300}
301
f0601b87 302function search() {
eff4997c 303 closeInfoBox();
4ce19859 304 viewCurrentFeed(0, "");
76798ff3 305}
1cd17194 306
13ad9102
AD
307function localPiggieFunction(enable) {
308 if (enable) {
309 var query_str = "backend.php?op=feeds&subop=piggie";
310
c0e5a40e 311 if (xmlhttp_ready(xmlhttp)) {
13ad9102
AD
312
313 xmlhttp.open("GET", query_str, true);
314 xmlhttp.onreadystatechange=feedlist_callback;
315 xmlhttp.send(null);
316 }
317 }
318}
319
806a3d14
AD
320// if argument is undefined, current subtitle is not updated
321// use blank string to clear subtitle
fc69e641
AD
322function updateTitle(s) {
323 var tmp = "Tiny Tiny RSS";
21703604 324
5a494a0b 325 if (s != undefined) {
21703604
AD
326 current_subtitle = s;
327 }
328
fc69e641
AD
329 if (global_unread > 0) {
330 tmp = tmp + " (" + global_unread + ")";
331 }
332
5a494a0b 333 if (current_subtitle) {
21703604 334 tmp = tmp + " - " + current_subtitle;
fc69e641 335 }
21703604
AD
336
337 if (active_title_text.length > 0) {
338 tmp = tmp + " > " + active_title_text;
339 }
340
fc69e641
AD
341 document.title = tmp;
342}
343
22a93ad8 344function genericSanityCheck() {
ac43eba1 345
295f9b42
AD
346 if (!xmlhttp) fatalError(1);
347
348 setCookie("ttrss_vf_test", "TEST");
349
350 if (getCookie("ttrss_vf_test") != "TEST") {
351 fatalError(2);
352 }
353
22a93ad8
AD
354 return true;
355}
356
357function init() {
358
7719618b 359 try {
fe2f1970 360
97dcd654
AD
361 // this whole shebang is based on http://www.birnamdesigns.com/misc/busted2.html
362
363 if (arguments.callee.done) return;
364 arguments.callee.done = true;
365
7719618b 366 disableContainerChildren("headlinesToolbar", true);
70830c87 367
86b682ce
AD
368 Form.disable("main_toolbar_form");
369
7719618b
AD
370 if (!genericSanityCheck())
371 return;
ac43eba1 372
0ee1d1a0
AD
373 if (getURLParam('debug')) {
374 document.getElementById('debug_output').style.display = 'block';
375 debug('debug mode activated');
376 }
377
4220d6b0
AD
378 var params = "&ua=" + param_escape(navigator.userAgent);
379
380 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck" + params, true);
7719618b
AD
381 xmlhttp.onreadystatechange=backend_sanity_check_callback;
382 xmlhttp.send(null);
47179952 383
7719618b
AD
384 } catch (e) {
385 exception_error("init", e);
a8d28f48 386 }
7719618b 387}
86741347 388
a9d42cf7
AD
389function resize_headlines() {
390 var h_frame = document.getElementById("headlines-frame");
391 var c_frame = document.getElementById("content-frame");
392
393 debug("resize_headlines");
394
395 if (c_frame && h_frame) {
396 h_frame.style.height = 30 + "%";
397 c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px";
398 h_frame.style.height = h_frame.offsetHeight + "px";
399 }
400}
401
7719618b 402function init_second_stage() {
295f9b42 403
7719618b 404 try {
2f587484 405
76b4eae1
AD
406 cookie_lifetime = getCookie("ttrss_cltime");
407
408 delCookie("ttrss_vf_test");
7719618b 409
e12a547e
AD
410 if (!is_msie()) {
411 document.onresize = resize_headlines;
412 resize_headlines();
413 }
1b0809ae 414
40496720 415 var toolbar = document.forms["main_toolbar_form"];
f31673f7 416
40496720
AD
417 dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode"));
418 dropboxSelect(toolbar.limit, getInitParam("default_view_limit"));
c6784aea 419
0d51e25d
AD
420 daemon_enabled = getInitParam("daemon_enabled") == 1;
421 daemon_refresh_only = getInitParam("daemon_refresh_only") == 1;
5f136c9a 422
0e9dd1ba 423 setTimeout('updateFeedList(false, false)', 50);
0ee1d1a0
AD
424
425 debug("second stage ok");
7719618b 426
7719618b
AD
427 } catch (e) {
428 exception_error("init_second_stage", e);
2f587484 429 }
1cd17194 430}
ac43eba1 431
c09ec856 432function quickMenuChange() {
cbe45fa8 433 var chooser = document.getElementById("quickMenuChooser");
86b682ce 434 var opid = chooser[chooser.selectedIndex].value;
e2f8f7b4 435
c09ec856
AD
436 chooser.selectedIndex = 0;
437 quickMenuGo(opid);
438}
439
440function quickMenuGo(opid) {
bb3423cf 441 try {
c09ec856 442
bb3423cf
AD
443 if (opid == "qmcPrefs") {
444 gotoPreferences();
445 }
446
447 if (opid == "qmcSearch") {
0a6c4846 448 displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat());
6de5d056
AD
449 return;
450 }
bb3423cf
AD
451
452 if (opid == "qmcAddFeed") {
453 displayDlg("quickAddFeed");
454 return;
69668465 455 }
7086277c
AD
456
457 if (opid == "qmcEditFeed") {
458 editFeedDlg(getActiveFeedId());
459 }
6de5d056 460
bb3423cf
AD
461 if (opid == "qmcRemoveFeed") {
462 var actid = getActiveFeedId();
463
5c365f60 464 if (!actid || activeFeedIsCat()) {
0530ddd8 465 alert("Please select some feed first.");
bb3423cf
AD
466 return;
467 }
64a2875d
AD
468
469 var fn = getFeedName(actid);
bb3423cf 470
64a2875d 471 if (confirm("Unsubscribe from " + fn + "?")) {
bb3423cf
AD
472 qfdDelete(actid);
473 }
474
475 return;
476 }
477
478 if (opid == "qmcUpdateFeeds") {
479 scheduleFeedUpdate(true);
480 return;
481 }
482
483 if (opid == "qmcCatchupAll") {
484 catchupAllFeeds();
485 return;
486 }
487
488 if (opid == "qmcShowOnlyUnread") {
489 toggleDispRead();
490 return;
491 }
492
493 if (opid == "qmcAddFilter") {
494 displayDlg("quickAddFilter", getActiveFeedId());
495 }
496 } catch (e) {
497 exception_error("quickMenuGo", e);
a24f525c 498 }
e2f8f7b4
AD
499}
500
6de5d056
AD
501function qfdDelete(feed_id) {
502
42c32916 503 notify_progress("Removing feed...");
6de5d056 504
7f123cda
AD
505 if (!xmlhttp_ready(xmlhttp)) {
506 printLockingError();
507 return
508 }
509
15da5cc1
AD
510 _qfd_deleted_feed = feed_id;
511
69668465 512 xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id);
6de5d056
AD
513 xmlhttp.onreadystatechange=dlg_frefresh_callback;
514 xmlhttp.send(null);
7bc4f251
AD
515
516 return false;
6de5d056 517}
033e47e0 518
3745788e 519
21703604
AD
520function updateFeedTitle(t) {
521 active_title_text = t;
522 updateTitle();
523}
524
3745788e 525function toggleDispRead() {
7f123cda 526 try {
3745788e 527
7f123cda
AD
528 if (!xmlhttp_ready(xmlhttp)) {
529 printLockingError();
530 return
531 }
3745788e 532
e8bd0da9 533 var hide_read_feeds = (getInitParam("hide_read_feeds") == "1");
3745788e 534
7f123cda 535 hide_read_feeds = !hide_read_feeds;
e8bd0da9
AD
536
537 debug("toggle_disp_read => " + hide_read_feeds);
538
539 hideOrShowFeeds(getFeedsContext().document, hide_read_feeds);
540
7f123cda
AD
541 var query = "backend.php?op=rpc&subop=setpref" +
542 "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
3745788e 543
e8bd0da9
AD
544 storeInitParam("hide_read_feeds", hide_read_feeds, true);
545
546 new Ajax.Request(query);
7f123cda
AD
547
548 } catch (e) {
549 exception_error("toggleDispRead", e);
3745788e 550 }
3745788e 551}
295f9b42 552
71ad883b 553function parse_runtime_info(elem) {
4724a093
AD
554 if (!elem) {
555 debug("parse_runtime_info: elem is null, aborting");
556 return;
557 }
558
71ad883b
AD
559 var param = elem.firstChild;
560
52db9978 561 debug("parse_runtime_info: " + param);
1cb7492d 562
71ad883b
AD
563 while (param) {
564 var k = param.getAttribute("key");
565 var v = param.getAttribute("value");
3ac2b520 566
1cb7492d
AD
567 debug("RI: " + k + " => " + v);
568
d9fa39f1
AD
569 if (k == "new_version_available") {
570 var icon = document.getElementById("newVersionIcon");
571 if (icon) {
572 if (v == "1") {
573 icon.style.display = "inline";
574 } else {
575 icon.style.display = "none";
576 }
577 }
578 }
579
ef16ae37 580 if (k == "daemon_is_running" && v != 1) {
42c32916 581 notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not runing.</span>");
ef16ae37
AD
582 }
583
584/* var w = document.getElementById("noDaemonWarning");
71ad883b
AD
585
586 if (w) {
587 if (k == "daemon_is_running" && v != 1) {
588 w.style.display = "block";
589 } else {
590 w.style.display = "none";
591 }
ef16ae37 592 } */
71ad883b
AD
593 param = param.nextSibling;
594 }
595}
fce24838
AD
596
597function catchupCurrentFeed() {
598
234e467c 599 var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
fce24838 600
234e467c
AD
601 var str = "Mark all articles in " + fn + " as read?";
602
603/* if (active_feed_is_cat) {
604 str = "Mark all articles in this category as read?";
605 } */
606
f6d6e22f 607 if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
28de3732 608 return viewCurrentFeed('MarkAllRead')
fce24838
AD
609 }
610}
88040f57 611
461766f3
AD
612function userSwitch() {
613 var chooser = document.getElementById("userSwitch");
614 var user = chooser[chooser.selectedIndex].value;
615 window.location = "tt-rss.php?swu=" + user;
616}
6e6504bc 617
7086277c
AD
618function editFeedDlg(feed) {
619
729bafaa
AD
620 disableHotkeys();
621
7086277c
AD
622 if (!feed) {
623 alert("Please select some feed first.");
624 return;
625 }
626
92f3bcae
AD
627 if (feed <= 0 || active_feed_is_cat || tagsAreDisplayed()) {
628 alert("You can't edit this kind of feed.");
629 return;
630 }
631
7086277c
AD
632 if (xmlhttp_ready(xmlhttp)) {
633 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
634 param_escape(feed), true);
635 xmlhttp.onreadystatechange=infobox_callback;
636 xmlhttp.send(null);
637 } else {
638 printLockingError();
639 }
640}
641
642/* this functions duplicate those of prefs.js feed editor, with
643 some differences because there is no feedlist */
644
645function feedEditCancel() {
646 closeInfoBox();
647 return false;
648}
649
650function feedEditSave() {
651
652 try {
653
654 if (!xmlhttp_ready(xmlhttp)) {
655 printLockingError();
656 return
657 }
658
659 // FIXME: add parameter validation
660
661 var query = Form.serialize("edit_feed_form");
662
42c32916 663 notify_progress("Saving feed...");
7086277c
AD
664
665 xmlhttp.open("POST", "backend.php", true);
666 xmlhttp.onreadystatechange=dlg_frefresh_callback;
667 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
668 xmlhttp.send(query);
669
670 closeInfoBox();
671
672 return false;
673
674 } catch (e) {
675 exception_error("feedEditSave (main)", e);
676 }
677}
6e6504bc 678
1dc8dba0
AD
679function localHotkeyHandler(e) {
680
681 var keycode;
682
683 if (window.event) {
684 keycode = window.event.keyCode;
685 } else if (e) {
686 keycode = e.which;
687 }
688
689 var shift_key = false;
690
691 try {
692 shift_key = e.shiftKey;
693 } catch (e) { }
694
695 if (keycode == 66 && shift_key) { // shift-B
696
697 var op = history_pop();
698
699 if (op) {
700 var op_s = op.split(":");
701
702 var i;
703 for (i = 0; i < op_s.length; i++) {
704 if (op_s[i] == 'undefined') {
705 op_s[i] = undefined;
706 }
707
708 if (op_s[i] == 'false') {
709 op_s[i] = false;
710 }
711
712 if (op_s[i] == 'true') {
713 op_s[i] = true;
714 }
715
716 }
717
718 debug("history split: " + op_s);
719
720 if (op_s[0] == "ARTICLE") {
721 debug("history: reverting to article " + op_s[1] + "/" + op_s[2]);
722 view(op_s[1], op_s[2], true);
723 }
724
725 if (op_s[0] == "FEED") {
726 viewfeed(op_s[1], op_s[2], op_s[3], op_s[4], true);
727 }
728
729 } else {
42c32916 730 notify_error("No operation to undo");
1dc8dba0
AD
731 }
732
733 return false;
734
735 }
736
737 debug("LKP=" + keycode);
738}
739
740function history_push(op) {
741 debug("history_push: " + op);
742 op_history.push(op);
743
744 while (op_history.length > 30) {
745 op_history.shift();
746 }
747}
748
749function history_pop() {
750 var op = op_history.pop();
751 debug("history_pop: " + op);
752 return op;
753}
754
755function history_clear() {
756 debug("history_clear");
757 op_history.clear();
758}