-
-
Save barakplasma/29431f2ebf98719e61b18a1c78c22c2f to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xowara
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
textarea { | |
width: 100%; | |
} | |
#warnings { | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<textarea rows="20" id="userIn" oninput="update()"></textarea> | |
<div id="warnings"></div> | |
<div id="userOut"></div> | |
<script id="jsbin-javascript"> | |
var userIn; | |
function update(){ | |
userIn = document.querySelector('#userIn').value; | |
//var iframer = `<iframe sandbox width="100%" srcdoc=\`${userIn}\`></iframe>`; | |
//console.log(iframer); | |
document.querySelector('#userOut').innerHTML = userIn; | |
warn(); | |
} | |
function warn(){ | |
var warnHere = document.querySelector('#warnings'); | |
var problemsToLookFor = [ | |
"http(?!s)", | |
"other HTML Element limitations go here" | |
]; | |
var regEx = new RegExp(problemsToLookFor.join('|'),'i'); | |
if(regEx.test(userIn)){ | |
warnHere.innerHTML = regEx.exec(userIn)[0]; | |
console.error("code may not work due to: %s ",warnHere.innerHTML); | |
}else{ | |
warnHere.innerHTML = ""; | |
}; | |
} | |
</script> | |
<script id="jsbin-source-css" type="text/css">textarea { | |
width: 100%; | |
} | |
#warnings { | |
color: red; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var userIn; | |
function update(){ | |
userIn = document.querySelector('#userIn').value; | |
//var iframer = `<iframe sandbox width="100%" srcdoc=\`${userIn}\`></iframe>`; | |
//console.log(iframer); | |
document.querySelector('#userOut').innerHTML = userIn; | |
warn(); | |
} | |
function warn(){ | |
var warnHere = document.querySelector('#warnings'); | |
var problemsToLookFor = [ | |
"http(?!s)", | |
"other HTML Element limitations go here" | |
]; | |
var regEx = new RegExp(problemsToLookFor.join('|'),'i'); | |
if(regEx.test(userIn)){ | |
warnHere.innerHTML = regEx.exec(userIn)[0]; | |
console.error("code may not work due to: %s ",warnHere.innerHTML); | |
}else{ | |
warnHere.innerHTML = ""; | |
}; | |
}</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textarea { | |
width: 100%; | |
} | |
#warnings { | |
color: red; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userIn; | |
function update(){ | |
userIn = document.querySelector('#userIn').value; | |
//var iframer = `<iframe sandbox width="100%" srcdoc=\`${userIn}\`></iframe>`; | |
//console.log(iframer); | |
document.querySelector('#userOut').innerHTML = userIn; | |
warn(); | |
} | |
function warn(){ | |
var warnHere = document.querySelector('#warnings'); | |
var problemsToLookFor = [ | |
"http(?!s)", | |
"other HTML Element limitations go here" | |
]; | |
var regEx = new RegExp(problemsToLookFor.join('|'),'i'); | |
if(regEx.test(userIn)){ | |
warnHere.innerHTML = regEx.exec(userIn)[0]; | |
console.error("code may not work due to: %s ",warnHere.innerHTML); | |
}else{ | |
warnHere.innerHTML = ""; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment