mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-14 05:15:56 +00:00
add shortcut to open active article in new tab
This commit is contained in:
47
functions.js
47
functions.js
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user