Initial commit
This commit is contained in:
commit
f88f84bc57
40
init.js
Normal file
40
init.js
Normal file
@ -0,0 +1,40 @@
|
||||
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
|
||||
ready(function () {
|
||||
this.prev_feed = null;
|
||||
PluginHost.register(PluginHost.HOOK_FEED_SET_ACTIVE, (feed) => {
|
||||
if (feed[0] == this.prev_feed)
|
||||
return;
|
||||
|
||||
const toolbar = document.forms["toolbar-main"];
|
||||
const order_by = dijit.getEnclosingWidget(toolbar.order_by);
|
||||
const view_mode = dijit.getEnclosingWidget(toolbar.view_mode);
|
||||
|
||||
prev_prefs = {
|
||||
id:this.prev_feed,
|
||||
order_by: order_by.attr("value"),
|
||||
view_mode: view_mode.attr("value"),
|
||||
};
|
||||
prev_key = "ttrss:feedprefs:"+prev_feed;
|
||||
localStorage.setItem(prev_key, JSON.stringify(prev_prefs));
|
||||
|
||||
this.prev_feed = feed[0];
|
||||
|
||||
key = "ttrss:feedprefs:"+feed[0];
|
||||
data = localStorage.getItem(key);
|
||||
console.log
|
||||
if (data) {
|
||||
prefs = JSON.parse(data);
|
||||
console.log("plugin:feedprefs: "+key+" => "+data);
|
||||
if (prefs.id != feed[0]) {
|
||||
console.log("plugin:feedprefs: bad data - discard entry");
|
||||
localStorage.removeItem(key);
|
||||
return;
|
||||
}
|
||||
if (prefs.order_by)
|
||||
order_by.attr("value", prefs.order_by);
|
||||
if (prefs.view_mode)
|
||||
view_mode.attr("value", prefs.view_mode);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
25
init.php
Normal file
25
init.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class Feedprefs extends Plugin {
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(0.0,
|
||||
"Per feed preferences.",
|
||||
"gilles@grandou.net");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
function get_js() {
|
||||
return file_get_contents(__DIR__ . "/init.js");
|
||||
}
|
||||
|
||||
function api_version() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user