]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/jot.js
Merge remote-tracking branch 'upstream/develop' into aria
[friendica.git] / view / theme / frio / js / jot.js
1 // We append the linkPreview to a global Variable to make linkPreview
2 // accessable on other places. Note: search on other places before you
3 // delete or move the variable.
4 var linkPreview;
5
6 /**
7  * Insert a link into friendica jot.
8  * 
9  * @returns {void}
10  */
11 function jotGetLink() {
12         var currentText = $("#profile-jot-text").val();
13         var noAttachment = '';
14         reply = prompt(aStr.linkurl);
15         if(reply && reply.length) {
16                 // There should be only one attachment per post.
17                 // So we need to remove the old one.
18                 $('#jot-attachment-preview').empty();
19                 $('#profile-rotator').show();
20                 if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
21                         noAttachment = '&noAttachment=1';
22                 }
23
24                 // We use the linkPreview library to have a preview
25                 // of the attachments.
26                 if (typeof linkPreview === 'object') {
27                         linkPreview.crawlText(reply + noAttachment);
28
29                 // Fallback: insert the attachment bbcode directly into the textarea
30                 // if the attachment live preview isn't available
31                 } else {
32                         $.get('parse_url?binurl=' + bin2hex(reply) + noAttachment, function(data) {
33                                 addeditortext(data);
34                                 $('#profile-rotator').hide();
35                         });
36                 }
37                 autosize.update($("#profile-jot-text"));
38         }
39 }