mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-25 16:00:22 +01:00
insert cite at caret/selection pos instead of end
This commit is contained in:
parent
d749b20367
commit
fcafdf61f5
17
main.js
17
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';
|
||||
|
@ -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 = '{config[default_stylesheet][0]}';
|
||||
|
Loading…
Reference in New Issue
Block a user