thelounge/client/js/libs/handlebars/colorClass.js

10 lines
236 B
JavaScript
Raw Normal View History

2016-12-18 16:53:28 +01:00
// 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);
}
2016-12-18 16:53:28 +01:00
return "color-" + (1 + hash % 32);
};