From 66d8eb39ebdcd3fdf2749c0614e7f33afd572837 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 8 Dec 2017 00:59:01 +0100 Subject: [PATCH] fix: view.main (added geolocation) | upd: vue.emergency|vue.event (added geolocation use) --- view/main.js | 4 +++- view/vue/container/emergency.vue | 2 +- view/vue/container/event.vue | 21 +++++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/view/main.js b/view/main.js index 4e094b6..29a67d6 100755 --- a/view/main.js +++ b/view/main.js @@ -60,4 +60,6 @@ delete window._router_; /* (4) Get geolocation ---------------------------------------------------------*/ -navigator.geolocation && navigator.geolocation.getCurrentPosition(function(a, b){ console.log(this, a, b); }, null); +navigator.geolocation && navigator.geolocation.getCurrentPosition(function(loc){ + gstore.data.loc = [ loc.coords.latitude, loc.coords.longitude ]; +}, null); diff --git a/view/vue/container/emergency.vue b/view/vue/container/emergency.vue index 4b291b3..73687ad 100644 --- a/view/vue/container/emergency.vue +++ b/view/vue/container/emergency.vue @@ -55,7 +55,7 @@ export default { /* (2) Prepare request */ var rq = { message: this.gstore.new_msg.emergency, - location: [1.1, 2.2], + location: this.gstore.loc, username: this.gstore.server.session.name }; diff --git a/view/vue/container/event.vue b/view/vue/container/event.vue index 9c7f8ac..91fad1f 100644 --- a/view/vue/container/event.vue +++ b/view/vue/container/event.vue @@ -49,14 +49,27 @@ export default { if( msg.trim().length == 0 ) return; - /* (2) Send message to WebSocket */ - wsc_event.send(JSON.stringify({message: msg, location: [1.1, 2.2]})); + /* (2) Prepare request */ + var rq = { + message: this.gstore.new_msg.event, + location: this.gstore.loc, + username: this.gstore.server.session.name + }; /* (3) Add loader */ gstore.data.msg_pending.event = true; - /* (4) Empty input */ - this.gstore.new_msg.event = ''; + /* (4) Send request */ + api.call("POST message/event/"+this.dep, rq, function(rs){ + + // {1} If error -> exit // + if( rs.error != 0 ) + return; + + // {2} Empty input // + gstore.data.new_msg.event = ''; + + }); }, bbcode: function(msg){