Move escapeHtml to utils.

Signed-off-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
XhmikosR
2020-05-25 12:32:43 +03:00
parent ac8ece7d05
commit eab6485edb
7 changed files with 47 additions and 70 deletions

View File

@@ -7,6 +7,21 @@
/* global moment:false */
// Credit: https://stackoverflow.com/questions/1787322/htmlspecialchars-equivalent-in-javascript/4835406#4835406
function escapeHtml(text) {
var map = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#039;"
};
return text.replace(/[&<>"']/g, function (m) {
return map[m];
});
}
var info = null;
function showAlert(type, icon, title, message) {
var opts = {};
@@ -172,6 +187,7 @@ function stateLoadCallback(itemName) {
window.utils = (function () {
return {
escapeHtml: escapeHtml,
showAlert: showAlert,
datetime: datetime,
disableAll: disableAll,