[ui_enhancements] Fix display of releases with few mediums after Server

update, 2015-02-09.
This commit is contained in:
Aurélien Mino 2015-02-14 12:29:36 +01:00
parent f217ccf005
commit a21eae18e6

View file

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Musicbrainz UI enhancements // @name Musicbrainz UI enhancements
// @description Various UI enhancements for Musicbrainz // @description Various UI enhancements for Musicbrainz
// @version 2014.12.25.1 // @version 2015.02.14.1
// @downloadURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js // @downloadURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js
// @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js // @updateURL https://raw.githubusercontent.com/murdos/musicbrainz-userscripts/master/mb_ui_enhancements.user.js
// @icon http://wiki.musicbrainz.org/-/images/3/3d/Musicbrainz_logo.png // @icon http://wiki.musicbrainz.org/-/images/3/3d/Musicbrainz_logo.png
@ -57,10 +57,10 @@ function main() {
// Fix for http://tickets.musicbrainz.org/browse/MBS-750 // Fix for http://tickets.musicbrainz.org/browse/MBS-750
re = new RegExp("musicbrainz\.org\/release\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})","i"); re = new RegExp("musicbrainz\.org\/release\/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})","i");
if (window.location.href.match(re)) { if (window.location.href.match(re)) {
if ( $("tr.subh").length == 1 ) { if ($("table.medium thead").length == 1) {
var text = $.trim($("tr.subh:eq(0)").text()); var text = $.trim($("table.medium thead").text());
if (text.match(/ 1$/)) { if (text.match(/ 1$/)) {
$("tr.subh:eq(0) a").text(text.replace(/ 1$/, '')); $("table.medium thead a").text(text.replace(/ 1$/, ''));
} }
} }
} }
@ -166,12 +166,12 @@ function main() {
// Get ISRC data from webservice // Get ISRC data from webservice
var wsurl = "/ws/2/release/" + mbid + "?inc=isrcs+recordings"; var wsurl = "/ws/2/release/" + mbid + "?inc=isrcs+recordings";
$.getJSON(wsurl, function(data) { $.getJSON(wsurl, function(data) {
// Table header // Extend colspan for medium table header
$("table.tbl thead th:nth-last-child("+ISRC_COLUMN_POSITION+")").before("<th> ISRC </th>"); $("table.medium thead tr").each(function() {
// Extend colspan for medium table row $(this).find("th:eq(0)").attr("colspan", $(this).find("th:eq(0)").attr("colspan")+1);
$("table.tbl tbody tr.subh").each(function() {
$(this).find("td:eq(1)").attr("colspan", $(this).find("td:eq(1)").attr("colspan")+1);
}); });
// Table sub-header
$("table.medium tbody tr.subh th:nth-last-child("+ISRC_COLUMN_POSITION+")").before("<th style='width: 150px;' class='c'> ISRC </th>");
$.each(data.media, function(index, medium) { $.each(data.media, function(index, medium) {
$.each(medium.tracks, function(i, track) { $.each(medium.tracks, function(i, track) {
@ -188,7 +188,7 @@ function main() {
}); });
isrcsLinks = links.join(", "); isrcsLinks = links.join(", ");
} }
$('#'+track.id).find("td:nth-last-child("+ISRC_COLUMN_POSITION+")").before("<td class='isrc'><small>"+isrcsLinks+"</small></td>"); $('#'+track.id).find("td:nth-last-child("+ISRC_COLUMN_POSITION+")").before("<td class='isrc c'><small>"+isrcsLinks+"</small></td>");
}); });
}); });
}); });