var inviteButton = $('.invite-button');

inviteButton.on('click', function() {
  var email = encodeURIComponent($('.invite-email').val());
  var time = (new Date).getTime();
  var token = "xoxp-3359469240-3368537646-3525848797-5d232a";
  var subdomain = "phackers";
  var url = "https://" + subdomain + ".slack.com/api/users.admin.invite?t=" + time +"&email="+ email +"&token="+ token + "&set_active=true";
  $.ajax({
    type: "POST",
    url: url,
    success: function(response) {
      if (response.ok === false) {
        var error_msg = response.error.split("_").join(" ");
        inviteButton.text(error_msg);
      } else if (response.ok === true) {
        inviteButton.text("Checked your email");
      }
    }
  });
});

function getTotalUsers() {
  var url = "https://phackers.slack.com/api/users.list?token=xoxp-3359469240-3368537646-3525848797-5d232a";
  $.ajax({
    type: "GET",
    url: url,
    success: function(response) {
      var totalUsers = response.members.length;
      var currentUsersTotal = $('.total-users').text(totalUsers);
    }
  })
}

getTotalUsers();
@@ -1,12 +1,29 @@
+(function() %7B%0A%0A  
 var inviteBu
@@ -53,47 +53,8 @@
 n');
-%0A%0AinviteButton.on('click', function() %7B
 %0A  v
@@ -85,17 +85,17 @@
 onent($(
-'
+%22
 .invite-
@@ -99,17 +99,17 @@
 te-email
-'
+%22
 ).val())
@@ -127,17 +127,16 @@
 e = 
-(
 new Date
 ).ge
@@ -131,16 +131,17 @@
 new Date
+(
 ).getTim
@@ -237,16 +237,125 @@
 ckers%22;%0A
+  var currentUsersTotal = $('.total-users');%0A%0A  getTotalUsers();%0A%0A  inviteButton.on(%22click%22, function() %7B%0A%0A  
   var ur
@@ -430,16 +430,17 @@
 + time +
+ 
 %22&email=
@@ -440,16 +440,17 @@
 &email=%22
+ 
 + email 
@@ -450,16 +450,17 @@
  email +
+ 
 %22&token=
@@ -460,16 +460,17 @@
 &token=%22
+ 
 + token 
@@ -491,16 +491,19 @@
 =true%22;%0A
+%0A
+  
   $.ajax
@@ -497,32 +497,34 @@
 ;%0A%0A    $.ajax(%7B%0A
+  
     type: %22POST%22
@@ -521,32 +521,34 @@
 pe: %22POST%22,%0A    
+ 
+ 
 url: url,%0A    su
@@ -533,32 +533,34 @@
       url: url,%0A
+  
     success: fun
@@ -583,16 +583,18 @@
 %7B%0A      
+  
 if (resp
@@ -618,24 +618,26 @@
 ) %7B%0A        
+ 
+ 
 var error_ms
@@ -677,32 +677,34 @@
 n(%22 %22);%0A        
+  
 inviteButton.tex
@@ -717,16 +717,18 @@
 r_msg);%0A
+  
       %7D 
@@ -760,32 +760,34 @@
 true) %7B%0A        
+  
 inviteButton.tex
@@ -821,27 +821,38 @@
     
+  
 %7D%0A    
+ 
+ 
 %7D%0A  
+ 
+ 
 %7D);%0A
+%0A  
 %7D);%0A%0A
+  
 func
@@ -874,16 +874,18 @@
 ers() %7B%0A
+  
   var ur
@@ -897,24 +897,33 @@
 https://
-phackers
+%22 + subdomain + %22
 .slack.c
@@ -950,55 +950,21 @@
 ken=
-xoxp-3359469240-3368537646-3525848797-5d232a%22
+%22 + token
 ;%0A
+  
   $.
@@ -966,24 +966,26 @@
    $.ajax(%7B%0A
+  
     type: %22G
@@ -989,24 +989,26 @@
  %22GET%22,%0A    
+ 
+ 
 url: url,%0A  
@@ -1001,24 +1001,26 @@
   url: url,%0A
+  
     success:
@@ -1037,24 +1037,26 @@
 response) %7B%0A
+  
       var to
@@ -1097,19 +1097,17 @@
 ;%0A      
-var
+ 
  current
@@ -1116,36 +1116,16 @@
 ersTotal
- = $('.total-users')
 .text(to
@@ -1135,24 +1135,26 @@
 Users);%0A
+  
     %7D%0A  
 %7D)%0A%7D%0A%0Age
@@ -1149,26 +1149,21 @@
 %7D%0A  
-%7D)%0A%7D%0A%0AgetTotalUsers();
+  %7D);%0A  %7D%0A%0A%7D());%0A

refactor a bit of jquery code