mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 08:23:12 +09:00
Housekeeping
This commit is contained in:
1 parent
2fc7de3983
commit
e3b8926e35
1 file changed
+12
-12
+12
-12
@@ -28,23 +28,23 @@ contents = {
|
|||||||
// nice functions
|
// nice functions
|
||||||
// hash a string to a hash
|
// hash a string to a hash
|
||||||
function djb2(str){
|
function djb2(str){
|
||||||
var hash = 5381;
|
var hash = 5381;
|
||||||
for (var i = 0; i < str.length; i++) {
|
for (var i = 0; i < str.length; i++) {
|
||||||
hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */
|
hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
// hash a string to a color
|
// hash a string to a color
|
||||||
function hashColor(str) {
|
function hashColor(str) {
|
||||||
var hash = djb2(str);
|
var hash = djb2(str);
|
||||||
var r = (hash & 0xFF0000) >> 16;
|
var r = (hash & 0xFF0000) >> 16;
|
||||||
var g = (hash & 0x00FF00) >> 8;
|
var g = (hash & 0x00FF00) >> 8;
|
||||||
var b = hash & 0x0000FF;
|
var b = hash & 0x0000FF;
|
||||||
return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2);
|
return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2);
|
||||||
}
|
}
|
||||||
// exactly what you would expect it to, returns String
|
// exactly what you would expect it to, returns String
|
||||||
function capitalizeFirstLetter(string) {
|
function capitalizeFirstLetter(string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide the HTML object passed as argument #1
|
// hide the HTML object passed as argument #1
|
||||||
@@ -62,7 +62,7 @@ Date.prototype.yyyymmdd = function(time) { // http://stackoverflow.com/questions
|
|||||||
};
|
};
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
function replaceAll(target, search, replacement) {
|
function replaceAll(target, search, replacement) {
|
||||||
return target.split(search).join(replacement);
|
return target.split(search).join(replacement);
|
||||||
};
|
};
|
||||||
|
|
||||||
function getImageFromName(name){
|
function getImageFromName(name){
|
||||||
|
|||||||
Reference in new issue
Block a user