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
1 changed files with 24 additions and 0 deletions
|
@ -17,6 +17,28 @@
|
||||||
|
|
||||||
+function(){
|
+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() {
|
var update_own = function() {
|
||||||
if ($(this).is('.you')) return;
|
if ($(this).is('.you')) return;
|
||||||
|
@ -61,9 +83,11 @@ $(function() {
|
||||||
board = $('input[name="board"]').first().val();
|
board = $('input[name="board"]').first().val();
|
||||||
|
|
||||||
update_all();
|
update_all();
|
||||||
|
addgui();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('ajax_after_post', function(e, r) {
|
$(document).on('ajax_after_post', function(e, r) {
|
||||||
|
if (localStorage.own_posts_tracking !== 'true') { return; }
|
||||||
var posts = JSON.parse(localStorage.own_posts || '{}');
|
var posts = JSON.parse(localStorage.own_posts || '{}');
|
||||||
posts[board] = posts[board] || [];
|
posts[board] = posts[board] || [];
|
||||||
posts[board].push(r.id);
|
posts[board].push(r.id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue