mirror of
https://github.com/goonstation/goonstation-2016.git
synced 2026-07-14 10:32:20 +01:00
180 lines
6.3 KiB
HTML
180 lines
6.3 KiB
HTML
<div id="contextMenu" class="contextMenu" style="display: none;">
|
|
<a href="#" id="ctx_pm">Admin PM</a>
|
|
<a href="#" id="ctx_smsg">Subtle Msg</a>
|
|
<a href="#" id="ctx_jump">Jump To</a>
|
|
<a href="#" id="ctx_get">Get</a>
|
|
<a href="#" id="ctx_boot">Boot</a>
|
|
<a href="#" id="ctx_ban">Ban</a>
|
|
<a href="#" id="ctx_gib">Gib</a>
|
|
<a href="#" id="ctx_popt">Player Options</a>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
/* DO NOT USE LINE COMMENTS (//) IN THIS FILE FOR THE LOVE OF GOD */
|
|
|
|
opts.menuTypes = { /* Action flags for context menu */
|
|
1: 'pm',
|
|
2: 'smsg',
|
|
4: 'boot',
|
|
8: 'ban',
|
|
16: 'gib',
|
|
32: 'popt',
|
|
64: 'jump',
|
|
128:'get',
|
|
};
|
|
opts.contextMenuTarget = null; /* Contains the player mind ref */
|
|
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']},
|
|
'Misc': {show: true},
|
|
};
|
|
opts.filterHideAll = false;
|
|
|
|
$contextMenu = $('#contextMenu');
|
|
$subOptions.append('<a href="#" class="filterMessagesOpt" id="filterMessagesOpt"><span>Filter Messages</span> <i class="icon-filter"></i></a>');
|
|
|
|
function openContextMenu(flags, target, x, y) {
|
|
for (var i in opts.menuTypes) {
|
|
$('#ctx_' + opts.menuTypes[i])[(flags & i) === 0 ? 'hide' : 'show']();
|
|
}
|
|
|
|
$contextMenu.hide(0, function() {
|
|
if (($contextMenu.height() + y) > ($(window).height() - 16)) {
|
|
y -= $contextMenu.height() + 4;
|
|
}
|
|
$contextMenu.css({top: y + 2, left: x + 2});
|
|
$contextMenu.slideDown(200);
|
|
});
|
|
|
|
opts.contextMenuTarget = target;
|
|
}
|
|
|
|
function hideContextMenu() {
|
|
$contextMenu.slideUp(200);
|
|
opts.contextMenuTarget = null;
|
|
}
|
|
|
|
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;
|
|
output('<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;
|
|
output('<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);
|
|
});
|
|
}
|
|
}
|
|
} else if (type == 'Misc') {
|
|
if (onoff) {
|
|
$('#messages .entry.hidden[data-filter="Misc"]').removeClass('hidden');
|
|
} else {
|
|
$('#messages .entry *:nth-child(1):not([class]), #messages .entry:not(:has(>*))').each(function(i, el) {
|
|
$(el).parent('.entry').addClass('hidden').attr('data-filter', 'Misc');
|
|
});
|
|
}
|
|
}
|
|
|
|
var msg = (onoff ? 'Showing' : 'Filtering <strong>OUT</strong>') + ' messages of type <strong>'+type+'</strong>';
|
|
output('<span class="internal boldnshit">'+msg+'</span>');
|
|
}
|
|
console.log('filters is: ', opts.showMessagesFilters);
|
|
}
|
|
|
|
$contextMenu.on('mousedown', function(e) {
|
|
e.preventDefault();
|
|
var target = $(e.target);
|
|
var id = target.attr('id');
|
|
if (!id) {
|
|
output('<span class="internal boldnshit">Failed to retrieve context menu command data. Report this bug.</span>');
|
|
} else {
|
|
var command = target.attr('id').substring(4);
|
|
runByond('byond://?action=ehjax&type=datum&datum=chatOutput&proc=handleContextMenu¶m[command]=' + command + '¶m[target]=' + opts.contextMenuTarget);
|
|
}
|
|
});
|
|
|
|
$messages.on('contextmenu', '.adminHearing .name', function(e) {
|
|
var $this = $(this);
|
|
var mind = $this.attr('data-ctx');
|
|
var flags = $this.closest('.adminHearing').attr('data-ctx');
|
|
if (mind && flags) {
|
|
openContextMenu(flags, mind, e.clientX, e.clientY);
|
|
return false;
|
|
}
|
|
else {
|
|
if (!mind && !flags) {
|
|
output('<span class="internal boldnshit">Failed to retrieve context menu option data. Report this bug.</span>');
|
|
}
|
|
}
|
|
});
|
|
|
|
$subOptions.on('click', '#filterMessagesOpt', function(e) {
|
|
if ($('#filterMessages').is(':visible')) {return;}
|
|
var content = '<div class="head">Filter Messages</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> |