diff --git a/src/scripts/App.vue b/src/scripts/App.vue index 751c7e4..45a243c 100644 --- a/src/scripts/App.vue +++ b/src/scripts/App.vue @@ -65,7 +65,7 @@ @@ -167,14 +168,14 @@ export default { console.log(data.index) console.log(data.tab) }, - search_dict() { + search_dict(term) { console.log(this.$refs.searchstr.value) console.log('SEARCH') var that = this axios .get('/api/v1/terms/', { params: { - string: this.$refs.searchstr.value, + string: term, translation: this.currentTrans, }, }) @@ -192,11 +193,19 @@ export default { // always executed }) }, + searchTerm2(term) { + this.$refs.searchstr.value = term; + if (this.currentTrans % 2) { + this.switchTrans(parseInt(this.currentTrans) + 1); + } else { + this.switchTrans(parseInt(this.currentTrans) - 1); + } + }, switchTrans(i) { if (this.currentTrans != i) { - this.currentTrans = i - this.search_dict() - console.log('TRANS switch = ', i) + this.currentTrans = i; + this.search_dict(this.$refs.searchstr.value); + console.log('TRANS switch = ', i); } }, }, diff --git a/src/scripts/components/Translation.vue b/src/scripts/components/Translation.vue index 592b250..082eaaf 100644 --- a/src/scripts/components/Translation.vue +++ b/src/scripts/components/Translation.vue @@ -4,6 +4,7 @@ import VueSound from './VueSound.vue' export default { props: ['data', 'type', 'translation'], components: { VueSound }, + emits: [ 'search-term', ], computed: { termsDataDict: function () { let data = this.data.terms @@ -14,6 +15,16 @@ export default { } return ret }, + termsDataDict2: function () { + let data = this.data.terms + let ret = Object({}) + for (let i = 0; i < data.length; i++) { + if (!Array.isArray(ret[data[i].string2])) ret[data[i].string2] = [] + ret[data[i].string2].push(data[i]) + } + console.log(ret); + return ret + }, }, } @@ -90,7 +101,7 @@ export default {