forked from leftypol/leftypol
Allow users to disable and clear (You)s
Credit to based anon https://leftypol.org/tech/res/6724.html#12776
This commit is contained in:
parent
19bbde2639
commit
c9ef4e80ac
|
@ -17,6 +17,28 @@
|
|||
|
||||
+function(){
|
||||
|
||||
if (typeof localStorage.own_posts_tracking === 'undefined') {
|
||||
localStorage.own_posts_tracking = 'true'; // set default
|
||||
}
|
||||
|
||||
const addgui = function () {
|
||||
if (!(window.Options && Options.get_tab ('general'))) { return; }
|
||||
const prefix = "showownposts_";
|
||||
const gui = '<fieldset><legend>(You)s</legend>'
|
||||
+ '<label><input type="checkbox" id="' + prefix + 'track">' + _('Track future (You)s') + '</label>'
|
||||
+ ' <button id="' + prefix + 'clear" title="' + _('Reload the page to see the effect') + '">' + _('Clear all (You)s') + '</button>'
|
||||
+ '</fieldset>';
|
||||
Options.extend_tab ("general", gui);
|
||||
const cb = Options.get_tab ('general').content.find ('#' + prefix + 'track');
|
||||
cb.prop ('checked', localStorage.own_posts_tracking === 'true');
|
||||
cb.on ("change", function (ev) {
|
||||
const cb = ev.target;
|
||||
localStorage.own_posts_tracking = cb.checked ? 'true' : 'false';
|
||||
});
|
||||
Options.get_tab ('general').content.find ('#' + prefix + 'clear').on ("click", function () {
|
||||
localStorage.own_posts = '{}';
|
||||
});
|
||||
}
|
||||
|
||||
var update_own = function() {
|
||||
if ($(this).is('.you')) return;
|
||||
|
@ -61,9 +83,11 @@ $(function() {
|
|||
board = $('input[name="board"]').first().val();
|
||||
|
||||
update_all();
|
||||
addgui();
|
||||
});
|
||||
|
||||
$(document).on('ajax_after_post', function(e, r) {
|
||||
if (localStorage.own_posts_tracking !== 'true') { return; }
|
||||
var posts = JSON.parse(localStorage.own_posts || '{}');
|
||||
posts[board] = posts[board] || [];
|
||||
posts[board].push(r.id);
|
||||
|
|
Loading…
Reference in New Issue
Block a user