1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00

Initial commit for modular FrankerFaceZ rewrite.

This commit is contained in:
SirStendec 2015-01-12 17:58:07 -05:00
parent b74fdaa22b
commit f1377bc989
27 changed files with 2717 additions and 1034 deletions

30
src/utils.js Normal file
View file

@ -0,0 +1,30 @@
var FFZ = window.FrankerFaceZ,
constants = require('./constants');
module.exports = {
update_css: function(element, id, css) {
var all = element.innerHTML,
start = "/*BEGIN " + id + "*/",
end = "/*END " + id + "*/",
s_ind = all.indexOf(start),
e_ind = all.indexOf(end),
found = s_ind !== -1 && e_ind !== -1 && e_ind > s_ind;
if ( !found && !css )
return;
if ( found )
all = all.substr(0, s_ind) + all.substr(e_ind + end.length);
if ( css )
all += start + css + end;
element.innerHTML = all;
},
number_commas: function(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
}