
socket.onopen = function(e) {
  
  
  socket.send("socket: Web Socket Open");
};

socket.onmessage = function(event) {
	
	var str = event.data;
	if (str.startsWith("[Command]"))
	{
       const value = document.getElementById('getmessage');
	  var S = str.replace("[Command]", "-"); 
	  value.value = S;
	}
    if (str.startsWith("[Status]")) 
	{
		const value = document.getElementById('getmessage');
		var S = str.replace("[Status]", "-"); 
		value.value = S;
    }
 
 if (str.startsWith("[BuEnable]")) 
	 EnableButtons();

 if (str.startsWith("[BuDisable]")) 
	DisableButtons();


};

socket.onclose = function(event) {
  if (event.wasClean) {
    alert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
  } else {
    // e.g. server process killed or network down
    // event.code is usually 1006 in this case
    alert('[close] Connection died');
  }
};

socket.onerror = function(error) {
  alert(`[error] ${error.message}`);
};


function SendUrl ( text )
   {
    if ( text != "" )
    {
		
		socket.send( "[MsgURL] = " + text );
	/*  var xhr = new XMLHttpRequest();
	xhr.open("GET", "/station_url?output=" + text, true); }
    xhr.send();	
	*/
    }
};

