$(document).ready(function() { var actionNumber = 1; var variableNumber = 1; $('#add-action').click(function(event) { $('
').insertBefore($(this).parent()); actionNumber++; }); $('#add-variable').click(function(event) { $('
').insertBefore($(this).parent()); variableNumber++; }); if ($('.deep-thought').hasClass('alert')) { checkIfDoneDeploying(); } }); function checkIfDoneDeploying() { $.ajax({ type:'GET', url:'/deploying', dataType:'json', success: function(data) { if (!data.deploying) { $('.deep-thought').removeClass('alert') $('.deep-thought > h1').text('Deep Thought is finished deploying.'); $('#deploy').removeClass('disabled').removeAttr('disabled').attr('value', 'deploy'); } else { setTimeout(checkIfDoneDeploying, 5000); } } }); }