From cc370555c78bfd2ffc83943f7857fff2f3a6f625 Mon Sep 17 00:00:00 2001 From: Igor Nurullaev Date: Thu, 5 Sep 2019 17:01:14 +0300 Subject: [PATCH] Added ply checks --- Server/static/js/main.js | 39 +++++++++++++++++++++++++++++--------- Server/templates/main.html | 2 +- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Server/static/js/main.js b/Server/static/js/main.js index e7093c7..69cfcb2 100644 --- a/Server/static/js/main.js +++ b/Server/static/js/main.js @@ -174,11 +174,19 @@ function setStartTime() { } function takeOff() { - sendCommandToSelected('takeoff'); + if (table.getSelectedRows().length > 0) { + askPermission('Are you sure you want to take off this copters?', function () { + sendCommandToSelected('takeoff'); + }); + } } function flipCopters() { - sendCommandToSelected('flip'); + if (table.getSelectedRows().length > 0) { + askPermission('Are you sure you want to flip this copters?', function () { + sendCommandToSelected('flip'); + }); + } } function land() { @@ -224,11 +232,24 @@ function emLand() { } function startAnimation() { - spinner.style.display = 'inline-block'; - setTimeout(function () { - let req = new XMLHttpRequest(); - req.open('POST', '/start_animation', false); - req.send(); - spinner.style.display = 'none'; - }, 20); + askPermission('Are you sure you want to start animation?', function () { + spinner.style.display = 'inline-block'; + setTimeout(function () { + let req = new XMLHttpRequest(); + req.open('POST', '/start_animation', false); + req.send(); + spinner.style.display = 'none'; + }, 20); + }); +} + +function askPermission(text, func) { + Ply.dialog("confirm", + {}, + text + ).done(function (e) { + if (e.state) { + func(); + } + }); } \ No newline at end of file diff --git a/Server/templates/main.html b/Server/templates/main.html index a1dfda7..c919983 100644 --- a/Server/templates/main.html +++ b/Server/templates/main.html @@ -11,7 +11,7 @@ - +