From 58ea025c039be49406d5709fcabfa28f3105c3c5 Mon Sep 17 00:00:00 2001 From: Jens Gutermuth Date: Sun, 22 Mar 2015 23:54:27 +0100 Subject: [PATCH] Case insensitive sorting of tags in javascript --- pinry/static/js/pinry.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pinry/static/js/pinry.js b/pinry/static/js/pinry.js index 5a52687..b9f93de 100644 --- a/pinry/static/js/pinry.js +++ b/pinry/static/js/pinry.js @@ -117,8 +117,12 @@ $(window).load(function() { if (userFilter) apiUrl = apiUrl + '&submitter__username=' + userFilter; $.get(apiUrl, function(pins) { // Set which items are editable by the current user - for (var i=0; i < pins.objects.length; i++) + for (var i=0; i < pins.objects.length; i++) { pins.objects[i].editable = (pins.objects[i].submitter.username == currentUser.username); + pins.objects[i].tags.sort(function (a, b) { + return a.toLowerCase().localeCompare(b.toLowerCase()); + }); + } // Use the fetched pins as our context for our pins template var template = Handlebars.compile($('#pins-template').html()); @@ -138,7 +142,7 @@ $(window).load(function() { if (pins.objects.length < apiLimitPerPage) { $('.spinner').css('display', 'none'); - if ($('#pins').length != 0) { + if ($('#pins').length !== 0) { var theEnd = document.createElement('div'); theEnd.id = 'the-end'; $(theEnd).html('— End —');