Files
Paradise/goon/browserassets/html/adminOutput.html
Tigercat2000 c0d3855d53 Goonchat Admin Filters
This adds Message filters to Goonchat (only for mentors +
administrators).

There is a new option in the settings dropdown of Goonchat to access
these. They are temporary, non-destructive filters which will hide all
messages matching them that are already in your chat, as well as any new
messages matching them.

There are 5 filters currently:
 - Admin; Filters out most admin logs.
 - Combat; Filters out a limited subset of combat messages-
 Specifically, any message with the 'combat' span class. Currently, this
 has only been added to the central /attack and /attacked_by procs, so a
 large considerable amount of hostile actions taken against a
 player are still not going to be filtered out. We can work on adding
 the identifier to more stuff later.
 - Radios: Filters out all radio messages.
 - Speech: Filters out all mob speech.
 - OOC: Filters out OOC chat.

There is also an "All" option, which just turns off all messages that
are not internal to Goonchat.
2017-02-06 12:19:33 -08:00

104 lines
3.9 KiB
HTML

<script type="text/javascript">
opts.showMessagesFilters = { /* Contains the current filters. "show: false" filters it out. "match" is all the css classes to filter on. */
'All': {show: true},
'Admin': {show: true, match: ['admin']},
'Combat': {show: true, match: ['combat']},
'Radios': {show: true, match: ['radio']},
'Speech': {show: true, match: ['say']},
'OOC': {show: true, match: ['ooc']},
};
opts.filterHideAll = false;
$subOptions.append('<a href="#" class="filterMessagesOpt" id="filterMessagesOpt"><span>Filter Messages</span> <i class="icon-filter"></i></a>');
function toggleFilter(type) {
if (type == 'All') {
if (opts.showMessagesFilters['All'].show === true) {
$.each(opts.showMessagesFilters, function (key) {
opts.showMessagesFilters[key].show = false;
if (key != 'All') {
$('#filter_'+key).prop('checked', false);
}
});
$('#messages .entry *:nth-child(1):not(.internal)').parent('.entry').addClass('hidden').attr('data-filter', 'All');
opts.filterHideAll = true;
internalOutput('<span class="internal boldnshit">Hiding <strong>ALL</strong> messages. Uhhh are you sure about this?</span>');
} else {
$.each(opts.showMessagesFilters, function (key) {
opts.showMessagesFilters[key].show = true;
if (key != 'All') {
$('#filter_'+key).prop('checked', true);
}
});
$('#messages .entry.hidden[data-filter]').removeClass('hidden');
opts.filterHideAll = false;
internalOutput('<span class="internal boldnshit">Showing <strong>ALL</strong> messages</span>');
}
} else {
var onoff = !opts.showMessagesFilters[type].show;
opts.showMessagesFilters[type].show = onoff;
var allTrue = true;
var allFalse = true;
$.each(opts.showMessagesFilters, function (key, val) {
if (key != 'All') {
if (allTrue) {
allTrue = (val.show ? true : false);
}
if (allFalse) {
allFalse = (val.show ? false : true);
}
}
});
opts.showMessagesFilters['All'].show = (allTrue ? true : false);
$('#filter_All').prop('checked', (allTrue ? true : false));
if (allTrue) {
opts.filterHideAll = false;
$('#messages .entry.hidden[data-filter]').removeClass('hidden');
} else if (allFalse) {
opts.filterHideAll = true;
$('#messages .entry *:nth-child(1):not(.internal)').each(function (i, el) {
$(el).parent('.entry').addClass('hidden').attr('data-filter', 'All');
});
} else if (typeof opts.showMessagesFilters[type].match != 'undefined') { /* If the filter has classes to match against */
/* Hide/Show all prior messages */
for (var i = 0; i < opts.showMessagesFilters[type].match.length; i++) {
var thisClass = opts.showMessagesFilters[type].match[i];
if (onoff) { /* Showing */
$('#messages .entry.hidden[data-filter="'+type+'"]').removeClass('hidden');
} else { /* Hiding */
$('#messages .'+thisClass).each(function (i, el) {
$(el).closest('.entry').addClass('hidden').attr('data-filter', type);
});
}
}
}
var msg = (onoff ? 'Showing' : 'Filtering <strong>OUT</strong>') + " messages of type <strong>"+type+"</strong>";
internalOutput('<span class="internal boldnshit">'+msg+'</span>');
}
console.log('filters is: ', opts.showMessagesFilters);
}
$subOptions.on('click', '#filterMessagesOpt', function (e) {
if ($('#filterMessages').is(':visible'))
return;
var content = '<div class="head">Filter Messsages</div>' +
'<div id="filterMessages" class="filterMessages">';
$.each(opts.showMessagesFilters, function (key, val) {
content += '<div><input type="checkbox" id="filter_'+key+'" name="'+key+'" value="'+key+'" '+(val.show ? 'checked="checked" ' : '')+'/> <label for="filter_'+key+'">'+key+'</label></div>';
});
content += '</div>';
createPopup(content, 150);
});
$('body').on('click', '#filterMessages input', function () {
var type = $(this).val();
console.log('hit change event with type: '+type);
toggleFilter(type);
$('body,html').scrollTop($messages.outerHeight());
});
</script>