Created
November 9, 2011 14:42
-
-
Save abidibo/1351623 to your computer and use it in GitHub Desktop.
A proof of character counter for fck editor 2.x
This file contains 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
// requires mootools-core bind function | |
function FCKeditor_OnComplete(editorInstance){ | |
editorInstance.EditorDocument.addEventListener('keypress', checkCharacters.bind(editorInstance)); | |
} | |
function checkCharacters(e) { | |
var characters = 0; | |
var clean_tag = this.GetHTML().replace(/<\/?.*?>| /gi, ''); | |
var clean_string = clean_tag.replace(/"/gi, ' '); // add more entities | |
var add = e.charCode ? 1 : (e.keyCode==46 || e.keyCode==8) ? -1 : 0; | |
characters = clean_string.length + add | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment