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