+// We apptend 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;
-$(document).ready(function() {
- linkPreview = $('#profile-jot-text').linkPreview();
-});
-
-
/**
* Insert a link into friendica jot.
*
// We use the linkPreview library to have a preview
// of the attachments.
- linkPreview.crawlText(reply + noAttachment);
+ if (typeof linkPreview === 'object') {
+ linkPreview.crawlText(reply + noAttachment);
+
+ // Fallback: insert the attachment bbcode directly into the textarea
+ // if the attachment live preview isn't available
+ } else {
+ $.get('parse_url?binurl=' + bin2hex(reply) + noAttachment, function(data) {
+ addeditortext(data);
+ $('#profile-rotator').hide();
+ });
+ }
autosize.update($("#profile-jot-text"));
}
}
}
function addCommentText(data, id) {
- // get the textfield
- var textfield = document.getElementById("comment-edit-text-" + id);
- // check if the textfield does have the default-value
- commentOpenUI(textfield, id);
- // save already existent content
- var currentText = $("#comment-edit-text-" + id).val();
- //insert the data as new value
- textfield.value = currentText + data;
- autosize.update($("#comment-edit-text-" + id));
+ // get the textfield
+ var textfield = document.getElementById("comment-edit-text-" + id);
+ // check if the textfield does have the default-value
+ commentOpenUI(textfield, id);
+ // save already existent content
+ var currentText = $("#comment-edit-text-" + id).val();
+ //insert the data as new value
+ textfield.value = currentText + data;
+ autosize.update($("#comment-edit-text-" + id));
}
function commentLinkDrop(event, id) {
- var reply = event.dataTransfer.getData("text/uri-list");
- event.target.textContent = reply;
- event.preventDefault();
- if (reply && reply.length) {
- reply = bin2hex(reply);
- $.get('parse_url?noAttachment=1&binurl=' + reply, function(data) {
+ var reply = event.dataTransfer.getData("text/uri-list");
+ event.target.textContent = reply;
+ event.preventDefault();
+ if (reply && reply.length) {
+ reply = bin2hex(reply);
+ $.get('parse_url?noAttachment=1&binurl=' + reply, function(data) {
addCommentText(data, id);
- });
- }
+ });
+ }
}
function commentLinkDropper(event) {
- var linkFound = event.dataTransfer.types.contains("text/uri-list");
- if (linkFound) {
- event.preventDefault();
- }
+ var linkFound = event.dataTransfer.types.contains("text/uri-list");
+ if (linkFound) {
+ event.preventDefault();
+ }
}