]> git.wh0rd.org Git - tt-rss.git/commitdiff
add shortcut to open active article in new tab
authorAndrew Dolgov <fox@madoka.spb.ru>
Fri, 20 Jul 2007 06:01:18 +0000 (07:01 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Fri, 20 Jul 2007 06:01:18 +0000 (07:01 +0100)
functions.js
modules/backend-rpc.php
viewfeed.js

index 89e3c26190b63997359666bd12685275a9ce0fbb..6ba37811e4d3b2ad0b37aaf612011767299e52a5 100644 (file)
@@ -64,6 +64,24 @@ function xmlhttp_ready(obj) {
        return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
 }
 
+function open_article_callback() {
+       if (xmlhttp_rpc.readyState == 4) {
+               try {
+
+                       if (xmlhttp_rpc.responseXML) {
+                               var link = xmlhttp_rpc.responseXML.getElementsByTagName("link")[0];
+
+                               if (link) {
+                                       window.open(link.firstChild.nodeValue, "_blank");
+                               }
+                       }
+
+               } catch (e) {
+                       exception_error("open_article_callback", e);
+               }
+       }
+}
+
 function logout_callback() {
        var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {
@@ -303,6 +321,12 @@ function hotkey_handler(e) {
                        }
                }
 
+               if (keycode == 86) { // v
+                       if (getActiveArticleId()) {
+                               openArticleInNewWindow(getActiveArticleId());
+                       }
+               }
+
                if (typeof localHotkeyHandler != 'undefined') {
                        try {
                                return localHotkeyHandler(e);
@@ -1715,3 +1739,26 @@ function getRelativePostIds(id) {
 
        return false;
 }
+
+function openArticleInNewWindow(id) {
+       try {
+
+               if (!xmlhttp_ready(xmlhttp_rpc)) {
+                       printLockingError();
+                       return
+               }
+
+               debug("openArticleInNewWindow: " + id);
+
+               var query = "backend.php?op=rpc&subop=getArticleLink&id=" + id;
+
+               debug(query);
+
+               xmlhttp_rpc.open("GET", query, true);
+               xmlhttp_rpc.onreadystatechange=open_article_callback;
+               xmlhttp_rpc.send(null);
+
+       } catch (e) {
+               exception_error("openArticleInNewWindow", e);
+       }
+}
index e70b75524a2b477cb08d97352aeeb6c4485909e7..868d464451d69991e3e099c4dcbf1806b0f7a77e 100644 (file)
 
                }
 
+               if ($subop == "getArticleLink") {
+
+                       $id = db_escape_string($_GET["id"]);
+
+                       $result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries
+                               WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'");
+
+                       if (db_num_rows($result) == 1) {
+                               $link = strip_tags(db_fetch_result($result, 0, "link"));
+                               print "<rpc-reply><link>$link</link></rpc-reply>";
+                       } else {
+                               print "<rpc-reply><error>Article not found</error></rpc-reply>";
+                       }
+               }
+
                if ($subop == "setArticleTags") {
 
                        $id = db_escape_string($_GET["id"]);
index 1d6a4a62b72a83d2774612972e54a137e8ae6a8f..4fd9db30f8e64654d52e72f920ac0c4065c7f193 100644 (file)
@@ -909,3 +909,7 @@ function cache_invalidate(id) {
                exception_error("cache_invalidate", e);
        }
 }
+
+function getActiveArticleId() {
+       return active_post_id;
+}