summaryrefslogtreecommitdiff
path: root/main.js
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-07-30 20:11:33 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-07-30 20:11:33 +1000
commit9dc14b04bea61783b91b3192bf7b1254c46acfc6 (patch)
tree147f81535a40b9e6d29e3738b6a40b259899c182 /main.js
parentdcba7462d61bc14efb4a71c0abf77b31d5ec6281 (diff)
insert cite at caret/selection pos instead of end
Diffstat (limited to 'main.js')
-rw-r--r--main.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/main.js b/main.js
index 477c90db..ce640390 100644
--- a/main.js
+++ b/main.js
@@ -53,7 +53,22 @@ function dopost(form) {
return form.body.value != "" || (typeof form.thread != "undefined" && form.file.value != "");
}
function citeReply(id) {
- document.getElementById('body').value += '>>' + id + '\n';
+ body = document.getElementById('body');
+
+ if (document.selection) {
+ // IE
+ body.focus();
+ sel = document.selection.createRange();
+ sel.text = '>>' + id + '\n';
+ } else if (body.selectionStart || body.selectionStart == '0') {
+ // Mozilla
+ start = body.selectionStart;
+ end = body.selectionEnd;
+ body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length);
+ } else {
+ // ???
+ body.value += '>>' + id + '\n';
+ }
}
var selectedstyle = 'Yotsuba B';