]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/js/jot.js
Merge pull request #7459 from annando/notice
[friendica.git] / view / theme / frio / js / jot.js
index 25db2382419d74c836e085c195ea194fc320e59c..d55e5098a28b89c96f9b6cb836ce0c4fbe412d05 100644 (file)
@@ -1,10 +1,8 @@
+// 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;
 
-$(document).ready(function() {
-       linkPreview = $('#profile-jot-text').linkPreview();
-});
-
-
 /**
  * Insert a link into friendica jot.
  * 
@@ -25,7 +23,17 @@ function jotGetLink() {
 
                // 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"));
        }
 }