Last active
February 19, 2016 09:20
-
-
Save mintyPT/99172ee907e7e93421b7 to your computer and use it in GitHub Desktop.
Some kind of cleaning function, no ideia why I made this though
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> | |
<title></title> | |
<style> | |
#input, #output { | |
width: 500px; | |
border: 1px solid #ccc; | |
} | |
#input { | |
height: 300px; | |
} | |
#output { | |
min-height: 300px; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- --> | |
<!-- nostrud exercitation <span clas="23ewcs23 12312e 123fcs xz">santos</span> dolore lablaborum. --> | |
<textarea id="input"></textarea> | |
<br> | |
<button id="limpar">limpar</button> | |
<br> | |
<br> | |
<hr> | |
<div id="output"></div> | |
<script> | |
function reEscape(s) { | |
return s.replace(/<span[\s\w="]*>(.*)<\/span>/mg, "$1"); | |
} | |
function strip(html) | |
{ | |
var tmp = document.createElement("DIV"); | |
tmp.innerHTML = html; | |
return tmp.textContent || tmp.innerText || ""; | |
} | |
document.getElementById('limpar').addEventListener("click", function(){ | |
console.log('run'); | |
var text = document.getElementById('input').value; | |
//text.replace(/<(?:.|\n)*?>/gm, ''); | |
document.getElementById('output').innerText = strip(text); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment