1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
!function(){var L,t,z,E,_,j,M,R,D,e,N,u,U=[].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1},s={},A=function(e,t){var o=!1;return e?($("#"+t).addClass("fa-check text-success"),$("#"+t).removeClass("fa-times text-danger"),$("#"+t).attr("role","status")):($("#"+t).addClass("fa-times text-danger"),$("#"+t).removeClass("fa-check text-success"),$("#"+t).attr("role","alert"),o=!0),o},I=function(r){return $.getJSON(window.staticPrefix+"languages/"+r+".json",function(e){var t,o,a,n;for(t in s=e,o=window.datas.trOver.all)n=o[t],s[t]=n;if(window.datas.trOver[r])for(t in a=window.datas.trOver[r])n=a[t],s[t]=n;return $("[trspan]").each(function(){for(var e=$(this).attr("trspan").split(","),t=G(e.shift()),o=0,a=e.length;o<a;o++)n=e[o],t=t.replace(/%[sd]/,n);return $(this).html(t)}),$("[trmsg]").each(function(){if($(this).html(G("PE"+$(this).attr("trmsg"))),G("PE"+$(this).attr("trmsg")).match(/_hide_/))return $(this).parent().hide()}),$("[trplaceholder]").each(function(){var e=G($(this).attr("trplaceholder"));return $(this).attr("placeholder",e),$(this).attr("aria-label",e)}),$("[localtime]").each(function(){var e=new Date(1e3*$(this).attr("localtime"));return $(this).text(e.toLocaleString())})})},G=function(e){return s[e]||e};window.translate=G,_=function(){var a={};return $("script[type='application/init']").each(function(){var e,t,o;try{for(e in o=JSON.parse($(this).text()),t=[],o)t.push(a[e]=o[e]);return t}catch(e){return console.log("Parsing error",e),console.log("JSON",$(this).text())}}),console.log(a),a},E=function(e){e=RegExp("[?&]"+e+"=([^&]*)").exec(window.location.search);return e?decodeURIComponent(e[1].replace(/\+/g," ")):null},u="#appslist",N=function(){return e("_appsListOrder",$(u).sortable("toArray").join())},M=function(e){return t("_oidcConsents",e,function(){return $("[partner='"+e+"']").hide()},function(e,t,o){return alert(t+" "+o)})},e=function(t,o,a,n){return $.ajax({type:"GET",url:L.scriptname+"/mysession/?gettoken",dataType:"json",error:n,success:function(e){e={token:e.token};return e[t]=o,$.ajax({type:"PUT",url:L.scriptname+"/mysession/persistent",dataType:"json",data:e,success:a,error:n})}})},t=function(t,o,a,n){return $.ajax({type:"GET",url:L.scriptname+"/mysession/?gettoken",dataType:"json",error:n,success:function(e){return $.ajax({type:"DELETE",url:L.scriptname+"/mysession/persistent/"+t+"?sub="+o+"&token="+e.token,dataType:"json",success:a,error:n})}})},R=function(){var e,t,o,a,n,r,s,i,l,c,d=$(u);if(null==d||!L.appslistorder)return null;for(e=L.appslistorder.split(","),i=[],a=0,n=(o=d.sortable("toArray")).length;a<n;a++)i[c=o[a]]=c;for(s=0,r=e.length;s<r;s++)i[l=e[s]]&&(t=i[l],t=$(u+".ui-sortable").children("#"+t),l=$(u+".ui-sortable").children("#"+l),t.remove(),$(u+".ui-sortable").filter(":first").append(l));return 1},j=function(){return $.ajax({type:"POST",url:L.scriptname,data:{ping:1},dataType:"json",success:function(e){return null!=e.result&&1===e.result?setTimeout(j,L.pingInterval):location.reload(!0)},error:function(e,t,o){return location.reload(!0)}})},window.ping=j,z=function(e){for(var t,o=decodeURIComponent(document.cookie).split(";"),a=new RegExp("^ *"+e+"="),n=0,r=o.length;n<r;n++)if((t=o[n]).match(a))return t=t.replace(a,"");return""},D=function(e,t,o,a){var n=new Date;return n.setTime(n.getTime()+864e5*a),document.cookie=e+"="+t+"; expires="+n.toUTCString()+"; path=/; SameSite="+o},L={},$(window).on("load",function(){var e,t,o,a,n,d,r,s,u,p,g,f,w,h,m,y,i,v,b,k,x,l,T,C,S,O,P,c;if(L=_(),"datas"in window&&"choicetab"in window.datas&&(L.choicetab=window.datas.choicetab),window.datas=L,$("#appslist").sortable({axis:"y",cursor:"move",opacity:.5,revert:!0,items:"> div.category",update:N}),R(),$("div.message").fadeIn("slow"),$("input[name=timezone]").val(-(new Date).getTimezoneOffset()/60),c=$("#menu").tabs({active:0}),i=$('#menu a[href="#'+L.displaytab+'"]').parent().index(),c.tabs("option","active",i=i<0?0:i),c=$("#authMenu").tabs({active:0}),i=$('#authMenu a[href="#'+L.displaytab+'"]').parent().index(),c.tabs("option","active",i=i<0?0:i),L.choicetab&&c.tabs("option","active",$('#authMenu a[href="#'+L.choicetab+'"]').parent().index()),L.login?$("input[type=password]:first").focus():0===$("input[autofocus]").length&&$("input[type!=hidden]:first").focus(),L.newwindow&&$("#appslist a").attr("target","_blank"),$("p.removeOther").length&&(i=$("#form").attr("action"),c=$("#form").attr("method"),console.log("method=",c),n="",$("#form input[type=hidden]")&&(console.log("Parse hidden values"),$("#form input[type=hidden]").each(function(e){return console.log(" ->",$(this).attr("name"),$(this).val()),n+="&"+$(this).attr("name")+"="+$(this).val()})),o="",i&&(console.log("action=",i),-1!==i.indexOf("?")?i.substring(0,i.indexOf("?")):o=i+"?",o+=n,n=""),i=$("p.removeOther a").attr("href")+"&method="+c+n,o&&(i+="&url="+btoa(o)),$("p.removeOther a").attr("href",i)),window.location.search&&((l=E("llnglanguage"))&&console.log("Get lang from parameter"),1===(P=E("setCookieLang"))&&console.log("Set lang cookie")),s||(s=z("llnglanguage"))&&!l&&console.log("Get lang from cookie"),s)U.call(window.availableLanguages,s)<0&&(s=window.availableLanguages[0],l||console.log("Lang not available -> Get default lang"));else if(navigator){for(p=[],g=[],k=[navigator.language],navigator.languages&&(k=navigator.languages),r=0,f=(C=window.availableLanguages).length;r<f;r++)e=C[r],u+='<img class="langicon" src="'+window.staticPrefix+"common/"+e+'.png" title="'+e+'" alt="['+e+']"> ';for(y=0,w=k.length;y<w;y++)for(b=k[y],console.log("Navigator lang",b),v=0,h=(S=window.availableLanguages).length;v<h;v++)e=S[v],console.log(" Available lang",e),T=new RegExp("^"+e+"-?"),b.match(T)?(console.log(" Matching lang =",e),p.push(e)):e.substring(0,1)===b.substring(0,1)&&g.push(e);(s=p[0]||g[0]||window.availableLanguages[0])&&!l&&console.log("Get lang from navigator")}else(s=window.availableLanguages[0])&&!l&&console.log("Get lang from window");for(l?(U.call(window.availableLanguages,l)<0&&(console.log("Lang not available -> Get default lang"),l=window.availableLanguages[0]),console.log("Selected lang ->",l),P&&(console.log("Set cookie lang ->",l),D("llnglanguage",l,L.sameSite)),I(l)):(console.log("Selected lang ->",s),D("llnglanguage",s,L.sameSite),I(s)),u="",x=0,m=(O=window.availableLanguages).length;x<m;x++)e=O[x],u+='<img class="langicon" src="'+window.staticPrefix+"common/"+e+'.png" title="'+e+'" alt="['+e+']"> ';return $("#languages").html(u),$(".langicon").on("click",function(){return s=$(this).attr("title"),D("llnglanguage",s,L.sameSite),I(s)}),d=function(e){e=e.charCodeAt(0);return 47<e&&e<58||64<e&&e<91||96<e&&e<123},t=function(e){var t,o,a,n,r,s,i=!0;if(0<window.datas.ppolicy.minsize&&A(e.length>=window.datas.ppolicy.minsize,"ppolicy-minsize-feedback")&&(i=!1),0<window.datas.ppolicy.minupper&&(s=e.match(/[A-Z]/g),A(s&&s.length>=window.datas.ppolicy.minupper,"ppolicy-minupper-feedback")&&(i=!1)),0<window.datas.ppolicy.minlower&&(s=e.match(/[a-z]/g),A(s&&s.length>=window.datas.ppolicy.minlower,"ppolicy-minlower-feedback")&&(i=!1)),0<window.datas.ppolicy.mindigit&&(s=e.match(/[0-9]/g),A(s&&s.length>=window.datas.ppolicy.mindigit,"ppolicy-mindigit-feedback")&&(i=!1)),window.datas.ppolicy.allowedspechar){for(n=window.datas.ppolicy.allowedspechar.replace(/\s/g,""),t=!1,o=0,a=e.length;o<a;)d(e.charAt(o))||n.indexOf(e.charAt(o))<0&&(t=!0),o++;A(!1===t,"ppolicy-allowedspechar-feedback")&&(i=!1)}if(0<window.datas.ppolicy.minspechar&&window.datas.ppolicy.allowedspechar){for(r=0,n=window.datas.ppolicy.allowedspechar.replace(/\s/g,""),o=0;o<e.length;)0<=n.indexOf(e.charAt(o))&&r++,o++;A(r>=window.datas.ppolicy.minspechar,"ppolicy-minspechar-feedback")&&(i=!1)}if(0<window.datas.ppolicy.minspechar&&!window.datas.ppolicy.allowedspechar){for(o=r=0;o<e.length;)d(e.charAt(o))||r++,o++;A(r>=window.datas.ppolicy.minspechar,"ppolicy-minspechar-feedback")&&(i=!1)}i?($(".ppolicy").removeClass("border-danger").addClass("border-success"),null!=(s=$("#newpassword").get(0))&&s.setCustomValidity("")):($(".ppolicy").removeClass("border-success").addClass("border-danger"),null!=(i=$("#newpassword").get(0))&&i.setCustomValidity(G("PE28")))},null!=window.datas.ppolicy&&$("#newpassword").length&&(t(""),$("#newpassword").keyup(function(e){t(e.target.value)})),c=function(e){return e.target.checked?($("#newpassword").off("keyup"),null!=(e=$("#newpassword").get(0))?e.setCustomValidity(""):void 0):($("#newpassword").keyup(function(e){t(e.target.value)}),t(""))},o=function(){var e;return(null!=(e=$("#confirmpassword").get(0))?e.value:void 0)===(null!=(e=$("#newpassword").get(0))?e.value:void 0)?(null!=(e=$("#confirmpassword").get(0))&&e.setCustomValidity(""),!0):(null!=(e=$("#confirmpassword").get(0))&&e.setCustomValidity(G("PE34")),!1)},$("#newpassword").change(o),$("#confirmpassword").change(o),null!=window.datas.ppolicy&&$("#newpassword").length&&$("#reset").change(c),L.enablePasswordDisplay&&(a="",L.dontStorePassword?($(".toggle-password").mousedown(function(){return a=(a=$(this).attr("id")).replace(/^toggle_/,""),console.log("Display",a),$(this).toggleClass("fa-eye fa-eye-slash"),$("input[name="+a+"]").attr("class","form-control")}),$(".toggle-password").mouseup(function(){if($(this).toggleClass("fa-eye fa-eye-slash"),$("input[name="+a+"]").get(0).value)return $("input[name="+a+"]").attr("class","form-control key")})):($(".toggle-password").mousedown(function(){return a=(a=$(this).attr("id")).replace(/^toggle_/,""),console.log("Display",a),$(this).toggleClass("fa-eye fa-eye-slash"),$("input[name="+a+"]").attr("type","text")}),$(".toggle-password").mouseup(function(){return $(this).toggleClass("fa-eye fa-eye-slash"),$("input[name="+a+"]").attr("type","password")}))),L.pingInterval&&0<L.pingInterval&&window.setTimeout(j,L.pingInterval),$(".localeDate").each(function(){var e=new Date(1e3*$(this).attr("val"));return $(this).text(e.toLocaleString())}),$(".oidcConsent").on("click",function(){return M($(this).attr("partner"))}),$("#passwordfield").on("input",function(){return $("#passwordfield").get(0).value&&L.dontStorePassword?$("#passwordfield").attr("class","form-control key"):$("#passwordfield").attr("class","form-control")}),$("#oldpassword").on("input",function(){return $("#oldpassword").get(0).value&&L.dontStorePassword?$("#oldpassword").attr("class","form-control key"):$("#oldpassword").attr("class","form-control")}),$("#newpassword").on("input",function(){return $("#newpassword").get(0).value&&L.dontStorePassword?$("#newpassword").attr("class","form-control key"):$("#newpassword").attr("class","form-control")}),$("#confirmpassword").on("input",function(){return $("#confirmpassword").get(0).value&&L.dontStorePassword?$("#confirmpassword").attr("class","form-control key"):$("#confirmpassword").attr("class","form-control")}),$(".clear-finduser-field").on("click",function(){return $(this).parent().find(":input").each(function(){return console.log("Clear search field ->",$(this).attr("name")),$(this).val("")})}),$("#closefinduserform").on("click",function(){return console.log("Clear modal"),$("#finduserForm").trigger("reset")}),$("#finduserbutton").on("click",function(e){return e.preventDefault(),document.body.style.cursor="progress",e=$("#finduserForm").serialize(),console.log("Send findUser request with parameters",e),$.ajax({type:"POST",url:portal+"finduser",dataType:"json",data:e,success:function(e){var t;if(document.body.style.cursor="default",t=e.user,console.log("Suggested spoofId=",t),$("input[name=spoofId]").each(function(){return $(this).val(t)}),e.captcha&&$("#captcha").attr("src",e.captcha),e.token)return $("#finduserToken").val(e.token),$("#token").val(e.token)},error:function(e,t,o){var a;if(document.body.style.cursor="default",o&&console.log("Error",o),(a=e?JSON.parse(e.responseText):a)&&a.error)return console.log("Returned error",a)}})}),$("#btn-back-to-top").on("click",function(){return console.log("Back to top"),document.body.scrollTop=0,document.documentElement.scrollTop=0}),$(window).on("scroll",function(){return L.scrollTop&&(document.body.scrollTop>Math.abs(L.scrollTop)||document.documentElement.scrollTop>Math.abs(L.scrollTop))?$("#btn-back-to-top").css("display","block"):$("#btn-back-to-top").css("display","none")})})}.call(this); |