2020-09-27 18:36:33 +02:00
|
|
|
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
|
2019-02-03 16:26:13 +01:00
|
|
|
// We append the linkPreview to a global Variable to make linkPreview
|
2019-02-02 03:12:36 +01:00
|
|
|
// accessable on other places. Note: search on other places before you
|
|
|
|
// delete or move the variable.
|
2019-02-01 19:18:08 +01:00
|
|
|
var linkPreview;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a link into friendica jot.
|
2021-01-22 14:38:44 +01:00
|
|
|
*
|
2019-02-01 19:18:08 +01:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function jotGetLink() {
|
|
|
|
var currentText = $("#profile-jot-text").val();
|
2021-01-22 14:38:44 +01:00
|
|
|
var noAttachment = "";
|
2019-02-01 19:18:08 +01:00
|
|
|
reply = prompt(aStr.linkurl);
|
2021-01-22 14:38:44 +01:00
|
|
|
if (reply && reply.length) {
|
2019-02-01 19:18:08 +01:00
|
|
|
// There should be only one attachment per post.
|
|
|
|
// So we need to remove the old one.
|
2021-01-22 14:38:44 +01:00
|
|
|
$("#jot-attachment-preview").empty();
|
|
|
|
$("#profile-rotator").show();
|
2019-02-01 19:18:08 +01:00
|
|
|
if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
|
2021-01-22 14:38:44 +01:00
|
|
|
noAttachment = "&noAttachment=1";
|
2019-02-01 19:18:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// We use the linkPreview library to have a preview
|
|
|
|
// of the attachments.
|
2021-01-22 14:38:44 +01:00
|
|
|
if (typeof linkPreview === "object") {
|
2019-02-02 03:12:36 +01:00
|
|
|
linkPreview.crawlText(reply + noAttachment);
|
|
|
|
|
2021-01-22 14:38:44 +01:00
|
|
|
// Fallback: insert the attachment bbcode directly into the textarea
|
|
|
|
// if the attachment live preview isn't available
|
2019-02-02 03:12:36 +01:00
|
|
|
} else {
|
2021-02-16 16:20:51 +01:00
|
|
|
$.get("parseurl?binurl=" + bin2hex(reply) + noAttachment, function (data) {
|
2019-02-02 03:12:36 +01:00
|
|
|
addeditortext(data);
|
2021-01-22 14:38:44 +01:00
|
|
|
$("#profile-rotator").hide();
|
2019-02-02 03:12:36 +01:00
|
|
|
});
|
|
|
|
}
|
2019-02-01 19:18:08 +01:00
|
|
|
autosize.update($("#profile-jot-text"));
|
|
|
|
}
|
|
|
|
}
|
2020-09-27 18:36:33 +02:00
|
|
|
// @license-end
|