Skip to content

Commit

Permalink
Set url of backend in frontend from window location
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Bertrand committed Nov 23, 2016
1 parent 1da6775 commit 4eee066
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions public/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var styleLayer = L.mapbox.styleLayer('mapbox://styles/ecotaco/civ00flry01gx2jl8d
var featureGroup = L.featureGroup().addTo(map);
var polygon = null;
var drivers = [];
var socket = io('http://localhost:3000');
var host_back = window.location.origin;
var socket = io(host_back);
var drawControl = new L.Control.Draw({
edit: {
featureGroup: featureGroup,
Expand Down Expand Up @@ -141,7 +142,7 @@ $('#list').click(function() {
})

$.ajax({
url : 'http://localhost:3000/bots',
url : host_back + '/bots',
success : function(data){
var html = '';
data.forEach(function(bot){
Expand Down Expand Up @@ -321,23 +322,23 @@ function display_points() {
function delete_bot(id) {
$.ajax({
type: 'DELETE',
url : 'http://localhost:3000/bots/' + id
url : host_back + '/bots/' + id
});
swal.close();
}

function pause_bot(id) {
$.ajax({
type: 'POST',
url : 'http://localhost:3000/bots/' + id + '/deactivate'
url : host_back + '/bots/' + id + '/deactivate'
});
swal.close();
}

function active_bot(id) {
$.ajax({
type: 'POST',
url : 'http://localhost:3000/bots/' + id + '/active'
url : host_back + '/bots/' + id + '/active'
});
swal.close();
}

0 comments on commit 4eee066

Please sign in to comment.