Created
April 17, 2016 16:34
-
-
Save 0xLeon/d517ff546301efd75937dd446962f4a7 to your computer and use it in GitHub Desktop.
RainBow Mode module for BCPlus
This file contains hidden or 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