Skip to content

Instantly share code, notes, and snippets.

@0xLeon
Created April 17, 2016 16:34
Show Gist options
  • Save 0xLeon/d517ff546301efd75937dd446962f4a7 to your computer and use it in GitHub Desktop.
Save 0xLeon/d517ff546301efd75937dd446962f4a7 to your computer and use it in GitHub Desktop.
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