1 line
2.6 KiB
JavaScript
1 line
2.6 KiB
JavaScript
(function(){var a;a=angular.module("llngConfDiff",["ui.tree","ui.bootstrap","llApp","ngCookies"]);a.controller("DiffCtrl",["$scope","$http","$q","$translator","$location",function(j,h,f,b,d){var c,k,g,e,i;j.links=links;j.menulinks=menulinks;j.staticPrefix=staticPrefix;j.scriptname=scriptname;j.availableLanguages=availableLanguages;j.waiting=true;j.showM=false;j.cfg=[];j.data={};j.translateTitle=function(l){return b.translateField(l,"title")};j.translateP=b.translateP;j.translate=b.translate;j.toggle=function(l){return l.toggle()};j.menuClick=function(l){if(l.popup){window.open(l.popup)}else{if(!l.action){l.action=l.title}switch(typeof l.action){case"function":l.action(j.currentNode,j);break;case"string":j[l.action]();break;default:console.log(typeof l.action)}}return j.showM=false};j.getLanguage=function(l){j.lang=l;j.init();return j.showM=false};c=function(l,o){var m;m=f.defer();if((j.cfg[l]==null)||j.cfg[l]!==o){h.get(""+confPrefix+o).then(function(n){var p;j.cfg[l]=n.data;p=new Date(n.data.cfgDate*1000);j.cfg[l].date=p.toLocaleString();console.log("Metadatas of cfg "+o+" loaded");return m.resolve("OK")},function(n){console.log(n);return m.reject("NOK")})}else{m.resolve()}return m.promise};k=function(){var l;j.message=null;l=f.defer();return h.get(scriptname+"diff/"+j.cfg[0].cfgNum+"/"+j.cfg[1].cfgNum).then(function(m){j.data=[];j.data=e(m.data[0],m.data[1]);return j.waiting=false},function(m){return j.message=(j.translate("error"))+" : "+m.statusLine})};e=function(q,p){var m,o,n,l;o=[];for(m in q){l=q[m];n={title:m};if(!m.match(/^cfg(?:Num|Log|Author(?:IP)?|Date)$/)){if(typeof l==="object"){if(l.constructor==="array"){n.oldvalue=l;n.newvalue=p[m]}else{if(typeof p[m]==="object"){n.nodes=e(q[m],p[m])}else{n.oldnodes=i(l,"old")}}}else{n.oldvalue=l;n.newvalue=p[m]}o.push(n)}}for(m in p){l=p[m];if(!((m.match(/^cfg(?:Num|Log|Author(?:IP)?|Date)$/))||(q[m]!=null))){n={title:m};if(typeof l==="object"){if(l.constructor==="array"){n.newvalue=l}else{n.newnodes=i(l,"new")}}else{n.newvalue=l}o.push(n)}}return o};i=function(q,p){var m,o,n,l;o=[];for(m in q){l=q[m];n={title:m};if(typeof l==="object"){if(l.constructor==="array"){n[p+"value"]=l}else{n[p+"nodes"]=i(q[m],p)}}else{n[p+"value"]=l}o.push(n)}return o};g=function(m,l,o){var p;p=l.match(new RegExp("#/(latest|[0-9]+)(?:/(latest|[0-9]+))?$"));if(p===null){d.path("/latest")}else{j.waiting=true;f.all([b.init(j.lang),c(0,p[1]),p[2]!=null?c(1,p[2]):void 0]).then(function(){if(p[2]!=null){return k()}else{if(j.cfg[0].prev){j.cfg[1]=j.cfg[0];return c(0,j.cfg[0].prev).then(function(){return k()})}else{j.message=j.translate("noDatas");return j.waiting=false}}})}return true};return j.$on("$locationChangeSuccess",g)}])}).call(this); |