Cleans the javascript

This commit is contained in:
2016-02-24 12:28:24 +01:00
parent e6e1f6d6b3
commit 17c2f18193
9 changed files with 34 additions and 30 deletions

View File

@@ -1,3 +1,3 @@
{ {
"varstmt" : true "varstmt" : false
} }

View File

@@ -38,7 +38,7 @@ album.component('album', {
id: '<albumId', id: '<albumId',
ratio: '<' ratio: '<'
} }
}) });
album.controller('AlbumModalInstanceCtrl', function($scope,$uibModalInstance,album) { album.controller('AlbumModalInstanceCtrl', function($scope,$uibModalInstance,album) {
$scope.album = album; $scope.album = album;
@@ -47,5 +47,5 @@ album.controller('AlbumModalInstanceCtrl', function($scope,$uibModalInstance,alb
}; };
$scope.getLink = function(n) { $scope.getLink = function(n) {
return $scope.album[n]; return $scope.album[n];
} };
}); });

View File

@@ -1,11 +1,11 @@
'use strict';
var controllers = angular.module('satbd.satellite.bar.controllers',[ var controllers = angular.module('satbd.satellite.bar.controllers',[
'ui.bootstrap', 'ui.bootstrap',
'ngAnimate' 'ngAnimate'
]); ]);
controllers.controller('NavBarCtrl',function($scope,$location,$uibModal) { controllers.controller('NavBarCtrl',function($scope,$location,$uibModal) {
"use strict";
$scope.isCollapsed = true; $scope.isCollapsed = true;
$scope.isActive = function(loc) { $scope.isActive = function(loc) {
return loc === $location.path(); return loc === $location.path();
@@ -15,7 +15,7 @@ controllers.controller('NavBarCtrl',function($scope,$location,$uibModal) {
if (searchTerms) { if (searchTerms) {
$location.url('/search?q='+ encodeURIComponent(searchTerms)); $location.url('/search?q='+ encodeURIComponent(searchTerms));
} }
} };
$scope.openHelpModal = function () { $scope.openHelpModal = function () {
var modalInstance = $uibModal.open({ var modalInstance = $uibModal.open({

View File

@@ -1,5 +1,3 @@
'use strict';
angular.module('satbd.satellite.bar',[ angular.module('satbd.satellite.bar',[
'ngRoute', 'ngRoute',
'satbd.satellite.bar.controllers', 'satbd.satellite.bar.controllers',
@@ -9,5 +7,7 @@ angular.module('satbd.satellite.bar',[
'satbd.satellite.bar.views.authors', 'satbd.satellite.bar.views.authors',
'satbd.satellite.bar.views.search' 'satbd.satellite.bar.views.search'
]).config(function($routeProvider) { ]).config(function($routeProvider) {
'use strict';
$routeProvider.otherwise({redirectTo: '/recents'}); $routeProvider.otherwise({redirectTo: '/recents'});
}); });

View File

@@ -1,4 +1,4 @@
var services = angular.module('satbd.satellite.bar.services',[]) var services = angular.module('satbd.satellite.bar.services',[]);
services.factory('albumService',['$http','$log','$q', function($http,$log,$q) { services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
var determinantRegexp = /^(.*) \(([Ll][eas']+)\)$/; var determinantRegexp = /^(.*) \(([Ll][eas']+)\)$/;
@@ -6,11 +6,11 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
var removeSerie = /^\(.*\) .*$/; var removeSerie = /^\(.*\) .*$/;
function cleanupName(name) { function cleanupName(name) {
var matchesStr = name.match(determinantRegexp); var matches = name.match(determinantRegexp);
if (matchesStr == null) { if (matches === null) {
return name; return name;
} }
return matchesStr[2] + ' ' + matchesStr[1]; return matches[2] + ' ' + matches[1];
} }
function cleanupFields(album) { function cleanupFields(album) {
@@ -18,7 +18,7 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
album.série = undefined; album.série = undefined;
album.editeur = album.éditeur; album.editeur = album.éditeur;
album.éditeur = undefined; album.éditeur = undefined;
if (removeSerie.test(album.serie) == true) { if (removeSerie.test(album.serie) === true) {
album.serieDisplay = ''; album.serieDisplay = '';
} else { } else {
album.serieDisplay = cleanupName(album.serie); album.serieDisplay = cleanupName(album.serie);
@@ -64,7 +64,7 @@ services.factory('albumService',['$http','$log','$q', function($http,$log,$q) {
"query": terms "query": terms
} }
}).then(function(response) { }).then(function(response) {
if ( fuzzify == true && response.data.total_hits == 0) { if ( fuzzify === true && response.data.total_hits === 0) {
return search(fuzzifyTerms(terms),from,false,response.data.took); return search(fuzzifyTerms(terms),from,false,response.data.took);
} }
return processResult(response.data,previousTime); return processResult(response.data,previousTime);

View File

@@ -1,9 +1,10 @@
'use strict';
angular.module('satbd.satellite.bar.views.authors',[ angular.module('satbd.satellite.bar.views.authors',[
'ngRoute' 'ngRoute'
]).config(function($routeProvider) { ]).config(function($routeProvider) {
'use strict';
$routeProvider.when('/authors', { $routeProvider.when('/authors', {
templateUrl: 'js/views/authors/authors.html', templateUrl: 'js/views/authors/authors.html',
}); });
}) });

View File

@@ -1,15 +1,17 @@
'use strict';
angular.module('satbd.satellite.bar.views.recents',[ angular.module('satbd.satellite.bar.views.recents',[
'ngRoute', 'ngRoute',
'satbd.satellite.bar.components.album', 'satbd.satellite.bar.components.album',
'angular-inview' 'angular-inview'
]).config(function($routeProvider) { ]).config(function($routeProvider) {
'use strict';
$routeProvider.when('/recents', { $routeProvider.when('/recents', {
templateUrl: 'js/views/recents/recents.html', templateUrl: 'js/views/recents/recents.html',
controller: 'RecentsCtrl' controller: 'RecentsCtrl'
}); });
}).controller('RecentsCtrl', function( $scope, $http, $log) { }).controller('RecentsCtrl', function( $scope, $http, $log) {
'use strict';
$scope.albumIDs = []; $scope.albumIDs = [];
$scope.allAlbums = []; $scope.allAlbums = [];
$scope.scrollMore = false; $scope.scrollMore = false;
@@ -29,13 +31,12 @@ angular.module('satbd.satellite.bar.views.recents',[
$log.info('Loading more components'); $log.info('Loading more components');
if (!$scope.scrollMore || $scope.albumIDs.length >= $scope.allAlbums.length) { if (!$scope.scrollMore || $scope.albumIDs.length >= $scope.allAlbums.length) {
$scope.scrollMore = false; $scope.scrollMore = false;
$log.info('reached the end of albums') $log.info('reached the end of albums');
return; return;
} }
var newSize = Math.min($scope.albumIDs.length + batchSize, $scope.allAlbums.length); var newSize = Math.min($scope.albumIDs.length + batchSize, $scope.allAlbums.length);
for( var i = $scope.albumIDs.length; i < newSize; i++) { for( var i = $scope.albumIDs.length; i < newSize; i++) {
$scope.albumIDs.push($scope.allAlbums[i]); $scope.albumIDs.push($scope.allAlbums[i]);
} }
} };
}); });

View File

@@ -1,5 +1,3 @@
'use strict';
angular.module('satbd.satellite.bar.views.search',[ angular.module('satbd.satellite.bar.views.search',[
'ngRoute', 'ngRoute',
'ngSanitize', 'ngSanitize',
@@ -7,11 +5,15 @@ angular.module('satbd.satellite.bar.views.search',[
'satbd.satellite.bar.components.album', 'satbd.satellite.bar.components.album',
'angular-inview' 'angular-inview'
]).config(function($routeProvider) { ]).config(function($routeProvider) {
'use strict';
$routeProvider.when('/search', { $routeProvider.when('/search', {
templateUrl: 'js/views/search/search.html', templateUrl: 'js/views/search/search.html',
controller: 'SearchCtrl' controller: 'SearchCtrl'
}); });
}).controller('SearchCtrl', function($scope,$routeParams,$log,$sce,albumService) { }).controller('SearchCtrl', function($scope,$routeParams,$log,$sce,albumService) {
'use strict';
$scope.terms=$routeParams.q; $scope.terms=$routeParams.q;
$scope.scrollMore = false; $scope.scrollMore = false;
$scope.allHits = []; $scope.allHits = [];
@@ -43,14 +45,14 @@ angular.module('satbd.satellite.bar.views.search',[
}; };
$scope.inSecond= function(bleveValue) { $scope.inSecond= function(bleveValue) {
return bleveValue / 1e9; return bleveValue / 1e6;
} };
$scope.trustedFragment = function(f) { $scope.trustedFragment = function(f) {
return $sce.trustAsHtml(f); return $sce.trustAsHtml(f);
} };
$scope.round4Dec = function(value) { $scope.round4Dec = function(value) {
return Math.round(value * 10000) / 10000; return Math.round(value * 10000) / 10000;
} };
}); });

View File

@@ -1,9 +1,9 @@
'use strict';
angular.module('satbd.satellite.bar.views.series',[ angular.module('satbd.satellite.bar.views.series',[
'ngRoute', 'ngRoute',
'satbd.satellite.bar.directives.responsive-ratio' 'satbd.satellite.bar.directives.responsive-ratio'
]).config(function($routeProvider) { ]).config(function($routeProvider) {
'use strict';
$routeProvider.when('/series', { $routeProvider.when('/series', {
templateUrl: 'js/views/series/series.html' templateUrl: 'js/views/series/series.html'
}); });