Frank Hochmuth f72d731e3f
Update emoticons.js
- Prevents jumping back to the first position if an emoticon is pressed several times
2024-03-02 21:47:43 +01:00

22 lines
593 B
JavaScript

/*
* Emoticons Plugin
*/
function insertAtCursor(myField, myValue) {
if(document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
else if (myField.selectionStart || myField.selectionStart == 0.1) {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}
function emoticons(value) {
return insertAtCursor(document.getElementById('content'), value);
}