appticles/mo-lunfardo/lunfardo.js
2022-10-19 14:00:54 -03:00

50 lines
1.1 KiB
JavaScript

const App = Vue.createApp({
data(){
return {
placeholder: 'Buscá che...',
searchQuery: '',
wordsJson: {
'word-1': { "title": "sonamos", "description": "pop. ¡Estamos perdidos!"},
'word-2': { "title": "percanta", "description": "(pop.) Mujer (LCV.), amante (LCV.), querida (LCV.), concubina."},
}
}
},
methods:{
matches(obj) {
const term = this.searchQuery.toLowerCase();
return obj.title.toLowerCase().includes(term) || obj.description.toLowerCase().includes(term);
}
},
mounted: {
// const res = fetch("");
},
computed:{
listValues() {
return Object.values(this.wordsJson);
},
countWords(){
return Object.keys(this.wordsJson).length;
},
filteredList() {
if (!this.searchQuery) {
return this.listValues;
}
return this.listValues
.map((v) => {
if (this.matches(v)) {
return v;
}
})
.filter((v) => v);
}
},
}).mount("#app");