diff --git a/public_html/js/Utils.js b/public_html/js/Utils.js index 4999312..d52eb3f 100644 --- a/public_html/js/Utils.js +++ b/public_html/js/Utils.js @@ -30,9 +30,13 @@ String.prototype.contains = function(text) { return this.indexOf(text) >= 0; }; -/*String.prototype.startsWith = function(text) { +String.prototype.replaceAll = function(search, replace) { + return this.split(search).join(replace); +}; + +String.prototype.startsWith = function(text) { return this.indexOf(text) == 0; -};*/ +}; String.prototype.replaceAll = function (find, replace) { var str = this; diff --git a/public_html/js/Views.js b/public_html/js/Views.js index 5da1f2f..a664eb7 100644 --- a/public_html/js/Views.js +++ b/public_html/js/Views.js @@ -221,21 +221,22 @@ Views.prototype.text_2 = function (whoid, text) { } }; Views.prototype.text = function (arg1, arg2) { - if (arguments.length === 1) this.text_1(arg1); - else this.text_2(arg1, arg2); + if (arguments.length === 1) this.text_1(String(arg1)); + else this.text_2(String(arg1), String(arg2)); }; Views.prototype.formatString = function (tag, text) { var edited = text.replaceAll("\\{w.*?\\}", ""); if (edited.contains("{center}")) { - edited = text.replaceAll("\\{center\\}", ""); + edited = edited.replaceAll("\\{center\\}", ""); this.textContentTag.style.textAlign = "center"; } else { this.textContentTag.style.textAlign = "left"; } if (edited.contains("{html}")) { edited = edited.replaceAll("\\{html\\}", ""); - return edited; + tag.innerHTML = edited; + return; } var codes = ["b","i","s","u","big","small"]; var html = false; @@ -249,7 +250,7 @@ Views.prototype.formatString = function (tag, text) { } if (html) { edited = edited.replace("\n", "
"); - tag.innerHtml = edited; + tag.innerHTML = edited; } else { tag.innerText = edited; }