Set the baseURL for ajax requests (#373)

* Set the baseURL for ajax requests

* Use async/await on AJAX calls

* Add mix_public() cache generated asset cache busting

* Move storage container into separate class

* Fix some styling
This commit is contained in:
Nabeel S
2019-08-27 15:08:42 -04:00
committed by GitHub
parent fd2f4f2150
commit 09f3e3cfdf
16 changed files with 335 additions and 145 deletions

View File

@@ -1,5 +1,7 @@
@section('scripts')
<script>
'use strict';
function setEditable() {
const csrf_token = $('meta[name="csrf-token"]').attr('content');
const api_key = $('meta[name="api-key"]').attr('content');
@@ -81,26 +83,32 @@ $(document).ready(function() {
}
});
$('a.airport_data_lookup').click(function(e) {
$('a.airport_data_lookup').click(async function(e) {
e.preventDefault();
const icao = $("input#airport_icao").val();
if(icao === '') {
return;
}
phpvms.airport_lookup(icao, function(response) {
_.forEach(response.data, function(value, key) {
if(key === 'city') {
key = 'location';
}
let response;
try {
response = await phpvms.airport_lookup(icao);
} catch (e) {
console.log('Error looking up airport!', e);
return;
}
$("#" + key).val(value);
_.forEach(response.data, function (value, key) {
if (key === 'city') {
key = 'location';
}
if(key === 'tz') {
$("#timezone").val(value);
$("#timezone").trigger('change');
}
});
$("#" + key).val(value);
if (key === 'tz') {
$("#timezone").val(value);
$("#timezone").trigger('change');
}
});
});