Ticket #223 (closed defect: fixed)
a Charcounter tested with Mozilla and IE "\plugins\CharCounter\"
| Reported by: | gocher / udo.schmal@… | Owned by: | gocher |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | Xinha Core | Version: | |
| Severity: | normal | Keywords: | new plugin |
| Cc: |
Description
my charcounter uses the statusbar for output
char-counter.js:
// Charcounter for HTMLArea-3.0
// (c) Udo Schmal & L.N.Schaffrath NeueMedien
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
function CharCounter(editor) {
this.editor = editor;
};
CharCounter._pluginInfo = {
name : "CharCounter",
version : "1.0",
developer : "Udo Schmal",
developer_url : "http://www.schaffrath-neuemedien.de",
sponsor : "L.N.Schaffrath NeueMedien",
sponsor_url : "http://www.schaffrath-neuemedien.de",
c_owner : "Udo Schmal & L.N.Schaffrath NeueMedien",
license : "htmlArea"
};
CharCounter.prototype.onGenerate = function() {
var self = this;
var charCount = document.createElement("div");
this.charCount = charCount;
charCount.innerHTML = HTMLArea._lc("Chars","CharCounter") + ": ";
this.editor._statusBar.appendChild(charCount);
var doc = this.editordoc = this.editor._iframe.contentWindow.document;
HTMLArea._addEvents(doc, ["keyup", "keypress", "mousedown", "mouseup", "drag"],
function (event) {
return self.keyPress(self.editor, HTMLArea.is_ie ? self.editor._iframe.contentWindow.event : event);
});
};
CharCounter.prototype.keyPress = function(editor, ev) {
var contents = editor.getHTML();
contents = contents.replace(/<(.+?)>/g, '');//Don't count HTML tags
contents = contents.replace(/ /g, ' ');//Count nbsp; as one keystroke
this.charCount.innerHTML = HTMLArea._lc("Chars","CharCounter") + ": " + contents.length;
}
language file de.js:
// I18N constants
// LANG: "de", ENCODING: UTF-8
// Author: Udo Schmal, <udo.schmal@t-online.de>
//
// (c) Udo Schmal & L.N.Schaffrath NeueMedien 2004
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
{
"Chars": "Zeichen"
}
Change History
Note: See
TracTickets for help on using
tickets.
