Skip to content

Instantly share code, notes, and snippets.

Created January 5, 2017 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/da847917648a935c652cad890cd678c1 to your computer and use it in GitHub Desktop.
Save anonymous/da847917648a935c652cad890cd678c1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xowara
<!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>
textarea {
width: 100%;
}
#warnings {
color: red;
}
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