UNPKG

@aliconnect/sdk

Version:
4 lines 137 kB
/** Last modified 2021-09-21 10:11:29 */ console.log('elem');eol='\n';function url_string(s=''){return s.replace(/%2F/g,'/')}function checkPath(e){let elem;if(elem=e.path.find(elem=>elem.item)){e.itemElement=elem;e.item=e.itemElement.item}}function linkify(inputText){var replacedText,replacePattern1,replacePattern2,replacePattern3;replacePattern1=/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;replacedText=inputText.replace(replacePattern1,'<a href="$1" target="_blank">$1</a>');replacePattern2=/(^|[^\/])(www\.[\S]+(\b|$))/gim;replacedText=replacedText.replace(replacePattern2,'$1<a href="http://$2" target="_blank">$2</a>');replacePattern3=/(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;replacedText=replacedText.replace(replacePattern3,'<a href="mailto:$1">$1</a>');return replacedText}(function web(){function handleData(targetItem,e){if(document.activeElement.isContentEditable||['INPUT'].includes(document.activeElement.tagName)){return}console.log('web.js.handleData',e,e.view===window);if(targetItem){console.log(targetItem);const eventData=e.dataTransfer||e.clipboardData;const type=$.his.keyEvent&&$.his.keyEvent.shiftKey?'link':e.type;let data;if(eventData.types.includes('Files')){e.preventDefault();e.stopPropagation();const files=[...eventData.files];const xls=files.find(file=>file.name.includes('.xls'));if(xls){return importXlsFile(xls)}files.forEach(targetItem.elemFiles.appendFile)}else if(data=eventData.getData("Aim/items")){data=JSON.parse(data);data.type=data.type||(e.ctrlKey?'copy':'cut');data.target=targetItem.tag;if(data.value){const targetItem=Item.get(data.target);console.log(data,targetItem,data.value);if(data.type==='cut'){const parent=targetItem;data.value.forEach(item=>$.link({name:'Master',item:item,to:targetItem,current:item.Master,index:99999,action:'move'}))}else if(data.type==='copy'){const items=[];(async function copy(item){if(item)items.push(item);const source=data.value.shift();if(source)return await $().copyFrom(source,targetItem).then(copy);item=items.shift();$().tree().setFocusElement(item.elemTreeLi.elem);item.edit()})()}}if(data.files){if(type==='cut'){data.files.forEach(ofile=>{console.warn('cut',ofile)})}else if(type==='copy'){data.files.forEach(ofile=>{console.warn('copy',ofile)})}}e.preventDefault();e.stopPropagation()}else if(data=eventData.getData("text/html")){var tmpStr=data.match("<!--StartFragment-->(.*)<!--EndFragment-->");var fragment=tmpStr[1];if(fragment.substr(0,3)=='<a>'){console.debug('REF',fragment)}else if(fragment.substr(0,5)=='<img '){console.debug('IMG',fragment)}}else if(data=eventData.getData("text")){if(data.substr(0,4)=='http'){}}}$.clipboard.dragItems=[]}function eventKeyState(e){return e?(e.shiftKey&&e.ctrlKey?'link':(e.shiftKey?'move':(e.ctrlKey?'copy':'default'))):'default'}function handleEvent(e){if(e){if(e.body){console.error('handleEvent',e.body);$.extend(e.body);if($.config_url){let res=new XMLHttpRequest();res.open('get',$.config_url);res.onload=e=>$.url('https://aliconnect.nl/v1beta1/api?request_type=yamlToJson',e.target.response).post().then(handleEvent);res.send();$.config_url=null;return}$().emit('config');new $.WebsocketRequest()}if(e.type==='connect'&&e.socket_id&&$.his.cookie.id_token){uploadState({type:'focus'})}}connectState++;if(connectState===2){if(window.addEventListener){window.addEventListener('focus',uploadState);window.addEventListener('blur',uploadState)}$.auth.init();if($.webinit){$.webinit()}}};function checkkey(e){const path=$.his.clickEvent?[...$.his.clickEvent.path]:[];path.push($);path.forEach(elem=>{const keys=elem[e.type];if(keys&&keys[e.keyPressed]){keys[e.keyPressed].call(elem,e)}})}function onkey(e){window.event=e;e.keyPressed=[ e.ctrlKey?'ctrl_':'',e.shiftKey?'shift_':'',e.altKey?'alt_':'',e.code].join('');$.his.keyEvent=null;clearTimeout($.his.keydownTimeout);clearTimeout($.his.keyupTimeout);clearTimeout($.his.keybufferTimeout);$.his.keybufferTimeout=setTimeout(()=>$.his.keybuffer=[],300);$.his.keybuffer=$.his.keybuffer||[];$.his.keybuffer.push(e.key);e.keybuffer=$.his.keybuffer;checkPath(e);if($.his.clickEvent){e.itemElement=e.itemElement||$.his.clickEvent.itemElement;e.item=e.item||$.his.clickEvent.item;e.clickEvent=$.his.clickEvent}}function loadStoredCss(){const css=JSON.parse(localStorage.getItem('css'))||{};for(let [id,param] of Object.entries(css)){let selector=id==='_body'?document.body:document.getElementById(id);if(selector){selector.style.cssText+=Object.entries(param).map(entry=>entry.join(':')).join(';')}}}function importScript(src){return $.promise('script',callback=>{function loaded(e){e.target.loading=false;for(let [key,value] of Object.entries(e.target)){if(typeof value==='function'){Elem.prototype[key]=value}}callback()}for(let script of [...document.getElementsByTagName('SCRIPT')]){if(script.getAttribute('src')===src){if(script.loading){return $(script).on('load',loaded)}return callback()}}var el=$('script').src(src).parent(document.head).on('load',loaded);el.elem.loading=true})}const libraries=Aim.libraries={start(){return;if($.user)$().dashboard();else $().home()},sw(){if('serviceWorker'in navigator){navigator.serviceWorker.addEventListener('message',e=>{console.log('MESSAGE',e);if(e.data&&e.data.url){const url=new URL(e.data.url);document.location.href='#'+url.pathname+url.search}});navigator.serviceWorker.register('sw.js',{scope:'/'}).then(function(registration){$().sw=registration;return;registration.pushManager.subscribe({userVisibleOnly:true}).then(function(sub){const channel=new BroadcastChannel('sw-messages');channel.addEventListener('message',e=>{console.log('Received',e.data)});console.log('SW',sub);$().sw.active.postMessage(JSON.stringify({hostname:document.location.hostname}))})}).catch(function(error){})}},om(){},loadclient(){$().on({load(){if($().script&&$().script.src){const el=document.createElement('script');el.src=$().script.src;document.head.appendChild(el)}}})},getstarted(){$().on({async ready(){libraries.start()}})}};function Elem(elem){const args=[...arguments];elem=this.elem=args.shift();this.elem.selector=this.elem.is=this;this.map=new Map();if(args.length){if(typeof this[elem.id]==='function'){this[elem.id](...args)}else{args.forEach(arg=>{if(arg instanceof Object){Object.assign(elem,arg)}else if(typeof arg==='string'){if('className'in this){this.innerHTML=elem.innerHTML=arg}else if(this.className=arg){elem.className=arg}}})}}};Object.defineProperties(Elem,{tagnames:{value:['a','abbr','address','area','article','aside','audio','b','base','bdi','bdo','blockquote','body','br','button','canvas','caption','cite','code','col','colgroup','data','datalist','dd','del','details','dfn','dialog','div','dl','dt','em','embed','fieldset','figcaption','figure','footer','form','h1','h2','h3','h4','h5','h6','head','header','hgroup','hr','html','i','iframe','img','input','ins','kbd','label','legend','li','link','main','map','mark','menu','meta','meter','nav','noscript','object','ol','optgroup','option','output','p','param','picture','pre','progress','q','rp','rt','ruby','s','samp','script','section','select','slot','small','source','span','strong','style','sub','summary','sup','table','tbody','td','template','textarea','tfoot','th','thead','time','title','tr','track','u','ul','var','video','wbr']}});Object.defineProperties(Elem.prototype,{append:{value:function(){this.elem=this.elem||document.body;Array.from(arguments).forEach(arg=>{if(typeof arg==='string'){this.elem.append(document.createTextNode(arg))}else if(Array.isArray(arg)){arg.forEach(arg=>this.append(arg))}else if(arg instanceof Elem){this.elem.append(arg.elem)}else if(arg){this.elem.append(arg)}});return this}},accept_scope:{value:function(scope,socket_id){const properties=Object.fromEntries(scope.map(val=>[val,{name:val,format:'checkbox',checked:1}]));properties.expire_time={format:'number',value:3600};const form=$().promptform($().url(AUTHORIZATION_URL).query('socket_id',socket_id),this.elem,arguments.callee.name,{properties:properties,btns:{deny:{name:'accept',value:'deny',type:'button'},allow:{name:'accept',value:'allow',type:'submit',default:true}}})}},attr:{value:function(selector,context,save){if(save&&this.elem.id){$.localAttr.set(this.elem.id,selector,context)}if(selector){if(typeof selector==='object'){Object.entries(selector).forEach(entry=>this.attr(...entry))}else{if(arguments.length===1){return this.elem.getAttribute(selector)}else if(context===null||context===undefined){this.elem.removeAttribute(selector)}else if(typeof context==='function'){this.on(selector,context)}else if(typeof context==='object'){this.elem[selector]=context}else{this.elem.setAttribute(selector,[].concat(context).join(' '))}}}return this}},assign:{value:function(selector,context){if(typeof selector==='string'){this.elem[selector]=context}else if(selector instanceof Object){Object.assign(this.elem,context)}return this}},btns:{value:function(selector,context){const elem=$('div').parent(this).class('row btns');function btn(selector,context){if(typeof selector==='object'){return Object.entries(selector).forEach(entry=>btn(...entry))}$(context.href?'a':'button').parent(elem).class('abtn').name(selector).caption(selector).attr(context)}[].concat(...arguments).forEach(selector=>typeof selector!=='object'?null:(selector.name?btn(selector.name,selector):Object.entries(selector).forEach(entry=>btn(...entry))));return this}},cam:{value:function(){const video=this.video=$('video').parent(this).autoplay().on('click',e=>{if(video.paused){video.play()}else{video.pause()}}).elem;if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){navigator.mediaDevices.getUserMedia({video:true}).then(stream=>{try{video.srcObject=stream}catch(error){video.src=window.URL.createObjectURL(stream)}video.play()})}return this}},cancel:{value:function(){this.elem.innerText}},caption:{value:function(){return this.attr('caption',__(...arguments))}},calendar:{value:function(data){new Calendar(data,this);return this}},chat:{value:function(selector,context){const $chat=this.sections.get('chat',selector=>{$().main().append(selector=$('section').id('chat-room').append($('div').id('videos').append($('video').id('self-view').attr('autoplay',''),$('video').id('remote-view').attr('autoplay',''))));return selector});return this}},checkbox:{value:function(){const property=Object.assign({},...arguments);const id='checkbox'+($.his.checkboxInt=$.his.checkboxInt?++$.his.checkboxInt:1);return [ this.class('check').attr('id',id).value(property.value).name(property.name).disabled(property.disabled).checked(property.checked),$('label').class('aco').for(id).append($('span').ttext(property.Title||property.title||property.name)),$('span').text(property.cnt)]}},children:{get(){return Array.from(this.elem.children).map(el=>$(el))}},class:{value:function(className){this.elem.className=[...arguments].join(' ').trim();return this}},code:{value:function(content,format){this.class('code');if(typeof content==='function'){format='js';content=String(content).replace(/^(.*?)\{|\}$/g,'')}content=format&&$.string[format]?$.string[format](content):content;this.elem.innerHTML=content;return this}},contextmenu:{value:function(menu){menu=$.extend({},...arguments);if(!menu.items)console.warn('no items',menu);const menuitems=new Map(Object.entries(menu.items));this.tabindex(0);this.on('keydown',e=>{[...menuitems.entries()].filter(([name,menuitem])=>menuitem.key===e.keyPressed&&menuitem.on&&menuitem.on.click).forEach(([name,menuitem])=>menuitem.on.click(e))});return this;this.on('contextmenu',e=>{e.preventDefault(e.stopPropagation());console.log(menu);const targetElement=this.elem;const targetRect=targetElement.getBoundingClientRect();var top=targetRect.bottom;if('left'in menu){var left=menu.left}else if('right'in menu){var left=menu.right-menuElement.clientWidth}else{var left=e.clientX;var top=e.clientY}this.close=e=>{window.removeEventListener('contextmenu',this.close,true);window.removeEventListener('click',this.close,true);window.removeEventListener('keydown',this.onKeydown,true);this.elemPopup.remove()};window.addEventListener('keydown',this.onKeydown=e=>e.key==='Escape'?this.close(e):null,true);window.addEventListener('click',this.close,true);this.elemPopup=$('div').parent(document.body).class('col popup').css('top',top+'px').css('left',Math.max(0,left)+'px').css('max-height',(window.screen.availHeight-top)+'px').append([...menuitems.entries()].map(([name,menuitem])=>$('div').class('row abtn icn').extend(menuitem).extend({srcEvent:e})));return;if(this.handlers.menuElement){this.handlers.menuElement.remove()}if(targetElement.popupmenu){targetElement.right=0}menuElement.innerText='';for(let [menuname,menuitem] of Object.entries(menuItems)){if(menuitem.hidden)continue;var linkElement=menuElement.createElement('A',{name:menuname,value:menuname,elMenu:menuElement,left:5,menuitem:menuitem,popupmenu:menuitem.menu,onclick:menuitem.onclick||(this.menu?this.menu.onclick:null)||targetElement.onselect||function(e){e.stopPropagation()},onmouseenter:this.enter},menuitem,{className:'row abtn icn '+(menuitem.className||menuname)});if(menuitem.color){linkElement.createElement('icon',{}).style='background-color:'+menuitem.color}linkElement.createElement('SPAN','aco',__(menuitem.header0||menuname));if(menuitem.key){linkElement.createElement('SPAN','',menuitem.key)}};var top=targetRect.bottom;if('left'in targetElement){var left=pos.left}else if('right'in targetElement){var left=targetRect.right-menuElement.clientWidth,top=targetRect.bottom}else{var left=e.clientX,top=e.clientY}left=Math.max(0,left);menuElement.style.left=left+'px';menuElement.style.top=top+'px';menuElement.style.maxHeight=(window.screen.availHeight-top)+'px'});return this}},messagesPanel:{value:function(){this.append($('div').class('col err').append($('div').class('row err hdr').append($('span').class('').text(''),$('span').class('').text('System'),$('span').class('aco').text('Message'),$('span').class('time').text('Start'),$('span').class('time').text('Accept'),$('span').class('time').text('End')),$().elemMessages=$('div').class('col aco')));return this}},css:{value:function(selector,value){const args=[...arguments];const elem=this.elem||this.selector;if(selector instanceof Object){Object.entries(selector).forEach(entry=>arguments.callee.call(this,...entry))}else{const css=elem.style.cssText.split(';').filter(s=>s.trim()).filter(s=>s.split(':')[0].trim()!==selector);if(value===''){css.push(selector)}else if(value===null){}else{css.push(`${selector}:${value}`)}elem.style.cssText=css.join(';')}return this}},dark:{value:function(){if($().storage('dark')===null){setTimeout(()=>{const h=new Date().getHours();$(document.documentElement).attr('dark',h>=20||h<=7?1:0)},5000)}else{$(document.documentElement).attr('dark',$().storage('dark'))}if(this.elem.tagName==='A'){this.on('click',e=>$(document.documentElement).attr('dark',$().storage('dark',$().storage('dark')^1).storage('dark')))}return this}},displayvalue:{value:function(selector){if(this.elem.item){this.text(this.elem.item.displayvalue(selector))}return this}},draw:{value:function(options){this.paint=new Paint(this.elem,options);return this}},insertBefore:{value:function(newNode,referenceNode){console.log(newNode,referenceNode);this.elem.insertBefore(newNode.elem||newNode,referenceNode?referenceNode.elem||referenceNode:null)}},extend:{value:function(){$.extend(this,...arguments);return this}},edit:{value:function(item){console.log('EDIT',item);item.editing=true;item.onloadEdit=false;function stopVideo(){var c=document.getElementsByTagName('video');for(var i=0,e;e=c[i];i++){e.pause()}}function users(){return;return ['A','c '+row.ID,row.Value||($.getItem(row.tag)?$.getItem(row.tag).Title:row.ID),{onclick:Web.Element.onclick,id:row.ID},[ ['BUTTON',{type:'BUTTON',row:row,onclick:$.removeUser=(e)=>{e.preventDefault();e.stopPropagation();new $.HttpRequest($.config.$,'DELETE',`/${this.tag}/Users(${e.target.row.ID})`,e=>{}).send();e.target.parentElement.remove();inputElement.focus();return false}}] ]]}item.elemFiles=$('div').files(item,'Files');function openDialog(accept){$('input').type('file').multiple(true).accept(accept).on('change',e=>{if(e.target.files){[...e.target.files].forEach(item.elemFiles.appendFile)}}).click().remove()}const buttons={attach:()=>openDialog(''),image:()=>openDialog('image/*'),camera:()=>{const panelElem=$('div').parent(document.querySelector('#section_main')).class('col aco abs panel').append($('nav').class('row top abs btnbar np').append($('span').class('aco'),$('button').class('abtn freedraw').on('click',this.openFreedraw=e=>{window.event.stopPropagation();buttons.freedraw().canvas.context.drawImage(this.cam.video,0,0,this.canvas.width,this.canvas.height);return this}),$('button').class('abtn save').on('click',e=>{window.event.stopPropagation();this.openFreedraw().save().closeFreedraw()}),$('button').class('abtn close').on('click',this.closeCam=e=>panelElem.remove())),this.cam=$('div').class('aco').cam())},freedraw:()=>{const panelElem=$('div').parent(document.querySelector('#section_main')).class('col aco abs panel').append($('nav').class('row top abs btnbar np').append($('span').class('aco'),$('button').class('abtn clean').on('click',e=>{this.canvas.context.clearRect(0,0,this.canvas.width,this.canvas.height)}),$('button').class('abtn save').on('click',this.save=e=>{window.event.stopPropagation();this.canvas.toBlob(blob=>{item.elemFiles.appendFile(new File([blob],`image.png`))});return this}),$('button').class('abtn close').on('click',this.closeFreedraw=e=>panelElem.remove())),this.canvasElem=$('canvas').width(640).height(480).draw());this.canvas=this.canvasElem.elem;return this},close(){$().send({body:{notify:{title:`${item.header0} modified`,options:{body:`Bla Bla`,icon:'https://aliconnect.nl/favicon.ico',image:'https://aliconnect.nl/shared/265090/2020/07/09/5f0719fb8fa69.png',data:{url:document.location.href}}}}});return $('view').show(item)}};const edit=$('div').parent(this).class('col aco abs').append($('nav').class('row top abs btnbar np').append($('span').class('aco'),Object.entries(buttons).map(([name,fn])=>$('button').class('abtn',name).on('click',fn))),this.header(item),$('form').class('oa aco').append(item.elemFiles).properties(item.properties));return this}},markup:{value:function(el){const replace={yaml(str){return str.replace(/\n/g,'').replace(/^(.*?)(#.*?|)$/,(s,codeString,cmt)=>{return codeString.replace(/^(\s*)(.+?):/,'$1<span class="hl-fn">$2</span>:').replace(/: (.*?)$/,': <span class="hl-string">$1</span>')+(cmt?`<span class=hl-cmt>${cmt}</span>`:'')})}};this.elem.innerHTML=replace.yaml(this.elem.innerText);this.elem.markup=true;return this}},editor:{value:function(lang){this.class('code-editor');const his=[];const elem=this.elem;const rectContainer=this.elem.getBoundingClientRect();const html=lang?$.string[lang](elem.innerText):elem.innerText;let rows;let selLine;function toggleOpen(el,open){if(open===-1){return s.removeAttribute('open')}if(el.hasAttribute('open')){open=open===undefined?el.getAttribute('open')^1:open;el.setAttribute('open',open);for(var s=el.nextSibling;s;s=s.nextSibling){if(s.level<=el.level)break;if(open){if(s.level<=el.level+2){s.removeAttribute('hide')}}else{s.setAttribute('hide','');if(s.hasAttribute('open')){s.setAttribute('open',0)}}}}}this.on('click',e=>{if(e.offsetX<0){toggleOpen(e.target)}});function checkOpen(el,open=1){if(!el)return;el.level=el.innerText.search(/\S/);if(el.nextSibling){el.nextSibling.level=el.nextSibling.innerText.search(/\S/);if(el.nextSibling.level>el.level){if(!el.hasAttribute('open')){el.setAttribute('open',open)}}else if(el.hasAttribute('open')){el.removeAttribute('open')}}else if(el.hasAttribute('open')){el.removeAttribute('open')}}this.text=content=>{this.elem.innerText='';this.append(content.split(/\n/).map(l=>$('div').text(l).markup()));this.append($('div').html('<br>'));var children=Array.from(this.elem.children);children.forEach(el=>{checkOpen(el,0);if(el.level>0)el.setAttribute('hide','')})};this.src=url=>{};function caret(el){const range=window.getSelection().getRangeAt(0);const prefix=range.cloneRange();prefix.selectNodeContents(el);prefix.setEnd(range.endContainer,range.endOffset);return prefix.toString().length}function getNode(parent,pos){if(parent.childNodes){for(var node of parent.childNodes){if(node.nodeType==Node.TEXT_NODE){if(pos<=node.length){return [node,pos,true]}else{pos=pos-node.length}}else{var [node,pos,done]=getNode(node,pos);if(done){return [node,pos,done]}}}}return [parent,pos]};function setCaret(parent,pos){var [node,nodepos]=getNode(parent,pos);var range=document.createRange();var sel=window.getSelection();range.setStart(node,nodepos);range.collapse(true);sel.removeAllRanges();sel.addRange(range)};return this.attr('contenteditable','').attr('spellcheck',false).on('paste',e=>{e.preventDefault();var text=e.clipboardData.getData("text");document.execCommand('insertText',false,text.replace(/\r/gs,''));var el=e.path.find(el=>el.tagName==='DIV');for(var el;el;el=el.nextSibling){checkOpen(el);$(el).markup();if(el.nextSibling&&el.nextSibling.markup){break}}}).on('keydown',e=>{var range=window.getSelection().getRangeAt(0);for(var el=range.startContainer.parentElement;el.tagName!=='DIV';el=el.parentElement);if(e.keyPressed==='ctrl_alt_BracketLeft'){e.preventDefault();toggleOpen(el,0)}if(e.keyPressed==='ctrl_alt_BracketRight'){e.preventDefault();toggleOpen(el,1)}if(e.keyCode==9&&!e.shiftKey){e.preventDefault();document.execCommand('insertHTML',false,' ')}setTimeout(()=>{var sel=window.getSelection();var an=sel.focusNode;var range=sel.getRangeAt(0);for(var el=an.nodeType===3?an.parentNode:an;el.tagName!=='DIV';el=el.parentElement);var children=Array.from(this.elem.children);const row=children.indexOf(el);const prefix=range.cloneRange();prefix.selectNodeContents(el);prefix.setEnd(range.endContainer,range.endOffset);var col=prefix.toString().length;$.his.elem.statusbar['pos'].text(`${row+1}:${col+1}`);var el=children[row];if(el.hasAttribute('hide')){for(var el;el&&el.hasAttribute('hide');el=e.keyCode>=39?el.nextSibling:el.previousSibling);if(el){if(e.keyCode===37)col=el.innerText.length;if(e.keyCode===39)col=0;var range=window.getSelection().getRangeAt(0).cloneRange();var [node,pos]=getNode(el,Math.min(col,el.innerText.length));range.setEnd(node,pos);if(!e.shiftKey){range.setStart(node,pos);range.collapse(true)}sel.removeAllRanges();sel.addRange(range)}}rows=Array.from(this.elem.children);rows.filter(el=>el.hasAttribute('selected')).forEach(el=>el.removeAttribute('selected'));el.setAttribute('selected','');checkOpen(el);checkOpen(el.previousElementSibling);if(!e.ctrlKey){if(e.keyCode>=0x30||e.keyCode==0x20){const rowsOpen=children.map(el=>el.getAttribute('open'));$(el).markup();console.log(el,col);setCaret(el,col)}}})})}},editorCollapse:{value:function(){}},emit:{value:function(selector,detail){this.elem.dispatchEvent(new CustomEvent(selector,{detail:detail}));return this}},exists:{value:function(parent){return(parent||document.documentElement).contains(this.elem)}},files:{value:function files(item,attributeName){this.item=item;console.log('FILES',item,attributeName);this.files=item[attributeName];if(this.files==='string'&&this.files[0]==='[')this.files=JSON.parse(this.files);if(this.files==='string'&&this.files[0]==='{')this.files=[JSON.parse(this.files)];if(!Array.isArray(this.files))this.files=[];this.appendFile=file=>$.promise('appendFile',callback=>{console.log(file,file.type,file.name);aimClient.api(`/${this.item.tag}/file`).query({uid:this.item.data.UID,name:file.name,lastModified:file.lastModified,size:file.size,type:file.type}).post(file).then(file=>{this.files.push(file);if(file.type==='application/pdf'){$().pdfpages(e.body.src).then(pages=>{const textpages=pages.map(lines=>lines.map(line=>line.str).join("\n"));let words=[].concat(textpages.map(page=>page.match(/\b\w+\b/gs))).map(words=>words.map(word=>word.toLowerCase()).unique().sort());console.log('PDF PAGES',words);aimClient.api(`/${this.item.tag}/?request_type=words`).patch(words).then(body=>{console.log('WORDS',body)})})}console.log(e.target.responseText,attributeName,this.files);item[attributeName]=JSON.stringify(this.files);this.emit('change');callback(file)})});this.removeElem=(elem,e)=>{e.stopPropagation();elem.remove();this.files=[...this.elem.getElementsByClassName('file')].map(e=>e.is.get('ofile'));item[attributeName]=JSON.stringify(this.files);return false};return this.class('col files').on('drop',e=>{e.preventDefault();if(e.dataTransfer.files){[...e.dataTransfer.files].forEach(this.appendFile)}}).on('dragover',e=>{e.dataTransfer.dropEffect='link';e.preventDefault()}).on('change',e=>{this.text('').append(this.imagesElem=$('div').class('row images'),this.attachElem=$('div').class('row attach'));console.debug(this,files,item,attributeName);return;this.files.filter(Boolean).forEach(ofile=>{let filename=ofile.src.split('/').pop();let ext=ofile.ext||ofile.src.split('.').pop();filename=filename.split('_');if(filename[0].length==32)filename.shift();filename=filename.join('_');let href=ofile.src;if(ofile.src.match(/jpg|png|bmp|jpeg|gif|bin/i)){const elem=$('span').parent(this.imagesElem).class('row file elplay').set('ofile',ofile).append($('i').class('bt sel'),$('img').class('aimage').src(ofile.src).set('ofile',ofile),$('div').class('row title').append($('span').class('aco').text(ofile.alt||ofile.name).title(ofile.title),$('i').class('abtn del').on('click',e=>this.removeElem(elem,e))));return;if(ofile.src){this.src(ofile.src)}return this;const access_token=$.auth.access_token;const iss=$.auth.access.iss;if(!ofile.src)return imgElement;var src=(ofile.srcs||ofile.src)+'?access_token='+access_token;imgElement.src=(src.indexOf('http')===-1?ofile.host||"https://"+iss:'')+src;var src=(ofile.src)+'?'+ofile.lastModifiedDate;imgElement.srcl=(src.indexOf('http')===-1?ofile.host||"https://"+iss:'')+src;imgElement.alt=ofile.name||'';return this}else if(ofile.src.match(/3ds/i)){const elem=$('span').parent(this.imagesElem).class('row file elplay').set('ofile',ofile).append($('i').class('bt sel'),$('div').class('aimage').set('ofile',ofile).width(120).height(120).tds({src:ofile.src}),$('div').class('row title').append($('span').class('aco').text(ofile.alt||ofile.name).title(ofile.title),$('i').class('abtn del').on('click',e=>this.removeElem(elem,e))))}else if(ofile.src.match(/mp4|webm|mov/i)){const elem=$('span').parent(this.imagesElem).class('row file elplay').set('ofile',ofile).append($('i').class('bt sel'),$('video').class('aimage').src(ofile.src).set('ofile',ofile),$('div').class('row title').append($('span').class('aco').text(ofile.alt||ofile.name).title(ofile.title),$('i').class('abtn del').on('click',e=>{e.stopPropagation();elem.remove();item[attributeName]=JSON.stringify([...this.elem.getElementsByClassName('file')].map(e=>e.ofile));return false})))}else{const elem=$('a').parent(this.attachElem).class('row file icn file_'+ext).set('ofile',ofile).href(href).download(ofile.name).draggable().on('click',e=>{if(ext==='pdf'){const href=ofile.host+ofile.src;const iframeElem=$('view').append($('div').class('col aco iframe').append($('iframe').class('aco').src(href),$('button').class('abtn close abs').on('click',e=>iframeElem.remove())));return false}}).append($('div').class('col aco').target('file').draggable().append($('div').class('row title').append($('span').class('aco').text(ofile.alt||ofile.name).title(ofile.title),$('i').class('abtn del').on('click',e=>this.removeElem(elem,e))),$('div').class('row dt').append($('span').class('aco').text(ofile.size?Math.round(ofile.size / 1000)+'kB':''),$('i').class('abtn download').href(href).download(ofile.name).on('click',e=>{e.stopPropagation();if($().aliconnector_id&&href.match(/(.doc|.docx|.xls|.xlsx)$/)){e.preventDefault();console.log(href);$().ws().sendto($().aliconnector_id,{external:{filedownload:['http://alicon.nl'+href]}}).then(e=>{console.log(e)})}}))));elem.elem.ofile=ofile}})}).emit('change')}},filesNext:{value:function(){this.filesSlide(1);if(this.slideIdx==0&&get.pv){}}},filesSlide:{value:function(step){this.images=this.elem.getElementsByClassName('aimage');this.slideIdx+=step||0;this.imagesElement.setAttribute('prev',this.slideIdx>0);this.imagesElement.setAttribute('next',this.slideIdx<this.images.length-1);var elSlide=this.images[this.slideIdx];if(!elSlide){this.slideIdx=0;var elSlide=this.images[this.slideIdx]}if(!elSlide)return;elSlide.show();if(elSlide.play&&checkVisible(elSlide)){if($.player.elPlaying)items.player.elPlaying.pause();elSlide.currentTime=0;elSlide.play()}}},forEach:{value:function(fn,selector,context){if(selector){if(typeof selector!=='object'){return fn.apply(this,[...arguments].slice(1))}else{Object.entries(selector).forEach(entry=>fn.call(this,...entry))}}return this}},ganth:{value:function(data){setTimeout(()=>new Ganth(data,this));return this}},get:{value:function(){return this.map.get(...arguments)}},has:{value:function(){return this.map.has(...arguments)}},header:{value:function(item){return $('header').class('row header',item.tag).draggable().on('change',function(e){function linkMaster(item,name,elem){if(item&&item.data&&item.data[name]){const master=$(data=[].concat(item.data[name]).shift());elem.insert($('span').itemLink(master),'/');if(master&&master.details){master.details().then(item=>linkMaster(item,name,elem))}}return elem}function linkSource(item,name,elem){if(item&&item.data&&item.data[name]){const master=$(data=[].concat(item.data[name]).shift());elem.append(':',$('span').itemLink(master));if(master&&master.details){master.details().then(item=>linkSource(item,name,elem))}}return elem}this.is.text('').append($('button').class('abtn stateicon').append($('i').append($('i').css('background-color',item.stateColor)),item.elemStateUl=$('ul').class('col').append($('li').class('abtn').text('JAdsfg sdfg sd'),$('li').class('abtn').text('JAdsfg sdfg sd'),$('li').class('abtn').text('JAdsfg sdfg sd'),$('li').class('abtn').text('JAdsfg sdfg sd'))).on('mouseenter',function(e){const rect=this.getBoundingClientRect();item.elemStateUl.css('top',(rect.top)+'px').css('left',rect.left+'px')}),item.IsPublic?$('div','icn IsPublic').class(item.hostID===1?'public':''):null,$('div').class('icn itemicon',item.className).css('border-color',item.modColor).css('color',item.schemaColor).append(item.gui&&item.gui.global?$('div','gui').append($('div','detail').append($('div','object').append($('div',item.tag,item.gui.detail)))):(item.iconsrc?$('img').src(item.iconsrc):null)),$('div').class('aco col headername inline').append($('div','header title',item.header0).append(),$('div','header subject',item.header1),$('div','header preview',item.header2),$('div','row date')))}).emit('change')}},html:{value:function(content,format){const elem=this.elem;[].concat(content).forEach(content=>{if(typeof content==='function'){format='js';content=String(content).replace(/^(.*?)\{|\}$/g,'')}content=format&&$.string[format]?$.string[format](content):content;this.elem.innerHTML+=content});return this}},write:{value:function(content){return this.elem.innerHTML+=content}},htmledit:{value:function(property){const oDoc=this.elem;const stateButtons={};function formatDoc(sCmd,sValue){if(oDoc.currentRange){var sel=window.getSelection();sel.removeAllRanges();sel.addRange(oDoc.currentRange)}if(validateMode()){document.execCommand(this.cmd||sCmd,false,this.value||this.name||this.Title||sValue||this.cmd||sCmd);oDoc.focus()}}function validateMode(){if(!oDoc.codeview||!oDoc.codeview.checked){return true}alert("Uncheck \"Show HTML\".");oDoc.focus();return false}function setDocMode(){var oContent;if(oDoc.contentEditable!=='false'){oContent=document.createTextNode(oDoc.innerHTML);oDoc.innerHTML='';var oPre=document.createElement('PRE');oPre.onfocus=function(e){this.parentElement.onfocus()};oDoc.contentEditable=false;oPre.id='sourceText';oPre.contentEditable=true;oPre.appendChild(oContent);oDoc.appendChild(oPre);document.execCommand('defaultParagraphSeparator',false,'p')}else{if(document.all){oDoc.innerHTML=oDoc.innerText}else{oContent=document.createRange();oContent.selectNodeContents(oDoc.firstChild);oDoc.innerHTML=oContent.toString()}oDoc.contentEditable=true}oDoc.focus()}function printDoc(){if(!validateMode()){return}var oPrntWin=window.open('','_blank','width=450, height=470, left=400, top=100, menubar=yes, toolbar=no, location=no, scrollbars=yes');oPrntWin.document.open();oPrntWin.document.write("<!doctype html><html><head><title>Print<\/title><\/head><body onload=\"print();\">"+oDoc.innerHTML+"<\/body><\/html>");oPrntWin.document.close()}const contentEditableCheck=(e)=>{var sel=window.getSelection();stateButtons.hyperlink.attr('checked',sel.focusNode.parentElement.tagName==='A');stateButtons.unlink.attr('disabled',!((sel.anchorNode.nextSibling&&sel.anchorNode.nextSibling.tagName==='A'&&sel.extentNode.previousSibling&&sel.extentNode.previousSibling.tagName==='A')||(sel.extentNode.nextSibling&&sel.extentNode.nextSibling.tagName==='A'&&sel.anchorNode.previousSibling&&sel.anchorNode.previousSibling.tagName==='A')||(sel.anchorNode.parentElement.tagName==='A'&&sel.extentNode.parentElement.tagName!=='A')||(sel.anchorNode.parentElement.tagName!=='A'&&sel.extentNode.parentElement.tagName==='A')));stateButtons.blockquote.attr('checked',sel.anchorNode.parentElement===sel.extentNode.parentElement&&sel.extentNode.parentElement.tagName==='BLOCKQUOTE');['bold','italic','underline','strikeThrough','superscript','subscript','insertunorderedlist','insertorderedlist','justifyleft','justifycenter','justifyright','justifyfull'].forEach(name=>stateButtons[name].attr('checked',document.queryCommandState(name)))};let keyupTimeout;const keysup={shift_alt_ArrowRight(){formatDoc('indent')},shift_alt_ArrowLeft(){formatDoc('outdent')},ctrl_Space(){formatDoc('removeFormat');oDoc.innerHTML=oDoc.innerHTML.replace(/\r/g,'').replace(/<p><\/p>/g,'')},ctrl_alt_Digit1(){formatDoc('formatblock','H1')},ctrl_alt_Digit2(){formatDoc('formatblock','H2')},ctrl_alt_Digit3(){formatDoc('formatblock','H3')},ctrl_shift_Period(){var startSize=parseInt(window.getComputedStyle(window.getSelection().anchorNode.parentElement,null).fontSize);for(var i=1;i<=7;i++){formatDoc('fontsize',i);if(parseInt(window.getComputedStyle(window.getSelection().anchorNode.parentElement,null).fontSize)>startSize)break}},ctrl_shift_Comma(){var startSize=parseInt(window.getComputedStyle(window.getSelection().anchorNode.parentElement,null).fontSize);for(var i=7;i>=1;i--){formatDoc('fontsize',i);if(parseInt(window.getComputedStyle(window.getSelection().anchorNode.parentElement,null).fontSize)<startSize)break}}};const keysdown={ctrl_KeyD(){formatDoc('strikeThrough')}};this.contenteditable('').on('paste',e=>{console.log(e,e.clipboardData,e.clipboardData.files,e.clipboardData.types.includes('Files'))}).on('drop',e=>{e.preventDefault();if(e.dataTransfer.files){[...e.dataTransfer.files].forEach(file=>{property.item.elemFiles.appendFile(file).then(file=>{console.log(file);if(window.getSelection){var sel,range,html;sel=window.getSelection();if(sel.getRangeAt&&sel.rangeCount){range=sel.getRangeAt(0);range.deleteContents();var elImg=document.createElement('img');elImg.src=file.srcs||file.src;range.insertNode(elImg);range.setStartAfter(elImg);sel.removeAllRanges();sel.addRange(range)}}else if(document.selection&&document.selection.createRange){document.selection.createRange().text=text}})})}}).on('focus',e=>{oDoc.currentRange=null;document.execCommand('defaultParagraphSeparator',false,'p');for(var menuParentElement=oDoc;menuParentElement.tagName!=='FORM';menuParentElement=menuParentElement.parentElement);if(!$.editBtnRowElement||!$.editBtnRowElement.parentElement){function formatButton(name,classname){return stateButtons[name]=$('button').class('abtn',name,classname).attr('title',name).on('click',e=>formatDoc(name))}$.editBtnRowElement=$('div').parent(document.body).class('row top abs textedit np shdw').append(formatButton('undo r'),formatButton('redo'),formatButton('cut','split'),formatButton('copy'),formatButton('paste'),$('button').class('abtn fontname split').append($('ul').append(['Arial','Arial Black','Courier New','Times New Roman'].map(fontname=>$('li').class('abtn').text(fontname).on('click',e=>formatDoc('fontname',fontname))))),$('button').class('abtn fontsize').append($('ul').append([ [1,'Very small'],[2,'A bit small'],[3,'Normal'],[4,'Medium-large'],[5,'Big'],[6,'Very big'],[7,'Maximum']].map(([size,text])=>$('li').class('abtn').text(text).on('click',e=>formatDoc('fontsize',size))))),$('button').class('abtn switchMode').append($('ul').append([ ['h1',__('Header 1')+' <h1>'],['h2',__('Header 2')+' <h2>'],['h3',__('Header 3')+' <h3>'],['p',__('Paragraph')+' <p>'],['pre',__('Preformated')+' <pre>']].map(([tag,text])=>$('li').class('abtn').text(text).on('click',e=>formatDoc('formatblock',tag))))),formatButton('removeFormat','split'),formatButton('bold','split'),formatButton('italic'),formatButton('underline'),formatButton('strikeThrough'),formatButton('subscript'),formatButton('superscript'),$('button').class('abtn backcolor split').append($('ul').append(['black','red','orange','yellow','green','blue','white'].map(color=>$('li').class('abtn',color).text(color).on('click',e=>formatDoc('backcolor',color))))),$('button').class('abtn forecolor').append($('ul').append(['black','red','orange','yellow','green','blue','white'].map(color=>$('li').class('abtn',color).text(color).on('click',e=>formatDoc('forecolor',color))))),formatButton('insertunorderedlist','split'),formatButton('insertorderedlist'),formatButton('outdent','split'),formatButton('indent'),formatButton('justifyleft','split'),formatButton('justifycenter'),formatButton('justifyright'),formatButton('justifyfull'),stateButtons.blockquote=$('button').class('abtn blockquote split').on('click',e=>formatDoc('formatblock','blockquote')),stateButtons.hyperlink=$('button').class('abtn hyperlink split').on('click',e=>{var sLnk=prompt('Write the URL here','http:\/\/');if(sLnk&&sLnk!=''&&sLnk!='http://'){formatDoc('createlink',sLnk)}}),stateButtons.unlink=$('button').class('abtn unlink').on('click',e=>formatDoc('unlink')),$('button').class('abtn clean split').on('click',e=>{if(validateMode()&&confirm('Are you sure?')){this.innerHTML=this.value}}),$('button').class('abtn print').on('click',e=>printDoc())).on('click',e=>{clearTimeout(oDoc.blurTimeout)},true)}}).on('keyup',e=>{let key=e.keyPressed;if(oDoc.innerHTML&&oDoc.innerHTML[0]!=='<'){oDoc.innerHTML='<p>'+oDoc.innerHTML+'</p>';const node=oDoc.childNodes[0];const range=document.createRange();const sel=window.getSelection();range.setStart(node,1);range.collapse(true);sel.removeAllRanges();sel.addRange(range);e.preventDefault()}if(keysup[key]){keysup[key]();e.preventDefault()}clearTimeout(keyupTimeout);keyupTimeout=setTimeout(contentEditableCheck,200,e)}).on('keydown',e=>{let key=e.keyPressed;if(keysdown[key]){keysdown[key]();e.preventDefault()}}).on('blur',e=>{oDoc.blurTimeout=setTimeout(e=>$.editBtnRowElement.elem.remove(),300);oDoc.currentRange=window.getSelection().getRangeAt(0);for(var i=0,p;p=e.path[i];i++){if(p.item)break}if(p&&p.item&&oDoc.name){p.item[oDoc.name]=oDoc.innerHTML}if(property){property.value=oDoc.innerHTML}}).on('mouseup',e=>contentEditableCheck);return this}},insert:{value:function(){this.elem=this.elem||document.body;const args=[].concat(...arguments);args.forEach(a=>!a?null:this.elem.insertBefore(typeof a==='string'?document.createTextNode(a):a.elem||a,this.elem.firstChild));return this}},id:{value:function(selector){this.elem.setAttribute('id',selector);$.his.map.set(selector,this);return this}},index:{value:function(docelem){const all=[...docelem.elem.querySelectorAll("h1, h2, h3")];const topItem=docelem.topItem=all[0];const elemTop=docelem.elemTop=docelem.elem.getBoundingClientRect().top;const findAll=docelem.findAll=all.slice().reverse();const allmenu=docelem.allmenu=[];let i=0;var li;var path=[];function addChapters(ul,level){for(let elem=all[i];elem;elem=all[i]){const tagLevel=Number(elem.tagName[1]);path.slice(0,tagLevel-1);const title=elem.innerText;path[tagLevel-1]=title.toLowerCase().replace(/ /g,'_');const name=path.join('-');if(tagLevel===level){$(elem).append($('a').attr('name',name));li=$('li').parent(ul).append(elem.a=$('a').text(elem.innerText).attr('href','#'+name).attr('open','0').attr('target','_self'));i++;allmenu.push(elem.a)}else if(li&&tagLevel>level){li.append(addChapters($('ul'),level+1))}else{return ul}}return ul}let to;var lastScrollTop=0;addChapters(this.text(''),1);return this;this.addNextPreviousButtons()}},item:{value:function(item,name){if(item){if(name){item.elems=item.elems||new Map();item.elems.set(name,this)}this.elem.item=item;return this;this.set('item',item)}for(var elem=this.elem;elem&&!elem.item;elem=elem.parentElement);return elem?elem.item:null}},itemAttr:{value:function(items,attributeName,value){items=Array.isArray(items)?items:[items];const a=$.his.attributeItems=$.his.attributeItems||{};if(a[attributeName]){a[attributeName].forEach(item=>{delete item[attributeName];Object.values(item).filter(value=>value instanceof Element).forEach(elem=>elem.removeAttribute(attributeName))})}items.forEach(item=>{const elements=Object.values(item).filter(value=>value instanceof Element);if(value===undefined){delete item[attributeName];elements.forEach(elem=>elem.removeAttribute(attributeName))}else{item[attributeName]=value;elements.forEach(elem=>elem.setAttribute(attributeName,value))}});return a[attributeName]=items||[]}},itemLink:{value:function(link){if(link){item=link instanceof Item?link:$(link);return this.append((this.linkElem=$('a')).text(item.header0).item(item).href('#/id/'+item.Id).on('mouseenter',e=>{console.log('a mouseenter');const targetElement=this.linkElem.elem;const rect=targetElement.getBoundingClientRect();const popupElem=$.popupcardElem=$.popupcardElem||$('div').parent(document.body).class('pucard');popupElem.style(`top:${rect.top}px;left:${rect.left}px;width:${rect.width}px;height:${rect.height+10}px;`).on('close',e=>{console.log('div close',this);$.popupcardElem=null;popupElem.remove()}).on('mouseleave',e=>{console.log('div mouseleave',this);popupElem.to=clearTimeout(popupElem.to);popupElem.emit('close')}).on('mouseenter',e=>{console.log('div mouseenter');clearTimeout(this.to);const divElem=$('div').parent(popupElem.text(''));console.log(item);this.to=setTimeout(()=>item.details().then(item=>{popupElem.css(`opacity:1;`);const infoID=item.tag;divElem.append($('div').class(' shdw col').append($('div').class('aco point').append($('div').class('kop0').text(item.header0),$('div').class('kop1').text(item.header1),$('div').class('kop2').text(item.header2)),$('div').class('row top btnbar').append(Array.isArray(item.Email)?item.Email.map(email=>$('a').class('abtn icn email').text(email.Value).href(`mailto:${property.Value}`)):null)).on('click',e=>{popupElem.emit('close');$().preview(item)}))}),500)})}))}}},langtext:{value:function(value){return this.ttext(...arguments)}},list:{value:function(){$().list(this);return this}},load:{value:async function(src,callback){console.warn(src);if(src.match(/\w+\(\d+\)/)){return}if(src.match(/wiki$/)){src+='/'}if(src.match(/wiki\/$/)){src+='Home'}function hrefSrc(href,src='/'){if(href[0]==='#')return href;if(href.match(/^http/))return href;href=new URL(href,new URL(src,document.location)).href.replace(/^.*?\//,'/');return href}function rawSrc(src){console.log(777,src,document.location.hostname);src=src.replace(/\/(blob|tree)\/main/,'');if(document.location.hostname.split('.').pop()==='localhost'){src=new URL(new URL(src,document.location).pathname,'http://github.aliconnect.nl').href}else if(!src.match(/githubusercontent/)){src=src.replace(/\/\/([\w\.-]+)\.github\.io/,'//github.com/$1');src=src.replace(/github.com/,'raw.githubusercontent.com')}if(src.match(/githubusercontent/)){if(src.match(/\/wiki/)){src=src.replace(/wiki$/,'wiki/Home');src=src.replace(/raw.githubusercontent.com\/(.*?)\/wiki/,'raw.githubusercontent.com/wiki/$1')}else if(!src.match(/\/main/)){src=src.replace(/raw.githubusercontent.com\/([\w\.-]+)\/([\w\.-]+)/,'raw.githubusercontent.com/$1/$2/main')}}else{src=src.replace(/\/main/g,'')}src=src.replace(/\/tree|\/glob|\/README.md/g,'');src=new URL(src,document.location).href;console.log(1,src);return src}const elem=this;elem.paths=elem.paths||[];const homePath=document.location.origin;const origin=new URL(src,document.location).origin;const linksrc=hrefSrc(src).toLowerCase();this.links=this.links||[];src=rawSrc(src);this.loadMenu=async function(src){var wikiPath=rawSrc(src).replace(/wiki$/,'wiki/').replace(/[\w\.-]*$/,'');if(!elem.paths.includes(wikiPath)){console.log(9,'loadMenu',wikiPath,this.links);elem.paths.push(wikiPath);await $().url(rawSrc(wikiPath+'_Sidebar.md')).accept('text/markdown').get().catch(console.error).then(e=>{this.doc.leftElem.md(e.target.responseText);Array.from(this.doc.leftElem.elem.getElementsByTagName('A')).forEach(elem=>$(elem).href(hrefSrc(elem.getAttribute('href'),e.target.responseURL)))});Array.from(this.doc.leftElem.elem.getElementsByTagName('LI')).forEach(li=>{if(li.childNodes.length){if(li.childNodes[0].nodeValue){li.replaceChild($('span').text(li.childNodes[0].nodeValue.trim()).elem,li.childNodes[0])}const nodeElem=li.firstChild;if(!nodeElem.hasAttribute('open')&&nodeElem.nextElementSibling){nodeElem.setAttribute('open','0');$(nodeElem).attr('open','0').on('click',e=>{nodeElem.setAttribute('open',nodeElem.getAttribute('open')^ 1)})}}});this.links=Array.from(this.doc.leftElem.elem.getElementsByTagName('A'))}};if(!this.doc){this.doc=$().document($('div'));await this.loadMenu($.config.ref.home)}(this.findlink=()=>{this.link=this.links.find(link=>link.getAttribute('href')&&link.getAttribute('href').toLowerCase()===linksrc)})();if(!this.link){await this.loadMenu(src);this.findlink()}if(src.match(/wiki/)){}else if(!src.match(/\.md$/)){src+='/README'}if(!src.match(/\.md$/)){src+='.md'}this.src=src;this.scrollTop=this.scrollTop||new Map();(this.url=$().url(src).accept('text/markdown').get()).then(async e=>{if(elem.pageElem&&elem.pageElem.elem.parentElement){elem.loadIndex=false}else{elem.loadIndex=true}let content=e.target.responseText;if(callback){content=callback(content)}const responseURL=e.target.responseURL;var title=responseURL.replace(/\/\//g,'/');var match=content.match(/^#\s(.*)/);if(match){content=content.replace(/^#.*/,'').trim();title=match[1]}else{title=title.match(/README.md$/)?title.replace(/\/README.md$/,'').split('/').pop().split('.').shift().capitalize():title.split('/').pop().split('.').shift().replace(/-/g,' ');title=title.replace(/-/,' ')}const date=e.target.getResponseHeader('last-modified');content=content.replace(/<\!-- sample button -->/gs,`<button onclick="$().demo(e)">Show sample</button>`);try{}catch(err){}this.doc.docElem.text('').append(this.doc.navElem=$('nav'),$('h1').text(title),date?$('div').class('modified').text(__('Last modified'),new Date(date).toLocaleString()):null).md(content).mdAddCodeButtons();[...this.doc.docElem.elem.getElementsByTagName('code')].forEach(elem=>{if(elem.hasAttribute('source')){$().url(hrefSrc(elem.getAttribute('source'),responseURL)).get().then(e=>{var content=e.target.responseText.replace(/\r/g,'');if(elem.hasAttribute('id')){var id=elem.getAttribute('id');var content=content.replace(new RegExp(`.*?<${id}>.*?\n(.*?)\n(\/\/|<\!--) <\/${id}.*`,'s'),'$1').trim()}if(elem.hasAttribute('function')){var id=elem.getAttribute('function');var content=content.replace(/\r/g,'').replace(new RegExp(`.*?((async |)function ${id}.*?\n\})\n.*`,'s'),'$1').trim()}elem.innerHTML=elem.hasAttribute('language')?$.string[elem.getAttribute('language')](content):content})}});[...this.doc.docElem.elem.getElementsByTagName('A')].forEach(elem=>$(elem).href(hrefSrc(elem.getAttribute('href'),responseURL)));[...this.doc.docElem.elem.getElementsByTagName('IMG')].forEach(elem=>{elem.setAttribute('src',new URL(elem.getAttribute('src'),new URL(src,document.location)).href.replace(/^.*?\//,'/'))});setTimeout(()=>this.doc.indexElem.index(this.doc.docElem));this.links.forEach(link=>link.removeAttribute('selected'));if(this.link){$(this.link).attr('selected','');for(var link=this.link;link;link=link.parentElement.parentElement?link.parentElement.parentElement.previousElementSibling:null){if(link.hasAttribute('open')){link.setAttribute('open','1')}}const children=Array.from(this.link.parentElement.parentElement.children);const total=children.length;const index=children.indexOf(this.link.parentElement)+1;var elemPrevious;var elemNext;this.doc.docNavTop.text('');if(this.link.parentElement.previousElementSibling){elemPrevious=$('a').class('row prev').href(this.link.parentElement.previousElementSibling.firstChild.getAttribute('href')).append($('span').text('←'),$('small').class('aco').text('Previous'));this.doc.docNavTop.append($('a').class('row prev').href(this.link.parentElement.previousElementSibling.firstChild.getAttribute('href')).append($('span').text('←'),$('small').text(this.link.parentElement.previousElementSibling.firstChild.innerText)))}if(this.link.parentElement.nextElementSibling){elemNext=$('a').class('row next').href(this.link.parentElement.nextElementSibling.firstChild.getAttribute('href')).append($('small').class('aco').text('Next'),$('span').text('→'));this.doc.docNavTop.append($('a').class('row next').href(this.link.parentElement.nextElementSibling.firstChild.getAttribute('href')).append($('small').class('aco').text(this.link.parentElement.nextElementSibling.firstChild.innerText),$('span').text('→')))}$('div').parent(this.doc.docElem).class('row').append($('span').append(elemPrevious),$('span').class('aco').align('center').text(`${index} van ${total}`),$('span').append(elemNext))}this.doc.docElem.elem.scrollTop=this.scrollTop.get(src);return this});return this.url}},maps:{value:async function(selector,referenceNode){const maps=await $.his.maps();let map=new maps.Map(this.elem,{zoom:8});bounds=new maps.LatLngBound