async function showtext () { /* ETIQUETES DELS ELEMENTS HTML */ // Obté el llenguatge amb el qual esta configurat el navegador. //var userLang = navigator.language || navigator.userLanguage; var userLang = 'ca'; const getLangFile = () => { switch (userLang) { case 'ca': return('./ca.json'); break; case 'es': return('./es.json'); break; default: return('./en.json'); break; } } const fileName = getLangFile(); // Obtenir la llista dels ID per psoder iterar i buscar el text corresponent. const getAllIds = () => {return(document.querySelectorAll('*[id]'))}; const ids = Array.prototype.map.call( getAllIds(), function( el ) { return el.id; }); // Carrega asincrona de fitxer JSON. const loadJson = async (file) => { const fetchResult = await fetch(file).catch(e=>console.log(e)); const response = await fetchResult.json().catch(e=>console.log(e)); return(response); } //Carrega asincrona del fitxer d'idioma const tags = await loadJson(fileName); // Obtenir tag a partir de id const getTag = (id) => {return(tags[id])}; // Establir el contingut d'un Id a partir del Id const setIdContent = (id,content) => { if(content===null | content===undefined | content===""){return}; document.getElementById(id).innerHTML = content; } // GET ALL TAGS // Establir el contingut de tots els ID a partir de l'array de Ids const getAllTags = async() => { ids.map( x => { const t = getTag(x); if(t===undefined | t===""){return}; setIdContent(x, t); }); } await getAllTags(); /* FORMULARI */ const $form = document.querySelector('#form'); const $buttonMailto = document.querySelector('#mailto'); $form.addEventListener('submit', handleSubmit) function handleSubmit(event){ event.preventDefault() const form = new FormData(this) const name = form.get('name') const surname = form.get('surname') const email = form.get('email') const message = form.get('message') const check = form.get('sendcopyMail') //console.log(name, surname, email, message, check) let sendto = undefined if (check==="on"){ $buttonMailto.setAttribute('href', `mailto:sabria-bach-ginecolegs@sbpsoftware.com;${email}?subject=${name} ${surname} - ${email}&body=${message}`) $buttonMailto.click() } else { $buttonMailto.setAttribute('href', `mailto:sabria-bach-ginecolegs@sbpsoftware.com;?subject=${name} ${surname} - ${email}&body=${message}`) $buttonMailto.click() } console.log(sendto) } /* ETIQUETES DELS ELEMENTS DEL FORMULARI */ async function getAllFormTags() { const formids = Array.prototype.map.call( $form, function( el ) { return el.id; }); const setPlaceholder = (id, ph) => { if(ph===null | ph===undefined | ph===""){return}; document.getElementById(id).placeholder = ph; } formids.map( x => {setPlaceholder(x, getTag(x))}); } await getAllFormTags(); /* COMPONENTS */ const followreading = async () => { let div = document.createElement('div'); div.setAttribute('class', 'reading_div'); div.innerHTML = `

` document.querySelector('#followReading').appendChild(div); console.log("followReading", document.querySelector('#followReading')) } await followreading(); // Initialize and add the map (g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({ key: "AIzaSyAmMvNwJkGxxEO0UIEXlmS_I1X--xqmT4M", v: "weekly"}); /* let map; async function initMap() { const position = { lat: 41.9776, lng: 2.82 }; //@ts-ignore const { Map } = await google.maps.importLibrary("maps"); const { AdvancedMarkerView } = await google.maps.importLibrary("marker"); //https://maps.app.goo.gl/oraFP5EVxW3mLbR78 map = new Map(document.getElementById("map"), { center: position, zoom: 16, mapID: "SB_MAP", }); // The marker, positioned at Uluru const marker = new AdvancedMarkerView({ map: map, position: position, title: "adreça", }); } initMap(); */ const { Map } = await google.maps.importLibrary("maps"); const { Marker } = await google.maps.importLibrary("marker"); var myLatlng = new google.maps.LatLng(41.977885, 2.82025); var mapOptions = { zoom: 18, center: myLatlng } var map = new Map(document.getElementById("map"), mapOptions); var marker = new Marker({ map: map, position: myLatlng, title:"Hello World!" }); // To add the marker to the map, call setMap(); initMap(); marker.setMap(map); /* const comp = document.querySelector('#map') console.log("SBP_MAP:", comp) */ };