aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2020-02-22 20:23:14 +0100
committerache <ache@ache.one>2020-02-22 20:23:14 +0100
commit1cde126e6f730605890cb299953e028d074ccf8a (patch)
tree2bc8b82fe12b75d7fae8a4652c1501fb70e70f19
parentTest no autocapitalize (diff)
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.
-rw-r--r--assets/web.js3
-rw-r--r--main.js0
-rw-r--r--web.js42
-rw-r--r--web.py11
4 files changed, 13 insertions, 43 deletions
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
--- a/main.js
+++ /dev/null
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)