109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
// Generated by CoffeeScript 1.10.0
|
|
|
|
/*
|
|
diff.html script
|
|
*/
|
|
|
|
(function() {
|
|
var llapp;
|
|
|
|
llapp = angular.module('llngConfDiff', ['ui.tree', 'ui.bootstrap', 'llApp', 'ngCookies']);
|
|
|
|
llapp.controller('DiffCtrl', [
|
|
'$scope', '$http', '$q', '$translator', '$location', function($scope, $http, $q, $translator, $location) {
|
|
var getCfg, init, pathEvent;
|
|
$scope.links = links;
|
|
$scope.menulinks = menulinks;
|
|
$scope.staticPrefix = staticPrefix;
|
|
$scope.scriptname = scriptname;
|
|
$scope.availableLanguages = availableLanguages;
|
|
$scope.waiting = true;
|
|
$scope.showM = false;
|
|
$scope.cfg = [];
|
|
$scope.translateTitle = function(node) {
|
|
return $translator.translateField(node, 'title');
|
|
};
|
|
$scope.translateP = $translator.translateP;
|
|
$scope.translate = $translator.translate;
|
|
$scope.menuClick = function(button) {
|
|
if (button.popup) {
|
|
window.open(button.popup);
|
|
} else {
|
|
if (!button.action) {
|
|
button.action = button.title;
|
|
}
|
|
switch (typeof button.action) {
|
|
case 'function':
|
|
button.action($scope.currentNode, $scope);
|
|
break;
|
|
case 'string':
|
|
$scope[button.action]();
|
|
break;
|
|
default:
|
|
console.log(typeof button.action);
|
|
}
|
|
}
|
|
return $scope.showM = false;
|
|
};
|
|
$scope.getLanguage = function(lang) {
|
|
$scope.lang = lang;
|
|
$scope.init();
|
|
return $scope.showM = false;
|
|
};
|
|
getCfg = function(b, n) {
|
|
var d;
|
|
d = $q.defer();
|
|
if (($scope.cfg[b] == null) || $scope.cfg[b] !== n) {
|
|
$http.get("" + confPrefix + n).then(function(response) {
|
|
var date;
|
|
$scope.cfg[b] = response.data;
|
|
date = new Date(response.data.cfgDate * 1000);
|
|
$scope.cfg[b].date = date.toLocaleString();
|
|
console.log("Metadatas of cfg " + n + " loaded");
|
|
return d.resolve('OK');
|
|
}, function(response) {
|
|
console.log(response);
|
|
return d.reject('NOK');
|
|
});
|
|
} else {
|
|
d.resolve();
|
|
}
|
|
return d.promise;
|
|
};
|
|
init = function() {
|
|
$scope.waiting = true;
|
|
return $q.all([$translator.init($scope.lang)]).then(function() {
|
|
return $scope.waiting = false;
|
|
}, function(resp) {
|
|
return $scope.waiting = false;
|
|
});
|
|
};
|
|
pathEvent = function(event, next, current) {
|
|
var n;
|
|
n = next.match(new RegExp('#/(latest|[0-9]+)(?:/(latest|[0-9]+))?$'));
|
|
if (n === null) {
|
|
$location.path('/latest');
|
|
} else {
|
|
console.log(n);
|
|
$q.all([getCfg(0, n[1]), n[2] != null ? getCfg(1, n[2]) : void 0]).then(function() {
|
|
if (n[2] != null) {
|
|
return init();
|
|
} else {
|
|
if ($scope.cfg[0].prev) {
|
|
return getCfg(1, $scope.cfg[0].prev).then(function() {
|
|
return init();
|
|
});
|
|
} else {
|
|
return console.log('TODO');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return true;
|
|
};
|
|
return $scope.$on('$locationChangeSuccess', pathEvent);
|
|
}
|
|
]);
|
|
|
|
}).call(this);
|