Skip to content

Commit

Permalink
Adding teleport js
Browse files Browse the repository at this point in the history
  • Loading branch information
ejdanderson committed Mar 25, 2018
1 parent 6b975d6 commit 96cade2
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions static/js/teleport.js
@@ -0,0 +1,55 @@
(function($) {

$(document).ready(function(){
$('.js-teleport').click(function(e) {
$('.js-bobs-code').html('')
e.preventDefault();
$this = $(this);
$this.hide()
$pb = $this.siblings('.progress');
$pb.show();

$.post({
url : '/api/teleportsend',
data: {'sendit' : 1 },
success: function(response) {
load_progressbar(response);
},
dataType: 'json'
});
})
});

function load_results(response) {
$('.js-bobs-code').html(response.program);
$('.js-bobs-wvf').html(response.wvf);
$('.js-teleport').show()
$('.progress').hide()
}

function load_progressbar(response) {
var progressBar = $('.js-teleport-progress-bar'),

width = 0;
progressBar.width(width);
var interval = setInterval(function() {
width += 10;
progressBar.css('width', width + '%');
if (width >= 100) {
clearInterval(interval);
load_results(response);
}
}, 500);

}

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function demo() {
console.log('Taking a break...');
await sleep(2000);
console.log('Two second later');
}
})(jQuery);

0 comments on commit 96cade2

Please sign in to comment.