RainBow Mode module for BCPlus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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