2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Event = (function() {
|
2014-01-17 09:56:15 -05:00
|
|
|
|
|
|
|
var queue = [];
|
|
|
|
|
|
|
|
return {
|
|
|
|
ListenMouseEvents: function() {
|
|
|
|
|
|
|
|
document.onclick = function(e) {
|
|
|
|
|
|
|
|
var action = e.target.getAttribute("data-action");
|
|
|
|
|
|
|
|
if (action) {
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
case 'mark_entry_read':
|
|
|
|
e.preventDefault();
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.MarkAsRead(e.target.getAttribute("data-entry-id"));
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 'mark_entry_unread':
|
|
|
|
e.preventDefault();
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.MarkAsUnread(e.target.getAttribute("data-entry-id"));
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
2014-01-17 11:19:43 -05:00
|
|
|
case 'unstar_entry':
|
2014-01-17 09:56:15 -05:00
|
|
|
e.preventDefault();
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.MarkAsUnstarred(e.target.getAttribute("data-entry-id"));
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
2014-01-17 11:19:43 -05:00
|
|
|
case 'star_entry':
|
2014-01-17 09:56:15 -05:00
|
|
|
e.preventDefault();
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.MarkAsStarred(e.target.getAttribute("data-entry-id"));
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
2014-01-17 11:19:43 -05:00
|
|
|
// case 'original-link':
|
2014-05-20 10:25:29 -04:00
|
|
|
// wallabag.Item.OpenOriginal(e.target.getAttribute("data-entry-id"));
|
2014-01-17 11:19:43 -05:00
|
|
|
// break;
|
|
|
|
// case 'mark-all-read':
|
|
|
|
// e.preventDefault();
|
2014-05-20 10:25:29 -04:00
|
|
|
// wallabag.Item.MarkListingAsRead("?action=unread");
|
2014-01-17 11:19:43 -05:00
|
|
|
// break;
|
2014-01-17 09:56:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-05-30 12:12:30 -04:00
|
|
|
},
|
2014-01-17 09:56:15 -05:00
|
|
|
ListenKeyboardEvents: function() {
|
|
|
|
|
|
|
|
document.onkeypress = function(e) {
|
|
|
|
|
|
|
|
queue.push(e.keyCode || e.which);
|
|
|
|
|
|
|
|
if (queue[0] == 103) { // g
|
|
|
|
|
|
|
|
switch (queue[1]) {
|
|
|
|
case undefined:
|
|
|
|
break;
|
|
|
|
case 117: // u
|
2014-05-30 12:12:30 -04:00
|
|
|
window.location.href = "/";
|
2014-01-17 09:56:15 -05:00
|
|
|
queue = [];
|
|
|
|
break;
|
|
|
|
case 98: // b
|
2014-05-30 12:12:30 -04:00
|
|
|
window.location.href = "/bookmarks";
|
2014-01-17 09:56:15 -05:00
|
|
|
queue = [];
|
|
|
|
break;
|
|
|
|
case 104: // h
|
2014-05-30 12:12:30 -04:00
|
|
|
window.location.href = "/archive";
|
2014-01-17 09:56:15 -05:00
|
|
|
queue = [];
|
|
|
|
break;
|
|
|
|
case 115: // s
|
2014-05-30 12:12:30 -04:00
|
|
|
window.location.href = "/add";
|
2014-01-17 09:56:15 -05:00
|
|
|
queue = [];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
queue = [];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
queue = [];
|
|
|
|
|
|
|
|
switch (e.keyCode || e.which) {
|
|
|
|
case 100: // d
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.DownloadContent(wallabag.Nav.GetCurrentItemId());
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 112: // p
|
|
|
|
case 107: // k
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Nav.SelectPreviousItem();
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 110: // n
|
|
|
|
case 106: // j
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Nav.SelectNextItem();
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 118: // v
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.OpenOriginal(wallabag.Nav.GetCurrentItemId());
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 111: // o
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.Show(wallabag.Nav.GetCurrentItemId());
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 109: // m
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.SwitchStatus(wallabag.Nav.GetCurrentItem());
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 102: // f
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Item.SwitchBookmark(wallabag.Nav.GetCurrentItem());
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 104: // h
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Nav.OpenPreviousPage();
|
2014-01-17 09:56:15 -05:00
|
|
|
break
|
|
|
|
case 108: // l
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Nav.OpenNextPage();
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
case 63: // ?
|
2014-05-20 10:25:29 -04:00
|
|
|
wallabag.Nav.ShowHelp();
|
2014-01-17 09:56:15 -05:00
|
|
|
break;
|
|
|
|
}
|
2014-05-30 12:12:30 -04:00
|
|
|
|
2014-01-17 09:56:15 -05:00
|
|
|
}
|
|
|
|
}
|
2014-05-30 12:12:30 -04:00
|
|
|
}
|
2014-01-17 09:56:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|