Vue.component('Menu',{
template: `
`,
props : {
obj : Object
},
data () {
return {
message : "hello from menu",
et : {
fr : " et ",
en : " and ",
it : " e ",
},
fourchette : {
fr : "Fourchette de prix par personne:",
en : "Price range per person:",
it : "Fascia di prezzo per persona:",
},
horsboissons : {
fr : "(hors boissons)",
en : "(excluding drinks)",
it : "(bevande escluse)",
},
indicatif : {
fr : "menu fournis à titre indicatif",
}
}
},
methods : {
capitalize(s){
return s.charAt(0).toUpperCase() + s.slice(1)
},
l2s(l, lang) {
let r = ""
let llength = l.length - 1
for (i in l){
if (parseInt(i) === 0){
r = this.capitalize(l[i])
} else if (parseInt(i) < parseInt(llength)) {
r = r + ", " + l[i]
} else {
r = r + this.et[lang] + l[i]
}
}
return r
},
ings2ls(ings, lang){
let l = []
for (i in ings) {
l.push(ings[i][lang])
}
return l
}
}
})
Vue.component('Time', {
template : `
`,
props : {
obj : Object
},
data () {
return {
message : "hello from time",
closed : {
fr : "Fermé",
en : "Closed",
it : "Chiuso",
},
days : {
mon : {
fr : "Lundi",
en : "Monday",
it : "Lunedì"
},
tue : {
fr : "Mardi",
en : "Tuesday",
it : "Martedì"
},
wed : {
fr : "Mercredi",
en : "Wednesday",
it : "Mercoledì"
},
thu : {
fr : "Jeudi",
en : "Thursday",
it : "Giovedì"
},
fri : {
fr : "Vendredi",
en : "Friday",
it : "Venerdì"
},
sat : {
fr : "Samedi",
en : "Saturday",
it : "Sabato"
},
sun : {
fr : "Dimanche",
en : "Sunday",
it : "Domenica"
},
}
}
},
methods : {
checkTime (d) {
if (d != "" ){
return d
} else {
return this.closed
}
}
}
});
Vue.component('Accordeon', {
template : `
`,
props : {
list : Object
},
data () {
return {
isActive : false,
displayCard : "block",
cardTop : "110vh",
tabrollxoff : 0,
tabind : 0,
markerL : 0,
markerW : 0,
}
},
computed: {
xy: function () {
if ('xy' in this.list) {
return this.list.xy
} else {
return [0,0]
}
},
dirxy: function () {
if ('dirxy' in this.list) {
return this.list.dirxy
} else {
return [0,0]
}
},
dirzl: function () {
if ('dirzl' in this.list) {
return this.list.dirzl
} else {
return 1
}
},
href: function () {
return "#" + this.list.id;
},
cardid: function () {
return "card" + this.list.id;
},
tabcount: function () {
if ('card' in this.list){
var arr = Object.entries(this.list.card.tabs);
return arr.length
} else {
return 0;
}
},
tabrollw: function () {
return this.tabcount + "00vw";
},
tabrollTransX: function () {
return "translateX(-" + this.tabrollxoff + "00vw)";
},
},
methods : {
getMarkerId(i) {
return this.cardid + this.getIndex(i).toString()
},
getIndex(obj) {
var arr = Object.entries(this.list.card.tabs);
let ind = arr.findIndex(e => e[0] === obj.tabtype);
return ind
},
setTab(ind) {
this.tabrollxoff = ind;
this.tabind = ind
t = document.getElementById(this.cardid + ind);
this.markerL = t.offsetLeft + "px"
this.markerW = t.offsetWidth + "px"
},
getTabLogo(obj) {
switch(obj.tabtype) {
case "menu":
return "byl-icon-restaurant"
// code block
break;
case "time":
return "byl-icon-clock"
// code block
break;
default:
// code block
}
},
showCard() {
this.displayCard = "block";
this.setTab(0)
this.cardTop = "0vh"
this.setTab(0)
this.setTab(0)
this.setMap()
this.setTab(0)
},
hideCard() {
this.cardTop = "110vh"
},
donothing () {
},
toggleActive () {
this.list.isActive = !this.list.isActive
document.getElementById(this.list.id).scrollIntoView();
},
setMap () {
map.setView(this.dirxy, this.dirzl)
this.list.marker.openPopup()
}
},
})
const jsonurl = "https://ed.brz9.dev/proj/map/asset/json/db.json"
/*
let jdnb
fetch(jsonurl)
.then(res => res.json())
.then(data => jdnb = data)
*/
let vm = new Vue({
el: '#root',
data : jdb.data,
methods: {
hidelang: function(lang) {
langClass = "b9h-lang-" + lang;
langElms = document.getElementsByClassName(langClass);
for (i = 0; i < langElms.length; i++) {
langElms[i].style.display = 'none';
}
},
hidelangs: function() {
this.hidelang('fr');
this.hidelang('en');
this.hidelang('it');
},
showlang: function(lang) {
this.hidelangs();
langClass = "b9h-lang-" + lang;
langElms = document.getElementsByClassName(langClass);
for (i = 0; i < langElms.length; i++) {
langElms[i].style.display = 'revert';
}
},
setlang: function (lang) {
target = document.querySelector("#"+"tab-"+lang);
marker = document.querySelector("#lang-marker");
marker.style.left = target.offsetLeft + "px";
marker.style.width = target.offsetWidth + "px";
this.showlang(lang);
},
},
created: function(){
this.setlang('fr');
},
mounted: function() {
this.setlang('fr');
this.setlang('fr');
this.setlang('fr');
this.setlang('fr');
this.setlang('fr');
},
updated: function() {
this.setlang('fr');
this.setlang('fr');
this.setlang('fr');
this.setlang('fr');
}
})