harbor/static/resources/js/harbor.config.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
angular
.module('harbor.app')
.config(function($interpolateProvider){
$interpolateProvider.startSymbol('//');
$interpolateProvider.endSymbol('//');
})
.config(function($httpProvider) {
$httpProvider.defaults.headers.common = {'Accept': 'application/json, text/javascript, */*; q=0.01'};
})
.factory('getParameterByName', getParameterByName)
2016-05-13 12:48:06 +02:00
.filter('dateL', localizeDate)
.filter('tr', tr);
function getParameterByName() {
return get;
function get(name, url) {
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
2016-05-23 12:29:17 +02:00
if (!results) {
return null;
}
if (!results[2]) {
return '';
}
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
}
function localizeDate() {
return filter;
function filter(input, pattern) {
return moment(new Date(input || '')).format(pattern);
}
2016-05-13 12:48:06 +02:00
}
tr.$inject = ['I18nService'];
function tr(I18nService) {
return tr;
function tr(label, params) {
2016-05-13 12:48:06 +02:00
var currentLanguage = I18nService().getCurrentLanguage();
var result = '';
2016-05-13 12:48:06 +02:00
if(label && label.length > 0){
result = I18nService().getValue(label, currentLanguage);
2016-05-13 12:48:06 +02:00
}
if(angular.isArray(params)) {
angular.forEach(params, function(value, index) {
result = result.replace('$' + index, params[index]);
});
}
return result;
2016-05-13 12:48:06 +02:00
}
}
})();