JS: Base functions

This commit is contained in:
2015-05-27 01:22:37 +02:00
parent 3833d3ccca
commit 58824eea58
4 changed files with 145 additions and 2 deletions

View File

@@ -1 +1,20 @@
function GetElement(element) {
if (typeof element == "string") {
element = document.getElementById(element);
}
return element;
}
function escapeHTML(s) {
return s.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}