mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-22 12:42:44 +01:00
Added styles to application
This commit is contained in:
@@ -38,7 +38,17 @@
|
||||
return HtmlBuilder.createElement(this.toString());
|
||||
};
|
||||
|
||||
HtmlBuilder.createElement = function(html) {
|
||||
HtmlBuilder.createElement = function(template, model) {
|
||||
var regex = /(?:{([^}]+)})/g, html;
|
||||
|
||||
if(model == null){
|
||||
html = template;
|
||||
} else {
|
||||
html = template.replace(regex, function(m, g1) {
|
||||
return HtmlBuilder.escapeHtml(model[g1]);
|
||||
});
|
||||
}
|
||||
|
||||
var el = document.createElement('div');
|
||||
el.innerHTML = html;
|
||||
return el.children[0];
|
||||
@@ -53,12 +63,21 @@
|
||||
for(var key in attr) {
|
||||
if(key == 'html')
|
||||
continue;
|
||||
str.push(key + '="' + attr[key] + '"');
|
||||
str.push(key + '="' + HtmlBuilder.escapeHtml(attr[key]) + '"');
|
||||
}
|
||||
|
||||
return str.join(' ');
|
||||
}
|
||||
|
||||
HtmlBuilder.escapeHtml = function(html) {
|
||||
return html
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
};
|
||||
|
||||
window.HtmlBuilder = HtmlBuilder;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user