Skip to content

Instantly share code, notes, and snippets.

@0xLeon
Created April 17, 2016 16:34
Embed
What would you like to do?
RainBow Mode module for BCPlus
Modules.RainbowMode = (function() {
var bcplus = null;
var initialize = function(_bcplus) {
bcplus = _bcplus;
buildUI();
addEventListeners();
};
var buildUI = function() {
bcplus.addBoolOption('RainbowModeActive', 'Regenbogen-Modus', 'UIOptimize', 'User Interface', false);
};
var addEventListeners = function() {
bcplus.addEventListener('messageSubmit', function() {
bcplus.sendMessage('/color ' + getRandomColor() + ' ' + getRandomColor(), false);
});
bcplus.addEventListener('messageAdded', function(messageNodeEvent) {
if ((messageNodeEvent.messageType === bcplus.messageType.INFO) && messageNodeEvent.messageText.startsWith('Die Farbe')) {
messageNodeEvent.messageNode.addClass('invisible');
}
});
};
var getRandomColor = function() {
return '#' +
('00' + Math.floor(Math.random() * 256).toString(16)).slice(-2) +
('00' + Math.floor(Math.random() * 256).toString(16)).slice(-2) +
('00' + Math.floor(Math.random() * 256).toString(16)).slice(-2);
};
return {
initialize: initialize
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment