From 32a34f76df401c9bf90c087047c5a45b04aeeaee Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 2 May 2014 02:32:52 +0200 Subject: [PATCH 1/2] Fix unwanted GET {0} requests Because of image prefetch of browsers the templates cause unwanted /{0} requests to the webserver. Templates are changed to use a data-src attribute. --- view/js/acl.js | 7 ++++++- view/tpl/acl_selector.tpl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/view/js/acl.js b/view/js/acl.js index 28e47011f..c129634a0 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -258,11 +258,16 @@ ACL.prototype.populate = function(data){ that.list_content.height(height); $(data.items).each(function(){ html = "
"+that.item_tpl+"
"; - html = html.format( this.photo, this.name, this.type, this.xid, '', this.self, this.link, this.taggable ); + html = html.format(this.photo, this.name, this.type, this.xid, '', this.self, this.link, this.taggable); if (this.uids!=undefined) that.group_uids[this.id] = this.uids; //console.log(html); that.list_content.append(html); }); + $("#acl-list-content .acl-list-item img[data-src]").each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); that.update_view(); } diff --git a/view/tpl/acl_selector.tpl b/view/tpl/acl_selector.tpl index c98350843..722d541ed 100755 --- a/view/tpl/acl_selector.tpl +++ b/view/tpl/acl_selector.tpl @@ -15,7 +15,7 @@ From cfad83084a0118dfdd88d4339109e3595e43ace5 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 2 May 2014 02:40:04 +0200 Subject: [PATCH 2/2] Also for notifications. --- view/js/main.js | 7 +++++-- view/tpl/hdr.tpl | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/view/js/main.js b/view/js/main.js index 38cde749c..17ef578be 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -645,12 +645,15 @@ function updateConvItems(mode,data) { } else { $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark); - $(data.notify).each(function() { html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.class); $("#nav-" + notifyType + "-menu").append(html); }); - + $(".dropdown-menu img[data-src]").each(function(i, el){ + // Replace data-src attribute with src attribute for every image + $(el).attr('src', $(el).data("src")); + $(el).removeAttr("data-src"); + }); } }); diff --git a/view/tpl/hdr.tpl b/view/tpl/hdr.tpl index efb43224c..fdcc4521c 100644 --- a/view/tpl/hdr.tpl +++ b/view/tpl/hdr.tpl @@ -1,5 +1,5 @@