Skip to content

Instantly share code, notes, and snippets.

@dpsk
Created April 8, 2011 11:12
Show Gist options
  • Save dpsk/909649 to your computer and use it in GitHub Desktop.
Save dpsk/909649 to your computer and use it in GitHub Desktop.
rangy
<script type="text/javascript">
function clean(id) {
setTimeout('clean2("'+id+'")', 1)
}
function clean2(id) {
el=document.getElementById(id)
var savedSel = rangy.saveSelection();
el.innerHTML = el.innerHTML.replace(/(<([^>]+)>)/ig,"");
el.innerHTML = el.innerHTML.replace(/([0-9])/ig,"<font color='red'>$1</font>");
rangy.restoreSelection(savedSel);
return false;
}
</script>
<div contenteditable="true" id="pad" onkeyup="clean('pad')"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment