]> git.wh0rd.org Git - tt-rss.git/commitdiff
add experimental operation history stack
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 4 Dec 2006 08:26:09 +0000 (09:26 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 4 Dec 2006 08:26:09 +0000 (09:26 +0100)
feedlist.js
functions.js
tt-rss.js
viewfeed.js

index 53fc4c6e4d9e61f750903d9bc07dae7b81c73e2e..d324c6a80cccafd4599f0a80e820edda71a78dcd 100644 (file)
@@ -14,11 +14,16 @@ function feedlist_callback() {
        }
 }
 
-function viewfeed(feed, subop, is_cat, subop_param) {
+function viewfeed(feed, subop, is_cat, subop_param, skip_history) {
        try {
 
                enableHotkeys();
 
+               if (!skip_history) {
+                       history_push('FEED:' + feed + ':' + subop + ':' + is_cat +
+                               ':' + subop_param);
+               }
+
                var toolbar_query = Form.serialize("main_toolbar_form");
                var toolbar_form = document.forms["main_toolbar_form"];
 
index 4b610816d8ff97efb774697e2c1bb6474e6bba3a..6512d6adc34f91c3bee99ba88da49eef348a393f 100644 (file)
@@ -226,14 +226,6 @@ function hotkey_handler(e) {
                        }
                }
                
-               if (typeof localHotkeyHandler != 'undefined') {
-                       try {
-                               localHotkeyHandler(keycode);
-                       } catch (e) {
-                               exception_error("hotkey_handler, local:", e);
-                       }
-               }
-
                if (keycode == 68 && shift_key) { // d
                        if (!debug_mode_enabled) {
                                document.getElementById('debug_output').style.display = 'block';
@@ -245,6 +237,14 @@ function hotkey_handler(e) {
                        debug_mode_enabled = !debug_mode_enabled;
                }
 
+               if (typeof localHotkeyHandler != 'undefined') {
+                       try {
+                               return localHotkeyHandler(e);
+                       } catch (e) {
+                               exception_error("hotkey_handler, local:", e);
+                       }
+               }
+
                debug("KP=" + keycode);
        } catch (e) {
                exception_error("hotkey_handler", e);
index 472c90a6b0fad1c8779b013363decf2b5f479774..8630205055cf8347df4f382f5082be11ea052e59 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -20,6 +20,8 @@ var xmlhttp_ctr = Ajax.getTransport();
 
 var init_params = new Object();
 
+var op_history = new Array();
+
 function toggleTags() {
        display_tags = !display_tags;
 
@@ -654,3 +656,83 @@ function feedEditSave() {
        } 
 }
 
+function localHotkeyHandler(e) {
+
+       var keycode;
+
+       if (window.event) {
+               keycode = window.event.keyCode;
+       } else if (e) {
+               keycode = e.which;
+       }
+
+       var shift_key = false;
+
+       try {
+               shift_key = e.shiftKey;
+       } catch (e) { }
+
+       if (keycode == 66 && shift_key) { // shift-B
+
+               var op = history_pop();
+
+               if (op) {
+                       var op_s = op.split(":");
+
+                       var i;
+                       for (i = 0; i < op_s.length; i++) {
+                               if (op_s[i] == 'undefined') {
+                                       op_s[i] = undefined;
+                               }
+
+                               if (op_s[i] == 'false') {
+                                       op_s[i] = false;
+                               }
+
+                               if (op_s[i] == 'true') {
+                                       op_s[i] = true;
+                               }
+                               
+                       }
+
+                       debug("history split: " + op_s);
+
+                       if (op_s[0] == "ARTICLE") {
+                               debug("history: reverting to article " + op_s[1] + "/" + op_s[2]);
+                               view(op_s[1], op_s[2], true);
+                       }
+
+                       if (op_s[0] == "FEED") {
+                               viewfeed(op_s[1], op_s[2], op_s[3], op_s[4], true);
+                       }
+
+               } else {
+                       notify("No operation to undo");
+               }
+
+               return false;
+
+       }       
+
+       debug("LKP=" + keycode);
+}
+
+function history_push(op) {
+       debug("history_push: " + op);
+       op_history.push(op);
+
+       while (op_history.length > 30) {
+               op_history.shift();
+       }
+}
+
+function history_pop() {
+       var op = op_history.pop();
+       debug("history_pop: " + op);
+       return op;
+}
+
+function history_clear() {
+       debug("history_clear");
+       op_history.clear();
+}
index 7a499fd3b09b9d16ed5c41a56cd3dc889224945c..155fdd84134824236db9b08de288da75eac33f52 100644 (file)
@@ -51,10 +51,14 @@ function article_callback() {
        }
 }
 
-function view(id, feed_id) {
+function view(id, feed_id, skip_history) {
        
        try {
                debug("loading article: " + id + "/" + feed_id);
+
+               if (!skip_history) {
+                       history_push("ARTICLE:" + id + ":" + feed_id);
+               }
        
                enableHotkeys();