2016-04-13 12:55:05 +02:00
|
|
|
(function() {
|
2016-04-26 12:23:34 +02:00
|
|
|
'use strict';
|
|
|
|
angular
|
|
|
|
.module('harbor.app')
|
|
|
|
.config(function($interpolateProvider){
|
2016-04-13 12:55:05 +02:00
|
|
|
$interpolateProvider.startSymbol('//');
|
|
|
|
$interpolateProvider.endSymbol('//');
|
2016-04-26 12:23:34 +02:00
|
|
|
})
|
|
|
|
.config(function($httpProvider) {
|
|
|
|
$httpProvider.defaults.headers.common = {'Accept': 'application/json, text/javascript, */*; q=0.01'};
|
2016-05-12 12:30:01 +02:00
|
|
|
})
|
2016-05-19 06:50:32 +02:00
|
|
|
.factory('getParameterByName', getParameterByName)
|
2016-05-13 12:48:06 +02:00
|
|
|
.filter('dateL', localizeDate)
|
|
|
|
.filter('tr', tr);
|
2016-05-19 06:50:32 +02:00
|
|
|
|
|
|
|
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 '';
|
|
|
|
}
|
|
|
|
|
2016-05-19 06:50:32 +02:00
|
|
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-12 12:30:01 +02:00
|
|
|
function localizeDate() {
|
|
|
|
return filter;
|
|
|
|
|
|
|
|
function filter(input, pattern) {
|
2016-06-24 12:44:54 +02:00
|
|
|
var d = new Date(input || '');
|
|
|
|
if(d.getTime() <= 0) return 'N/A';
|
|
|
|
return moment(d).format(pattern);
|
2016-05-12 12:30:01 +02:00
|
|
|
}
|
2016-05-13 12:48:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
tr.$inject = ['I18nService'];
|
|
|
|
|
|
|
|
function tr(I18nService) {
|
|
|
|
return tr;
|
2016-05-14 13:28:15 +02:00
|
|
|
function tr(label, params) {
|
2016-05-13 12:48:06 +02:00
|
|
|
var currentLanguage = I18nService().getCurrentLanguage();
|
2016-05-14 13:28:15 +02:00
|
|
|
var result = '';
|
2016-05-13 12:48:06 +02:00
|
|
|
if(label && label.length > 0){
|
2016-05-14 13:28:15 +02:00
|
|
|
result = I18nService().getValue(label, currentLanguage);
|
2016-05-13 12:48:06 +02:00
|
|
|
}
|
2016-05-14 13:28:15 +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
|
|
|
}
|
2016-05-12 12:30:01 +02:00
|
|
|
}
|
2016-04-13 12:55:05 +02:00
|
|
|
|
|
|
|
})();
|