Dashboard
PHP:
8.0.30
OS:
Linux
User:
fouamico
/
/
home4
/
fouamico
/
public_html
/
mitsucap
/
sr-calculator
/
js
đ€ Upload
đ New File
đ New Folder
Close
Editing: Variable.js
class Variable { constructor(id, name, format) { this.id = id; this.name = name; this.format = format; Variable.list[id] = this; } getValue() { return this.value; } formated(val) { if (val == undefined) val = this.value; switch (this.format) { case '$': return (val < 0 ? '-' : '') + '$' + Math.abs(val).formatMoney(0, '.', ','); break; case '#': return val; break; case '%': return Math.round(val * 100) / 100 + '%'; break; } } } Variable.list = {}; Variable.get = function(id) { if (Variable.list[id] == undefined) console.error(id + ' we dont have such variable'); return Variable.list[id].getValue(); }; function V(id, recountArgument = false) { if (recountArgument) return Variable.list[id].count(false, recountArgument); else return Variable.get(id) } Number.prototype.formatMoney = function(c, d, t){ var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))), j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); };
Save
Cancel