2018-02-23 01:34:57 +08:00
|
|
|
@section('scripts')
|
2020-02-02 02:05:56 +08:00
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
$("button.save_flight").click(async function (e) {
|
2018-02-23 01:34:57 +08:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
const btn = $(this);
|
2018-03-13 14:26:27 +08:00
|
|
|
const class_name = btn.attr('x-saved-class'); // classname to use is set on the element
|
2019-08-28 03:08:42 +08:00
|
|
|
const flight_id = btn.attr('x-id');
|
2018-02-23 01:34:57 +08:00
|
|
|
|
2019-08-28 03:08:42 +08:00
|
|
|
if (!btn.hasClass(class_name)) {
|
2020-02-02 02:05:56 +08:00
|
|
|
await phpvms.bids.addBid(flight_id);
|
2018-02-23 01:34:57 +08:00
|
|
|
|
2020-02-02 02:05:56 +08:00
|
|
|
console.log('successfully saved flight');
|
|
|
|
btn.addClass(class_name);
|
|
|
|
alert('@lang("flights.bidadded")');
|
2018-03-13 14:26:27 +08:00
|
|
|
} else {
|
2020-02-02 02:05:56 +08:00
|
|
|
await phpvms.bids.removeBid(flight_id);
|
2018-03-13 14:26:27 +08:00
|
|
|
|
2020-02-02 02:05:56 +08:00
|
|
|
console.log('successfully removed flight');
|
|
|
|
btn.removeClass(class_name);
|
|
|
|
alert('@lang("flights.bidremoved")');
|
2019-08-28 03:08:42 +08:00
|
|
|
}
|
2020-02-02 02:05:56 +08:00
|
|
|
});
|
2018-02-23 01:34:57 +08:00
|
|
|
});
|
2020-02-02 02:05:56 +08:00
|
|
|
</script>
|
2018-02-23 01:34:57 +08:00
|
|
|
@endsection
|