function show(tag){
  $('.checking4updates').hide();
  $('.staged-error').hide();
  $('.no-internet-error').hide();
  $('.demo-mode-error').hide();
  $('.up2date').hide();
  $('.update-ready').hide();
  $('.updating').hide();
  $('.staged-done').hide();
  $(tag).show();
}

$( document ).ready(function() {
  $('.admin-logout-button').click(function(){

  });

  $('.check-updates-menu').on( "click", function(){
    show('.checking4updates');
    $.ajax({
      url: '/update/',
      type: 'GET',
      success: function(result) {
        res = JSON.parse(result);
        if(res.error){
          if(res.code == -1){
            show('.staged-error');
          }
          if(res.code == -2){
            show('.no-internet-error');
          }
          if(res.code == -3){
            show('.demo-mode-error');
          }
        }
        else if(res.current_version){
          if(res.commits_behind == 0){
            show('.up2date');
          }
          else{
            $('.update-ready > p').text('Your server is ' + res.commits_behind + ' commits behind. Please use the button bellow to start the update proccess.');
            show('.update-ready');
          }
        }
      }
    });
  });

  $('.update-btn').on( "click", function(){
    show('.updating');
    $.ajax({
      url: '/update/',
      type: 'PUT',
      success: function(result) {
        res = JSON.parse(result);
        if(res.error){
          if(res.code == -1){
            show('.staged-error');
          }
          if(res.code == -2){
            show('.no-internet-error');
          }
        }
        else if(res.commits_behind){
          if(res.status == 'restarting'){
            show('.update-done');
          }
        }
      }
    });
  });
});

@@ -1390,32 +1390,58 @@
 .parse(result);%0A
+        console.log(res);%0A
         if(res.e
@@ -1633,42 +1633,8 @@
 lse 
-if(res.commits_behind)%7B%0A          
 if(r
@@ -1661,18 +1661,16 @@
 ting')%7B%0A
-  
         
@@ -1689,36 +1689,24 @@
 ate-done');%0A
-          %7D%0A
         %7D%0A  

update js final handling fix