-
Notifications
You must be signed in to change notification settings - Fork 106
Open all unread articles shortcut
Since an app that opens a lot of tabs will be very slow and maybe even crash your browser, this kind of keyboard shortcut is not a good idea to include in the main app. For a few power users that know how to deal with the issues however this may be a nice addition.
This app follows the typical structure of a very simple Client Side Plugin.
For a very simple working solution, follow the following steps:
Create a directory in owncloud/apps called newsopenallshortcut. Inside that folder create a folder structure like this:
- appinfo/
- js/
Now create the following three text files inside the newsopenallshortcut folder:
- appinfo/app.php
- appinfo/info.xml:
- js/script.js:
with the following contents:
appinfo/app.php:
<?php
if (class_exists('OCA\News\Plugin\Client\Plugin')) {
\OCA\News\Plugin\Client\Plugin::registerScript('newsopenallshortcut', 'script');
}
appinfo/info.xml:
<?xml version="1.0"?>
<info>
<id>newsopenallshortcut</id>
<name>News Plugin: Open All Unread Articles In a New Tab</name>
<description>Press shift + o to open all loaded unread articles in a new tab</description>
<licence>AGPL</licence>
<author>Your Name Here</author>
<version>0.0.1</version>
<category>other</category>
<dependencies>
<owncloud min-version="9.0"/>
</dependencies>
</info>
js/script.js:
$(document).ready(function () {
var openAllUnread = function (number) {
var unreadItems = $('#app-content').find('.item:not(.read)');
unreadItems.slice(0, number).each(function (index, element) {
var url = $(element)
.find('.external:visible')
.attr('href');
$(element).trigger('click'); // mark read
window.open(url, '_blank');
});
};
var noInputFocused = function (element) {
return !(
element.is('input') ||
element.is('select') ||
element.is('textarea') ||
element.is('checkbox')
);
};
$(document).keyup(function (event) {
// shift + o
if (noInputFocused($(':focus')) && event.shiftKey && [79].indexOf(event.keyCode) >= 0) {
// number of tabs to open
openAllUnread(5);
}
});
});
Change the number in openAllUnread(5); to how many articles you want to open at once, e.g.:
openAllUnread(20);
for 20 articles.
Finally enable the app in your apps menu. The name is the same as the <name> Element in the appinfo/info.xml, in this case: News Plugin: Open All Unread Articles In a New Tab