/*jslint
browser:true
*/
/*eslint
operator-linebreak:["warn","before"]
*/
/*global
document,
console,
DOMParser,
*/
/*
version:1.2.6+
*/
function sealInit(){
'use strict';
var imgurl='https://siegel.siwecos.de/';
var imgext='.svg';
var svg=document.getElementById('siwecos-seal');
var sealgraphics=new DOMParser().parseFromString('','application/xml');
var siwecoslink=null;
var domain=null;
var format=null;
var img=null;
if(svg===null){console.log('Missing ');
}else{
svg.appendChild(sealgraphics.firstChild);
siwecoslink=svg;
if(typeof siwecoslink.dataset==='object'&&typeof siwecoslink.dataset.format==='string'){
format=siwecoslink.dataset.format;
}else{format='';}
while(siwecoslink.parentNode!==null){
if(siwecoslink.nodeName==='A'){
domain=siwecoslink.getAttribute('href');
if(domain!==null){
if(domain.match(/\s/)){break;}
if(format===''){
format=domain.replace(/^\S*[?&]format=(\S*?)(?:&\S*)?$/,'$1');
if(format===domain){
format='';
}
}
format=format.replace(/[^.\/dmy-]/g,'');
if(format===null||format!=='y-m-d'){format='d.m.y';}
if(imgurl.charAt(0)==='/'){
imgurl=domain.replace(/^(https?:\/\/(\S*?))\/\S*$/,'$1')+imgurl;
}
domain=domain.replace(/^\S*[?&]data-siwecos=(\S*?)(?:&\S*)?$/,'$1');
img=document.createElement('img');
break;
}
}
siwecoslink=siwecoslink.parentNode;
}
if(img!==null){
img.addEventListener('load',function(){
svg.parentNode.replaceChild(img,svg);
});
img.addEventListener('error',function(){
console.log('error');
});
img.width=svg.getBoundingClientRect().width;
img.src=imgurl+domain+'/'+format+imgext;
}
}
}
sealInit();