]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/jot.js
attachment preview: mv some js functions from frio to the linkPreview to make linkPre...
[friendica.git] / view / theme / frio / js / jot.js
1 var linkPreview;
2
3 $(document).ready(function() {
4         linkPreview = $('#profile-jot-text').linkPreview();
5 });
6
7
8 /**
9  * Insert a link into friendica jot.
10  * 
11  * @returns {void}
12  */
13 function jotGetLink() {
14         var currentText = $("#profile-jot-text").val();
15         var noAttachment = '';
16         reply = prompt(aStr.linkurl);
17         if(reply && reply.length) {
18                 // There should be only one attachment per post.
19                 // So we need to remove the old one.
20                 $('#jot-attachment-preview').empty();
21                 $('#profile-rotator').show();
22                 if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
23                         noAttachment = '&noAttachment=1';
24                 }
25
26                 // We use the linkPreview library to have a preview
27                 // of the attachments.
28                 linkPreview.crawlText(reply + noAttachment);
29                 autosize.update($("#profile-jot-text"));
30         }
31 }