Skip to content

Commit

Permalink
formatting to js standard
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Mar 14, 2018
1 parent 57cddee commit 6975167
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 509 deletions.
11 changes: 0 additions & 11 deletions resources/js/admin/app.js

This file was deleted.

90 changes: 0 additions & 90 deletions resources/js/admin/sidebar.js

This file was deleted.

42 changes: 20 additions & 22 deletions resources/js/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,38 @@
* Bootstrap any Javascript libraries required
*/

window._ = require('lodash');
window.Popper = require('popper.js').default;
window.$ = window.jquery = require('jquery');
window.select2 = require('select2');
window.pjax = require('pjax');
window.axios = require('axios');
window._ = require('lodash')
window.Popper = require('popper.js').default
window.$ = window.jquery = require('jquery')
window.select2 = require('select2')
window.pjax = require('pjax')
window.axios = require('axios')

/**
* Container for phpVMS specific functions
*/
window.phpvms = {

};
window.phpvms = {}

/**
* Configure Axios with both the csrf token and the API key
*/
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
const token = document.head.querySelector('meta[name="csrf-token"]');
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
const token = document.head.querySelector('meta[name="csrf-token"]')

if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
window.jquery.ajaxSetup({
'X-CSRF-TOKEN': token.content
})
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content
window.jquery.ajaxSetup({
'X-CSRF-TOKEN': token.content
})
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token')
}

const api_key = document.head.querySelector('meta[name="api-key"]');
if(api_key) {
window.axios.defaults.headers.common['x-api-key'] = api_key.content;
window.PHPVMS_USER_API_KEY = api_key.content;
const api_key = document.head.querySelector('meta[name="api-key"]')
if (api_key) {
window.axios.defaults.headers.common['x-api-key'] = api_key.content
window.PHPVMS_USER_API_KEY = api_key.content
} else {
window.PHPVMS_USER_API_KEY = false;
console.error('API Key not found!');
window.PHPVMS_USER_API_KEY = false
console.error('API Key not found!')
}
41 changes: 20 additions & 21 deletions resources/js/maps/airspace_map.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
const _ = require('lodash')
const leaflet = require('leaflet')

const _ = require('lodash');
const leaflet = require('leaflet');

import draw_base_map from './base_map';
import draw_base_map from './base_map'

/**
* Render a map with the airspace, etc around a given set of coords
* e.g, the airport map
* @param opts
*/
export default (opts) => {
opts = _.defaults(opts, {
render_elem: 'map',
overlay_elem: '',
lat: 0,
lon: 0,
zoom: 12,
layers: [],
set_marker: false,
});
opts = _.defaults(opts, {
render_elem: 'map',
overlay_elem: '',
lat: 0,
lon: 0,
zoom: 12,
layers: [],
set_marker: false,
})

let map = draw_base_map(opts);
const coords = [opts.lat, opts.lon];
console.log('Applying coords', coords);
let map = draw_base_map(opts)
const coords = [opts.lat, opts.lon]
console.log('Applying coords', coords)

map.setView(coords, opts.zoom);
if (opts.set_marker === true) {
leaflet.marker(coords).addTo(map);
}
map.setView(coords, opts.zoom)
if (opts.set_marker === true) {
leaflet.marker(coords).addTo(map)
}

return map;
return map
};
112 changes: 56 additions & 56 deletions resources/js/maps/base_map.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
const _ = require('lodash');
const leaflet = require('leaflet');
const _ = require('lodash')
const leaflet = require('leaflet')

export default (opts) => {

opts = _.defaults(opts, {
render_elem: 'map',
center: [29.98139, -95.33374],
zoom: 5,
maxZoom: 10,
layers: [],
set_marker: false,
});
opts = _.defaults(opts, {
render_elem: 'map',
center: [29.98139, -95.33374],
zoom: 5,
maxZoom: 10,
layers: [],
set_marker: false,
})

let feature_groups = [];
/*var openaip_airspace_labels = new leaflet.TileLayer.WMS(
"http://{s}.tile.maps.openaip.net/geowebcache/service/wms", {
maxZoom: 14,
minZoom: 12,
layers: 'openaip_approved_airspaces_labels',
tileSize: 1024,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
let feature_groups = []
/*var openaip_airspace_labels = new leaflet.TileLayer.WMS(
"http://{s}.tile.maps.openaip.net/geowebcache/service/wms", {
maxZoom: 14,
minZoom: 12,
layers: 'openaip_approved_airspaces_labels',
tileSize: 1024,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
openaip_airspace_labels.addTo(map);*/
openaip_airspace_labels.addTo(map);*/

const opencyclemap_phys_osm = new leaflet.TileLayer(
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=f09a38fa87514de4890fc96e7fe8ecb1', {
maxZoom: 14,
minZoom: 4,
format: 'image/png',
transparent: true
});
const opencyclemap_phys_osm = new leaflet.TileLayer(
'http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=f09a38fa87514de4890fc96e7fe8ecb1', {
maxZoom: 14,
minZoom: 4,
format: 'image/png',
transparent: true
})

feature_groups.push(opencyclemap_phys_osm);
feature_groups.push(opencyclemap_phys_osm)

/*const openaip_cached_basemap = new leaflet.TileLayer("http://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.png", {
maxZoom: 14,
minZoom: 4,
tms: true,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
/*const openaip_cached_basemap = new leaflet.TileLayer("http://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.png", {
maxZoom: 14,
minZoom: 4,
tms: true,
detectRetina: true,
subdomains: '12',
format: 'image/png',
transparent: true
});
feature_groups.push(openaip_cached_basemap);
*/
feature_groups.push(openaip_cached_basemap);
*/

const openaip_basemap_phys_osm = leaflet.featureGroup(feature_groups);
const openaip_basemap_phys_osm = leaflet.featureGroup(feature_groups)

let map = leaflet.map('map', {
layers: [openaip_basemap_phys_osm],
center: opts.center,
zoom: opts.zoom,
scrollWheelZoom: false,
});
let map = leaflet.map('map', {
layers: [openaip_basemap_phys_osm],
center: opts.center,
zoom: opts.zoom,
scrollWheelZoom: false,
})

const attrib = leaflet.control.attribution({position: 'bottomleft'});
attrib.addAttribution("<a href=\"https://www.thunderforest.com\" target=\"_blank\" style=\"\">Thunderforest</a>");
attrib.addAttribution("<a href=\"https://www.openaip.net\" target=\"_blank\" style=\"\">openAIP</a>");
attrib.addAttribution("<a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\" style=\"\">OpenStreetMap</a> contributors");
attrib.addAttribution("<a href=\"https://www.openweathermap.org\" target=\"_blank\" style=\"\">OpenWeatherMap</a>");
const attrib = leaflet.control.attribution({position: 'bottomleft'})
attrib.addAttribution('<a href="https://www.thunderforest.com" target="_blank" style="">Thunderforest</a>')
attrib.addAttribution('<a href="https://www.openaip.net" target="_blank" style="">openAIP</a>')
attrib.addAttribution('<a href="https://www.openstreetmap.org/copyright" target="_blank" style="">OpenStreetMap</a> contributors')
attrib.addAttribution('<a href="https://www.openweathermap.org" target="_blank" style="">OpenWeatherMap</a>')

attrib.addTo(map);
attrib.addTo(map)

return map;
return map
};
5 changes: 2 additions & 3 deletions resources/js/maps/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export let
PLAN_ROUTE_COLOR = '#36b123',
ACTUAL_ROUTE_COLOR = '#172aea';
PLAN_ROUTE_COLOR = '#36b123',
ACTUAL_ROUTE_COLOR = '#172aea'
20 changes: 10 additions & 10 deletions resources/js/maps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* All of the functionality required for maps
*/

window.L = require('leaflet');
require('Leaflet.Geodesic');
require('leaflet-rotatedmarker');
window.L = require('leaflet')
require('Leaflet.Geodesic')
require('leaflet-rotatedmarker')

import render_airspace_map from './airspace_map';
import render_live_map from './live_map';
import render_route_map from './route_map';
import render_airspace_map from './airspace_map'
import render_live_map from './live_map'
import render_route_map from './route_map'

export {
render_airspace_map,
render_live_map,
render_route_map,
};
render_airspace_map,
render_live_map,
render_route_map,
}
Loading

0 comments on commit 6975167

Please sign in to comment.