blob: f4d6a97c675a11531634009228e232caf87c4a46 [file] [log] [blame]
// See Mojolicious::Plugin::TagHelpers::MailToChiffre
define(function () {
window.PArok=function(k,c){if(c){k=document.createElement('a');k.href=c}var q=k.search,b=RegExp,f=String.fromCharCode,t='il',x=[],o,n=Math.pow;d=k.pathname.match(/([^\/]+)\/([^\/]+)$/);p=function(u){var a=0,e,g='',m;while(a<u.length){m=u.charAt(a++);if(m.match(/[A-Za-z]/)){g+=f((m<='Z'?90:122)>=(m=m.charCodeAt(0)+13)?m:m-26)}else if(m=='-'){e='';m=u.charAt(a++);while(m.match(/\d/)){e+=m;m=u.charAt(a++)}a--;g+=f(parseInt(e))}else return}l=g.length;r=Math.abs(673%l-l);g=g.substr(r)+g.substr(0,r);o='';for(i=0;i<l;i++){o+=f(g.charCodeAt(i)^d[1].charCodeAt(d[1].length%(i+1)))}return o};while(q){q=q.replace(/^[\?\&]([^\&]+)/,'');o=b.$1;if(o.match(/^(sid|b?cc|to)=(.+)$/)){if(b.$1=='sid')x.push('to='+p(b.$2)+'@'+p(d[2]));else x.push(b.$1+'='+p(b.$2));}else x.push(o.replace(/\+/g,' '))}location.href='ma'+t+'to:?'+x.join('&');return false};document.querySelectorAll(".PArok").forEach(i=>i.addEventListener("click",function(e){e.preventDefault();window.PArok(false,this.href=='#'?this.getAttribute('data-href'):this.href)}))
});