friendica/view/theme/frio/js/jot.js

42 lines
1.3 KiB
JavaScript
Raw Normal View History

// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
// We append the linkPreview to a global Variable to make linkPreview
// accessable on other places. Note: search on other places before you
// delete or move the variable.
var linkPreview;
/**
* Insert a link into friendica jot.
2021-01-22 14:38:44 +01:00
*
* @returns {void}
*/
function jotGetLink() {
var currentText = $("#profile-jot-text").val();
2021-01-22 14:38:44 +01:00
var noAttachment = "";
reply = prompt(aStr.linkurl);
2021-01-22 14:38:44 +01:00
if (reply && reply.length) {
// 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();
if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
2021-01-22 14:38:44 +01:00
noAttachment = "&noAttachment=1";
}
// We use the linkPreview library to have a preview
// of the attachments.
2021-01-22 14:38:44 +01:00
if (typeof linkPreview === "object") {
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
} else {
$.get("parseurl?binurl=" + bin2hex(reply) + noAttachment, function (data) {
addeditortext(data);
2021-01-22 14:38:44 +01:00
$("#profile-rotator").hide();
});
}
autosize.update($("#profile-jot-text"));
}
}
// @license-end