  (function (){

  var methods                 = document.getElementById('method');
  var ulrInput                = document.getElementById('url');
  var supportsCredentialsInput = document.getElementById('supportsCredentials');
  var customHeadersInput      = document.getElementById('custom-headers');
  var button                  = document.getElementById('test');
  var result                  = document.getElementById('result');

  (function init(){
    ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'].forEach(function(item) {
      var option       = document.createElement('option');
      option.innerHTML = item;
      option.value     = item;
      methods.appendChild(option);
    });
    ulrInput.value = 'http://172.16.22.242:8080/api/teams';
    customHeadersInput.value = 'X-PINGOTHER';
    methods.selectedIndex = 0;
    button.addEventListener('click', initCorsTest);
  })();

  var xhr;

  function initCorsTest(e){

    if (!ulrInput.value || !methods.value){
      return;
    }

    e.preventDefault();
    xhr = new XMLHttpRequest();

    xhr.open(methods.value, ulrInput.value + '?x=' + +new Date, true);

    if (!!customHeadersInput.value){
      xhr.setRequestHeader(customHeadersInput.value, +new Date);
    }

    xhr.withCredentials = supportsCredentialsInput.checked;

    xhr.addEventListener("load",  transferComplete);
    xhr.addEventListener("error", transferFailed);
    xhr.addEventListener("abort", transferCanceled);

    result.innerHTML = 'Waiting..';
    xhr.send();
  }

  function showResults() {
      result.innerHTML =
        (xhr.readyState == 4 && xhr.status == 200)
          ? xhr.responseText
          : 'ERROR! Status is "' + xhr.status + '" and status text is "' + xhr.statusText+ '"';
    };

    function transferComplete(e){
      console.log("Transfer completed");
      console.log(e);
      showResults();
    }

    function transferFailed(e){
      console.log("Transfer failed");
      console.log(e);
      showResults();
    }

    function transferCanceled(e){
      console.log("Transfer canceled");
      console.log(e);
      showResults();
    }
})();
@@ -1,18 +1,16 @@
-  
 (function ()%7B%0A%0A 
@@ -30,32 +30,34 @@
                 
+  
 = document.getEl
@@ -99,32 +99,34 @@
                 
+  
 = document.getEl
@@ -174,16 +174,17 @@
 lsInput 
+ 
 = docume
@@ -251,24 +251,26 @@
 sInput      
+  
 = document.g
@@ -324,32 +324,34 @@
                 
+  
 = document.getEl
@@ -391,32 +391,34 @@
                 
+  
 = document.getEl
@@ -459,16 +459,21 @@
 init()%7B%0A
+    %0A
     %5B'GE
@@ -705,67 +705,8 @@
 %7D);%0A
-    ulrInput.value = 'http://172.16.22.242:8080/api/teams';
 %0A   
@@ -831,16 +831,19 @@
 sTest);%0A
+  %0A
   %7D)();%0A
@@ -847,20 +847,8 @@
 );%0A%0A
-  var xhr;%0A%0A
   fu
@@ -965,16 +965,20 @@
 ();%0A    
+var 
 xhr = ne
@@ -1478,16 +1478,19 @@
 Results(
+xhr
 ) %7B%0A    
@@ -1694,18 +1694,16 @@
     %7D;%0A%0A
-  
   functi
@@ -1722,26 +1722,24 @@
 omplete(e)%7B%0A
-  
     console.
@@ -1761,34 +1761,32 @@
 ompleted%22);%0A    
- 
- 
 console.log(e);%0A
@@ -1781,34 +1781,32 @@
 ole.log(e);%0A    
-  
 showResults();%0A 
@@ -1797,36 +1797,48 @@
 showResults(
+e.currrentTarget
 );%0A
-  
   %7D%0A%0A
-  
   function t
@@ -1847,34 +1847,32 @@
 nsferFailed(e)%7B%0A
-  
     console.log(
@@ -1887,34 +1887,32 @@
 r failed%22);%0A    
-  
 console.log(e);%0A
@@ -1907,34 +1907,32 @@
 ole.log(e);%0A    
-  
 showResults();%0A 
@@ -1927,28 +1927,40 @@
 Results(
+e.currrentTarget
 );%0A
-  
   %7D%0A%0A
-  
   functi
@@ -1983,26 +1983,24 @@
 led(e)%7B%0A    
-  
 console.log(
@@ -2025,18 +2025,16 @@
 %22);%0A    
-  
 console.
@@ -2045,18 +2045,16 @@
 e);%0A    
- 
- 
 showResu
@@ -2057,21 +2057,35 @@
 Results(
+e.currrentTarget
 );%0A
-  
   %7D%0A%7D)()

Refactor index.js