-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (21 loc) · 858 Bytes
/
app.js
File metadata and controls
27 lines (21 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function runCSS(codeFrom, toApply) {
const re = new RegExp('^((\{)|(\}))+','g');
const text = document.getElementById(codeFrom);
const output = document.getElementById(toApply);
var code = "{" + text.value + "}";
if(text.value.match(re)){
alert("CSS CODE INJECTION DETECTED, REMOVE { or } FROM THE CODE_AREA") ;
return
}
var SHEET_ID_CHECK = document.getElementById(codeFrom + toApply + '-style');
if (SHEET_ID_CHECK != null) {
var sheetParent = SHEET_ID_CHECK.parentNode;
sheetParent.removeChild(SHEET_ID_CHECK);
}
var sheet = document.createElement('style');
sheet.type = 'text/css';
sheet.id = codeFrom + toApply + '-style';
sheet.innerHTML = "." + codeFrom + toApply + code;
document.body.appendChild(sheet);
output.classList.add(codeFrom + toApply);
}