thelounge/client/js/libs/handlebars/colorClass.js
Pavel Djundik fb87bd3a58 Webpack
2016-12-27 19:15:30 +02:00

10 lines
236 B
JavaScript

// Generates a string from "color-1" to "color-32" based on an input string
module.exports = function(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash += str.charCodeAt(i);
}
return "color-" + (1 + hash % 32);
};