From 40edfae0a23284e000dd3e6b258d6e3d257ffd19 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Thu, 10 Dec 2015 17:36:28 +0100 Subject: [PATCH] fix for https://quitter.no/notice/824574 --- js/dom-functions.js | 14 +++++--------- js/misc-functions.js | 26 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/js/dom-functions.js b/js/dom-functions.js index e4b4c7e..b9fe470 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -1934,9 +1934,6 @@ function buildQueetHtml(obj, idInStream, extraClasses, requeeted_by, isConversat }); } - // image attachment thumbnails - var attachmentsBuild = buildAttachmentHTML(obj.attachments); - // requeets get's a context element and a identifying class // uri used is the repeate-notice's uri for repeats, not the repetED notice's uri (necessary if someone deletes a repeat) var URItoUse = obj.uri; @@ -1989,7 +1986,7 @@ function buildQueetHtml(obj, idInStream, extraClasses, requeeted_by, isConversat \ \
' + $.trim(obj.statusnet_html) + '
\ -
' + attachmentsBuild.html + '
\ + ' + buildAttachmentHTML(obj.attachments) + '\ \ @@ -2019,7 +2016,9 @@ function buildAttachmentHTML(attachments){ var attachmentNum = 0; if(typeof attachments != "undefined") { $.each(attachments, function(){ - if(typeof this.thumb_url != 'undefined' && this.thumb_url !== null) { // if there's a thumb_url we assume this is a image or video + if(typeof this.thumb_url != 'undefined' + && this.thumb_url !== null + && isLocalURL(this.thumb_url)) { // if there's a local thumb_url we assume this is a image or video var bigThumbW = 1000; var bigThumbH = 3000; if(bigThumbW > window.siteMaxThumbnailSize) { @@ -2075,8 +2074,5 @@ function buildAttachmentHTML(attachments){ } }); } - return { - html: attachment_html, - num: attachmentNum - }; + return '
' + attachment_html + '
'; } diff --git a/js/misc-functions.js b/js/misc-functions.js index 3e653f1..ac387a0 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -300,6 +300,22 @@ function localStorageIsEnabled() { } +/* · + · + · Is this a local URL? + · + · · · · · · · · · */ + +function isLocalURL(url) { + if(url.substring(0,window.siteInstanceURL.length) == window.siteInstanceURL) { + return true; + } + else { + return false; + } + } + + /* · · · Check for hidden items and show the new queets bar if there are any @@ -812,13 +828,9 @@ function searchForUpdatedNoticeData(obj) { // attachments might have been added/changed/have had time to be processed if(streamItemFoundInFeed.attr('data-attachments') != JSON.stringify(obj.attachments)) { streamItemFoundInFeed.attr('data-attachments',JSON.stringify(obj.attachments)); - // we might want to add thumbnails - if(queetFoundInFeed.find('.queet-thumbs').hasClass('thumb-num-0')) { - var attachmentsHTMLBuild = buildAttachmentHTML(obj.attachments); - queetFoundInFeed.find('.queet-thumbs').removeClass('thumb-num-0'); - queetFoundInFeed.find('.queet-thumbs').addClass('thumb-num-' + attachmentsHTMLBuild.num); - queetFoundInFeed.find('.queet-thumbs').html(attachmentsHTMLBuild.html); - } + var attachmentsHTMLBuild = buildAttachmentHTML(obj.attachments); + queetFoundInFeed.find('.queet-thumbs').remove(); + queetFoundInFeed.find('.stream-item-footer').before(attachmentsHTMLBuild); } // set favorite data