MediaWiki:ChatBinaryButton.js

// ChatBinaryButton - Count of Howard // Using code by Penguin-Pal and OneTwoThreeFall // 6-11-16 - Initial revision

$(function {    if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {        mw.util.addCSS( '.Write [name="message"] {' + 'width: calc(100% - 70px);' + '}' +           '#ChatBinaryButton {' + 'position: absolute;' + 'bottom: 25px;' + 'right: 50px;' + '}' +           'input + #ChatBinaryButton:last-child {' + 'bottom: 12px;' + 'right: 12px;' + '}'       );

var binaryValue; var binaryButton = $(' Binary! ');

function binary { var a = $('#Write textarea').val; var b = ""; var c;           for (var i = 0; i <a.length; i++) { c = a.charCodeAt(i).toString(2); if (c.length < 8) { c = new Array(9 - c.length).join("0") + c;               } b += c;           } binaryValue = b;       }

binaryButton.click(function {            binary;            mainRoom.socket.send(new models.ChatEntry({roomId:this.roomId,name:wgUserName,text:binaryValue}).xport);            $('#Write textarea').val('')        });

$('.Write').append(binaryButton); } });