User:Shining-Armor/chat.js

(function {   function z(a, b) {        var d = x        if (b === 1) {            if (d.indexOf(a) === -1) {                d.push(a)                y(d)            }        } else if (b === 2) {            if (d.indexOf(a) > -1) {                d.pop(d.indexOf(a))                y(d)            }        }    }

function y(a) { localStorage.setItem('mute', JSON.stringify(a)) }

function x { return JSON.parse(localStorage.getItem('mute') !== null ? localStorage.getItem('mute') : '[]') }

$('textarea[name=message]').keypress(function(e) {       if (e.which == 13) {            var a = $(this).val,                b = a.substr(1, a.length),                c = b.split(' ');            if (a[0] === '/') {                e.preventDefault                $(this).val('')                if (c[0] === 'mute') {                    z(c[1], 1)                } else if (c[0] === 'unmute') {                    z(c[1], 2)                }            }        }    })

window.mainRoom.model.chats.bind('afteradd', function {       var a = x,            i = 0;        for (i; i < a.length; i++) {            $('li[data-user=' + a[i] + ']').remove;        }    }) });