35 lines
1010 B
JavaScript
35 lines
1010 B
JavaScript
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 = {
|
|
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.order_by)
|
|
order_by.attr("value", prefs.order_by);
|
|
if (prefs.view_mode)
|
|
view_mode.attr("value", prefs.view_mode);
|
|
}
|
|
});
|
|
});
|
|
});
|