diff options
author | redmatrix <redmatrix@redmatrix.me> | 2015-11-24 09:41:55 +1100 |
---|---|---|
committer | redmatrix <redmatrix@redmatrix.me> | 2015-11-24 09:41:55 +1100 |
commit | 34b804e9dc5c288d133ea81727a0bf73297ddcbf (patch) | |
tree | f127bfdc48a14855cb112f12949864f550ac4944 /view | |
parent | ae1103c5a3f3f76a0269cbb5de11a7cb96496ad3 (diff) | |
parent | fee85030933bd15788bde7c0e019803a27a55f84 (diff) | |
download | volse-hubzilla-34b804e9dc5c288d133ea81727a0bf73297ddcbf.tar.gz volse-hubzilla-34b804e9dc5c288d133ea81727a0bf73297ddcbf.tar.bz2 volse-hubzilla-34b804e9dc5c288d133ea81727a0bf73297ddcbf.zip |
Merge pull request #182 from anaqreon/url-selected
Place link around selected text
Diffstat (limited to 'view')
-rwxr-xr-x | view/tpl/jot-header.tpl | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index b405e4ac8..84fccc105 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -190,15 +190,27 @@ function enableOnUser(){ } function jotGetLink() { - 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); - }); - } + textarea = document.getElementById('profile-jot-text'); + if (textarea.selectionStart || textarea.selectionStart == "0") { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + if (end > start) { + reply = prompt("{{$linkurl}}"); + 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() { |