Makes album display a bit nicer

This commit is contained in:
2016-02-12 14:36:59 +01:00
parent cadd630a44
commit 830cec54c5
2 changed files with 26 additions and 15 deletions

View File

@@ -1,11 +1,32 @@
var services = angular.module('satbd.satellite.bar.services',[])
services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
var determinantRegexp = /^(.*) \(([Ll][eas']+)\)$/;
var removeSerie = /^\(.*\) .*$/;
function cleanupName(name) {
matches = name.match(determinantRegexp);
if (matches == null) {
return name;
}
return matches[2] + ' ' + matches[1];
}
function cleanupFields(album) {
album.serie = album.série;
album.série = undefined;
album.editeur = album.éditeur;
album.éditeur = undefined;
if (removeSerie.test(album.serie) == true) {
album.serieDisplay = '';
} else {
album.serieDisplay = cleanupName(album.serie);
if ( album.Num > -1 ) {
album.serieDisplay += ' ' + album.Num;
}
}
album.titleDisplay = cleanupName(album.titre);
return album;
}
function get(id) {