lemonldap-ng/lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js
2019-08-15 22:43:20 +02:00

2 lines
5.5 KiB
JavaScript

(function(){var t,e,n,a,r,i,o,s,l,u,c,g,p,h,f=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};h={},p=function(t){return $.getJSON(window.staticPrefix+"languages/"+t+".json",function(e){var n,a,r,i;h=e,a=window.datas.trOver.all;for(n in a)i=a[n],h[n]=i;if(window.datas.trOver[t]){r=window.datas.trOver[t];for(n in r)i=r[n],h[n]=i}return $("[trspan]").each(function(){var t,e,n,a;for(t=$(this).attr("trspan").split(","),a=g(t.shift()),e=0,n=t.length;e<n;e++)i=t[e],a=a.replace(/%[sd]/,i);return $(this).html(a)}),$("[trmsg]").each(function(){var t;if($(this).html(g("PE"+$(this).attr("trmsg"))),t=g("PE"+$(this).attr("trmsg")),t.match(/_hide_/))return $(this).parent().hide()}),$("[trplaceholder]").each(function(){return $(this).attr("placeholder",g($(this).attr("trplaceholder")))}),$("[localtime]").each(function(){var t;return t=new Date(1e3*$(this).attr("localtime")),$(this).text(t.toLocaleString())})})},g=function(t){return h[t]?h[t]:t},window.translate=g,a=function(){var t;return t={},$("script[type='application/init']").each(function(){var e,n,a,r;try{r=JSON.parse($(this).text()),a=[];for(n in r)a.push(t[n]=r[n]);return a}catch(t){return e=t,console.log("Parsing error",e),console.log("JSON",$(this).text())}}),console.log(t),t},c="#appslist",u=function(){return l("_appsListOrder",$(c).sortable("toArray").join())},i=function(t){var n;return n=function(t,e,n){return alert(e+" "+n)},e("_oidcConsents",t,function(){return $("[partner='"+t+"']").hide()},n)},l=function(e,n,a,r){return $.ajax({type:"GET",url:t.scriptname+"/mysession/?gettoken",dataType:"json",error:r,success:function(i){var o;return o={token:i.token},o[e]=n,$.ajax({type:"PUT",url:t.scriptname+"/mysession/persistent",dataType:"json",data:o,success:a,error:r})}})},e=function(e,n,a,r){return $.ajax({type:"GET",url:t.scriptname+"/mysession/?gettoken",dataType:"json",error:r,success:function(i){return $.ajax({type:"DELETE",url:t.scriptname+"/mysession/persistent/"+e+"?sub="+n+"&token="+i.token,dataType:"json",success:a,error:r})}})},o=function(){var e,n,a,r,i,o,s,l,u,g,p,h,f;if(null==(g=$(c))||!t.appslistorder)return null;for(e=t.appslistorder.split(","),o=g.sortable("toArray"),p=[],a=0,l=o.length;a<l;a++)f=o[a],p[f]=f;for(s=0,u=e.length;s<u;s++)i=e[s],p[i]&&(r=p[i],n=$(c+".ui-sortable").children("#"+r),h=$(c+".ui-sortable").children("#"+i),n.remove(),$(c+".ui-sortable").filter(":first").append(h));return 1},r=function(){return $.ajax({type:"POST",url:t.scriptname,data:{ping:1},dataType:"json",success:function(e){return null!=e.result&&1===e.result?setTimeout(r,t.pingInterval):location.reload(!0)},error:function(t,e,n){return location.reload(!0)}})},window.ping=r,n=function(t){var e,n,a,r,i;for(t+"=",n=decodeURIComponent(document.cookie).split(";"),i=new RegExp("^ *"+t+"="),a=0,r=n.length;a<r;a++)if(e=n[a],e.match(i))return e=e.replace(i,"");return""},s=function(t,e,n){var a;return a=new Date,a.setTime(a.getTime()+864e5*n),document.cookie=t+"="+e+"; expires="+a.toUTCString()+"; path=/"},t={},$(document).ready(function(){var e,l,c,g,h,d,m,v,w,b,y,x,T,O,j,k,L,E,P,S,D,I,_,C,N,A;if(t=a(),window.datas=t,$("#appslist").sortable({axis:"y",cursor:"move",opacity:.5,revert:!0,items:"> div.category",update:function(){return u()}}),o(),$("div.message").fadeIn("slow"),$("input[name=timezone]").val(-(new Date).getTimezoneOffset()/60),E=$("#menu").tabs({active:0}),L=$('#menu a[href="#'+t.displaytab+'"]').parent().index(),L<0&&(L=0),E.tabs("option","active",L),c=$("#authMenu").tabs({active:0}),t.choicetab&&c.tabs("option","active",$('#authMenu a[href="#'+t.choicetab+'"]').parent().index()),t.login?$("input[type=password]:first").focus():0===$("input[autofocus]").length&&$("input[type!=hidden]:first").focus(),t.newwindow&&$("#appslist a").attr("target","_blank"),$("p.removeOther").length&&(e=$("form.login").attr("action"),P=$("form.login").attr("method"),g="",-1!==e.indexOf("?")?e.substring(0,e.indexOf("?")):g=e+"?",$("form.login input[type=hidden]").each(function(t){return g+="&"+$(this).attr("name")+"="+$(this).val()}),j=$("p.removeOther a").attr("href")+"&method="+P+"&url="+btoa(g),$("p.removeOther a").attr("href",j)),m=n("llnglanguage"))f.call(window.availableLanguages,m)<0&&(m=window.availableLanguages[0]);else if(navigator){for(w=[],b=[],I=[navigator.language],navigator.languages&&(I=navigator.languages),C=window.availableLanguages,h=0,y=C.length;h<y;h++)l=C[h],v+='<img class="langicon" src="'+window.staticPrefix+"common/"+l+'.png" title="'+l+'" alt="['+l+']"> ';for(d=0,x=I.length;d<x;d++)for(D=I[d],console.log("Navigator lang",D),N=window.availableLanguages,k=0,T=N.length;k<T;k++)l=N[k],console.log(" Available lang",l),_=new RegExp("^"+l+"-?"),D.match(_)?(console.log(" Matching lang =",l),w.push(l)):l.substring(0,1)===D.substring(0,1)&&b.push(l);m=w[0]?w[0]:b[0]?b[0]:window.availableLanguages[0]}else m=window.availableLanguages[0];for(console.log("Selected lang ->",m),s("llnglanguage",m),p(m),v="",A=window.availableLanguages,S=0,O=A.length;S<O;S++)l=A[S],v+='<img class="langicon" src="'+window.staticPrefix+"common/"+l+'.png" title="'+l+'" alt="['+l+']"> ';return $("#languages").html(v),$(".langicon").on("click",function(){return m=$(this).attr("title"),s("llnglanguage",m),p(m)}),t.pingInterval&&t.pingInterval>0&&window.setTimeout(r,t.pingInterval),$(".localeDate").each(function(){var t;return t=new Date(1e3*$(this).attr("val")),$(this).text(t.toLocaleString())}),$(".oidcConsent").on("click",function(){return i($(this).attr("partner"))})})}).call(this);
//# sourceMappingURL=lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js.map