var timer;
var MessageParser = (function(){
   function MessageParser(line){

   }

   return MessageParser;
})();

function onload(){
  if(is_websocket()){

  }else{
    setTimer();
    get("");
  }
}

function get(action){
  ajax("?ajax=true&action="+action);
}

function post(data){
 ajax("?ajax=true", data);
}

function send(msg){
  if(is_websocket()){
    websocket.send(msg);
    return;
  }
   stopTimer();
   post({
      "message" : msg
   });
}

function setTimer(){
  timer = setTimeout(function(){
     get("");
  }, 3000);
}

function stopTimer(){
  setTimeout(timer);
}

function ajax(url, data){
   var method = typeof data === "undefined" ? "GET" : "POST";
   var ajax = new XMLHttpRequest();
   ajax.XMLHttpRequest = function(){
      if(this.readyState == 4 && this.status == 200){
         var respons = this.responseText.split("\r\n");
         for(var i=0;i<respons.length;i++){
           handleMessage(respons[i]);
         }
         setTimer();
      }
   }
   ajax.open(method, url, true);
   if(method == "AJAX"){
      ajax.send();
   }else{
      ajax.send(data);
   }
}

function handleMessage(msg){
  msg = new MessageParser(msg);
}

@@ -70,21 +70,479 @@
 (line)%7B%0A
+     this.data = %7B%7D;%0A     first = line.substr(0, line.indexOf(%22: %22)).split(%22 %22);%0A     if(first%5B0%5D.indexOf(%22!%22) != -1)%7B%0A        parts = first%5B0%5D.split(%22!%22);%0A        this.data%5B%22prefix%22%5D = parts%5B0%5D;%0A        first%5B0%5D = parts%5B1%5D;%0A     %7D%0A     this.data%5B%22command%22%5D = first%5B0%5D;%0A     this.data%5B%22isCommand%22%5D = first.length == 1;%0A     this.data%5B%22channel%22%5D = this.isCommand() ? null : channel(first%5B1);%0A     this.data%5B%22message%22%5D = line.substr(line.indexOf(%22: %22)+2);%0A   %7D%0A
 %0A   
-%7D
 %0A%0A   ret

Update core.js