diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-03-31 10:59:20 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-31 10:59:20 +1100 |
| commit | fef9a3ca82144348924852f68aee35ff4bf6ca25 (patch) | |
| tree | 2eb7dd277177fcbd572884d15ed3ce100aa61c7c /js/forced-anon.js | |
| parent | 52443d3da98e992953d8214b7848350f70d02336 (diff) | |
| parent | 2df1ebd88c266d984cbaa6c26917c2ea89c2ae0e (diff) | |
Merge branch 'master' of github.com:savetheinternet/Tinyboard-Tools into tools
Conflicts:
README.md
Diffstat (limited to 'js/forced-anon.js')
| -rw-r--r-- | js/forced-anon.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/js/forced-anon.js b/js/forced-anon.js new file mode 100644 index 00000000..9b9df1eb --- /dev/null +++ b/js/forced-anon.js @@ -0,0 +1,85 @@ +/* + * forced-anon.js + * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/forced-anon.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/forced-anon.js'; + * + */ + +$(document).ready(function() { + var force_anon = function() { + 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) + var p = $(this).children('a.email'); + else + var p = $(this); + + 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) + p.children('span.trip').text(''); + } + }; + + var enable_fa = function() { + $('p.intro label').each(force_anon); + }; + + var disable_fa = function() { + $('p.intro label').each(function() { + 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) + 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) + p.children('span.trip').text(old_info[id]['trip']); + } + } + }); + }; + + old_info = {}; + forced_anon = localStorage['forcedanon'] ? true : false; + + $('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') + ')'); + + $('div#forced-anon a').click(function() { + forced_anon = !forced_anon; + + if(forced_anon) { + $('div#forced-anon a').text('Forced anonymity (enabled)'); + localStorage.forcedanon = true; + enable_fa(); + } else { + $('div#forced-anon a').text('Forced anonymity (disabled)'); + delete localStorage.forcedanon; + disable_fa(); + } + + return false; + }); + + if(forced_anon) + enable_fa(); + + $(document).bind('new_post', function(e, post) { + if(forced_anon) + $(post).find('p.intro label').each(force_anon); + }); +}); + |
