Merge pull request #182 from anaqreon/url-selected

Place link around selected text
This commit is contained in:
redmatrix 2015-11-24 09:41:55 +11:00
commit 34b804e9dc

View File

@ -190,15 +190,27 @@ function enableOnUser(){
} }
function jotGetLink() { function jotGetLink() {
reply = prompt("{{$linkurl}}"); textarea = document.getElementById('profile-jot-text');
if(reply && reply.length) { if (textarea.selectionStart || textarea.selectionStart == "0") {
reply = bin2hex(reply); var start = textarea.selectionStart;
$('#profile-rotator').spin('tiny'); var end = textarea.selectionEnd;
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) { if (end > start) {
addeditortext(data); reply = prompt("{{$linkurl}}");
$('#profile-rotator').spin(false); if(reply && reply.length) {
}); textarea.value = textarea.value.substring(0, start) + "[url=" + reply + "]" + textarea.value.substring(start, end) + "[/url]" + textarea.value.substring(end, textarea.value.length);
} }
} else {
reply = prompt("{{$linkurl}}");
if(reply && reply.length) {
reply = bin2hex(reply);
$('#profile-rotator').spin('tiny');
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) {
addeditortext(data);
$('#profile-rotator').spin(false);
});
}
}
}
} }
function jotVideoURL() { function jotVideoURL() {