mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
Added option for hiding IDs.
This commit is contained in:
parent
33ef3f9b01
commit
d069a4c9fd
@ -18,10 +18,10 @@
|
||||
if (active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || (window.Options && Options.get_tab('general')))
|
||||
$(document).ready(function() {
|
||||
var force_anon = function() {
|
||||
if($(this).children('a.capcode').length == 0) {
|
||||
if ($(this).children('a.capcode').length == 0) {
|
||||
var id = $(this).parent().children('a.post_no:eq(1)').text();
|
||||
|
||||
if($(this).children('a.email').length != 0)
|
||||
if ($(this).children('a.email').length != 0)
|
||||
var p = $(this).children('a.email');
|
||||
else
|
||||
var p = $(this);
|
||||
@ -29,7 +29,7 @@ $(document).ready(function() {
|
||||
old_info[id] = {'name': p.children('span.name').text(), 'trip': p.children('span.trip').text()};
|
||||
|
||||
p.children('span.name').text('Anonymous');
|
||||
if(p.children('span.trip').length != 0)
|
||||
if (p.children('span.trip').length != 0)
|
||||
p.children('span.trip').text('');
|
||||
}
|
||||
};
|
||||
@ -40,44 +40,60 @@ $(document).ready(function() {
|
||||
|
||||
var disable_fa = function() {
|
||||
$('p.intro label').each(function() {
|
||||
if($(this).children('a.capcode').length == 0) {
|
||||
if ($(this).children('a.capcode').length == 0) {
|
||||
var id = $(this).parent().children('a.post_no:eq(1)').text();
|
||||
|
||||
if(old_info[id]) {
|
||||
if($(this).children('a.email').length != 0)
|
||||
if ($(this).children('a.email').length != 0)
|
||||
var p = $(this).children('a.email');
|
||||
else
|
||||
var p = $(this);
|
||||
|
||||
p.children('span.name').text(old_info[id]['name']);
|
||||
if(p.children('span.trip').length != 0)
|
||||
if (p.children('span.trip').length != 0)
|
||||
p.children('span.trip').text(old_info[id]['trip']);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var toggle_id = function() {
|
||||
if (localStorage.hideids == 'true'){
|
||||
$(this).addClass('hidden');
|
||||
} else {
|
||||
$(this).removeClass('hidden');
|
||||
}
|
||||
};
|
||||
|
||||
old_info = {};
|
||||
forced_anon = localStorage['forcedanon'] ? true : false;
|
||||
|
||||
var selector, event;
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
selector = '#forced-anon';
|
||||
event = 'change';
|
||||
Options.extend_tab("general", "<label id='forced-anon'><input type='checkbox' />"+_('Forced anonymity')+"</label>");
|
||||
}
|
||||
else {
|
||||
selector = '#forced-anon';
|
||||
event = 'click';
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
var s1 = '#hide-ids', s2 = '#forced-anon', e = 'change';
|
||||
Options.extend_tab("general", "<label id='hide-ids'><input type='checkbox' /> "+_('Hide IDs')+"</label>");
|
||||
Options.extend_tab("general", "<label id='forced-anon'><input type='checkbox' /> "+_('Forced anonymity')+"</label>");
|
||||
}
|
||||
else {
|
||||
var s1 = '#hide-ids', s2 = '#forced-anon', e = 'click';
|
||||
$('hr:first').before('<div id="hide-ids" style="text-align:right"><a class="unimportant" href="javascript:void(0)">Hide IDs</a></div>');
|
||||
$('hr:first').before('<div id="forced-anon" style="text-align:right"><a class="unimportant" href="javascript:void(0)">-</a></div>');
|
||||
$('div#forced-anon a').text(_('Forced anonymity')+' (' + (forced_anon ? _('enabled') : _('disabled')) + ')');
|
||||
}
|
||||
}
|
||||
|
||||
$(s1).on(e, function(e) {
|
||||
if (!localStorage.hideids || localStorage.hideids == 'false') {
|
||||
localStorage.hideids = 'true';
|
||||
if (window.Options && Options.get_tab('general')) e.target.checked = true;
|
||||
} else {
|
||||
localStorage.hideids = 'false';
|
||||
if (window.Options && Options.get_tab('general')) e.target.checked = false;
|
||||
}
|
||||
$('.poster_id').each(toggle_id);
|
||||
});
|
||||
|
||||
$(selector).on(event, function() {
|
||||
$(s2).on(e, function() {
|
||||
forced_anon = !forced_anon;
|
||||
|
||||
if(forced_anon) {
|
||||
if (forced_anon) {
|
||||
$('div#forced-anon a').text(_('Forced anonymity')+' ('+_('enabled')+')');
|
||||
localStorage.forcedanon = true;
|
||||
enable_fa();
|
||||
@ -86,21 +102,27 @@ $(document).ready(function() {
|
||||
delete localStorage.forcedanon;
|
||||
disable_fa();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// initial option setup on script load
|
||||
if (localStorage.hideids == 'true'){
|
||||
if (window.Options && Options.get_tab('general')) $('#hide-ids>input').prop('checked',true);
|
||||
$('.poster_id').each(toggle_id);
|
||||
}
|
||||
|
||||
if(forced_anon) {
|
||||
enable_fa();
|
||||
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
$('#toggle-locked-threads>input').prop('checked', true);
|
||||
}
|
||||
if (window.Options && Options.get_tab('general')) {
|
||||
$('#toggle-locked-threads>input').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('new_post', function(e, post) {
|
||||
if(forced_anon)
|
||||
if (forced_anon)
|
||||
$(post).find('p.intro label').each(force_anon);
|
||||
if (localStorage.hideids == 'true')
|
||||
$(post).find('.poster_id').each(toggle_id);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -8,6 +8,10 @@ body {
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display:none;
|
||||
}
|
||||
|
||||
a,a:visited {
|
||||
text-decoration: underline;
|
||||
color: #34345C;
|
||||
@ -905,6 +909,10 @@ pre {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.poster_id::before {
|
||||
content: " ID: ";
|
||||
}
|
||||
|
||||
pre {
|
||||
/* Better code tags */
|
||||
max-width:inherit;
|
||||
|
@ -1,7 +1,7 @@
|
||||
{% if config.poster_ids %}
|
||||
{% if post.thread %}
|
||||
ID: <span class="poster_id">{{ post.ip|poster_id(post.thread) }}</span>
|
||||
<span class="poster_id">{{ post.ip|poster_id(post.thread) }}</span>
|
||||
{% else %}
|
||||
ID: <span class="poster_id">{{ post.ip|poster_id(post.id) }}</span>
|
||||
<span class="poster_id">{{ post.ip|poster_id(post.id) }}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user