Skip to content

Commit

Permalink
Added ignore cooldown option
Browse files Browse the repository at this point in the history
  • Loading branch information
yatendra1999 committed Jul 25, 2020
1 parent 03883e9 commit 0e94613
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 49 deletions.
Binary file removed icon.png
Binary file not shown.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<label for="coordinates">Coordinates</label>
<input class="form-control" id="new_coordinates">
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Ignore Cooldown</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
Expand Down
117 changes: 69 additions & 48 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,58 +73,79 @@ const form = document.getElementById("Fly-coord")
form.addEventListener('submit',function(event){
event.preventDefault();
entered_coords = event.target[0].value;
// console.log(entered_coords)
let options = {
mode: 'text',
pythonOptions: ['-u']
};
console.log(options)
if(current_coords == -1){
console.log(event)
if (event.target[1].checked == true){
fly_path = path.join(__dirname,"fly.py")
current_coords = entered_coords;
current_coords = entered_coords;
temp = current_coords.split(',');
document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
options = {
mode: 'text',
pythonOptions: ['-u']
};
options.args = ['fly', current_coords]
PythonShell.run(fly_path, options, function(err){
if (err) throw err;
})
}
options.args = ['getcd', entered_coords, current_coords]
console.log(options.args)
fly_path = path.join(__dirname,"fly.py")
PythonShell.run(fly_path, options, function(err, results){
if (err) throw err;
console.log(results);
cd = JSON.parse(results[0]);
cd = cd.cooldown;
cd = cd * 10;
let counter = 0;
// console.log(cd)
cd_bar = document.getElementById('cooldown_bar');
cd_bar.style.display = 'flex';
var per = 0
cd_bar.style.width = per+"%";
function update_progress(){
else{
let options = {
mode: 'text',
pythonOptions: ['-u']
};
console.log(options)
if(current_coords == -1){
current_coords = entered_coords;
}
options.args = ['getcd', entered_coords, current_coords]
console.log(options.args)
fly_path = path.join(__dirname,"fly.py")
PythonShell.run(fly_path, options, function(err, results){
if (err) throw err;
console.log(results);
cd = JSON.parse(results[0]);
cd = cd.cooldown;
cd = cd * 10;
let counter = 0;
// console.log(cd)
cd_bar = document.getElementById('cooldown_bar');
cd_bar.style.display = 'flex';
var per = 0
cd_bar.style.width = per+"%";
per += 1;
console.log("progress: "+per+"%");
if(per<100){
setTimeout(update_progress,cd);
function update_progress(){
cd_bar.style.width = per+"%";
per += 1;
console.log("progress: "+per+"%");
if(per<100){
setTimeout(update_progress,cd);
}
else{
//[todo] : call actual fly
current_coords = entered_coords;
temp = current_coords.split(',');
console.log("Cooldown over!")
console.log(temp)
document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
cd_bar.style.display = 'none';
options = {
mode: 'text',
pythonOptions: ['-u']
};
options.args = ['fly', current_coords]
PythonShell.run(fly_path, options, function(err){
if (err) throw err;
})
}
}
else{
//[todo] : call actual fly
current_coords = entered_coords;
temp = current_coords.split(',');
console.log("Cooldown over!")
console.log(temp)
document.getElementById("curr_lat").innerText = "Latitude : " + temp[0];
document.getElementById("curr_lon").innerText = "Longitude : " + temp[1];
cd_bar.style.display = 'none';
options = {
mode: 'text',
pythonOptions: ['-u']
};
options.args = ['fly', current_coords]
PythonShell.run(fly_path, options, function(err){
if (err) throw err;
})
}
}
setTimeout(update_progress,cd)
})
setTimeout(update_progress,cd)
})
}

// console.log(entered_coords)

})


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
]
},
"linux": {
"icon" : "icon.png",
"icon" : "icons/ico.png",
"target": [
"AppImage",
"deb"
Expand Down

0 comments on commit 0e94613

Please sign in to comment.