From 1cde126e6f730605890cb299953e028d074ccf8a Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 22 Feb 2020 20:23:14 +0100 Subject: Format fix Problem with gsm. They force the first letter to be a majuscule. Ex: Typing "manger" will become "Manger" and so will not be in the dictionary. Must be searched at manger and at Manger. --- assets/web.js | 3 +++ main.js | 0 web.js | 42 ------------------------------------------ web.py | 11 ++++++++++- 4 files changed, 13 insertions(+), 43 deletions(-) delete mode 100644 main.js delete mode 100644 web.js diff --git a/assets/web.js b/assets/web.js index b624edd..46b6810 100644 --- a/assets/web.js +++ b/assets/web.js @@ -22,6 +22,9 @@ const web = new Vue({ if( response.ok ) { response.arrayBuffer().then(res => { this.definitions = msgpack.decode(new Uint8Array(res)); + if( this.definitions && this.definitions[0] && this.definitions[0].mot) { + this.word = this.definitions[0].mot; + } }); } }) diff --git a/main.js b/main.js deleted file mode 100644 index e69de29..0000000 diff --git a/web.js b/web.js deleted file mode 100644 index 61b82d5..0000000 --- a/web.js +++ /dev/null @@ -1,42 +0,0 @@ -const web = new Vue({ - el: '#web', - data: { - word: '', - timer: undefined, - definitions: null, - is_word: null - }, - methods: { - searchWord: function() { - if(!this.word) return; - if(this.timer) { - clearTimeout(this.timer); - this.timer = undefined; - } - console.log(this.word); - fetch(`/def?w=${this.word}`) - .then((response) => { - this.is_word = response.ok; - - if( response.ok ) { - response.arrayBuffer().then(res => { - this.definitions = msgpack.decode(new Uint8Array(res)); - console.log(this.definitions); - }); - } - }) - } - }, - watch: { - word: function(w) { - if( w === '' ) { - this.is_word = null; - } - if(this.timer) { - clearTimeout(this.timer); - this.timer = undefined; - } - this.timer = setTimeout(this.searchWord, 800); - } - } -}); diff --git a/web.py b/web.py index 282c200..4ed0f98 100644 --- a/web.py +++ b/web.py @@ -25,7 +25,16 @@ def index_client(): @app.route('/def', methods=['GET']) def get_def(): - if res := dicofr.get_def_sql(request.args.get('w')): + w = request.args.get('w') + + # Recherche du mot tapé + if res := dicofr.get_def_sql(w): + return msgpack.packb(res) + # Recherche du mot en minuscule + elif res := dicofr.get_def_sql(w.lower()): + return msgpack.packb(res) + # Recherche du mot en nom propre + elif res := dicofr.get_def_sql(w.title()): return msgpack.packb(res) else: return Response("", status=404) -- cgit v1.2.3