

function updateTopicsGUI()
{

  ros.getTopics(function(result)
                {
                  ros.topics = result;
                });

  var topics = ros.topics;

  if(topics != null){
    var innerHTML = "";
    for (var i = 0; i < topics.length; i++ )
    {
      innerHTML = innerHTML.concat(topics[i]);
      innerHTML = innerHTML.concat("<br>");
    }
    document.getElementById("ROSTopics").innerHTML = innerHTML;
  }

};


function updateNodesGUI()
{

  ros.getNodes(function(result)
               {
                 ros.nodes = result;
               });

  var nodes = ros.nodes;

  nodes.sort()

  if(nodes != null){
    var innerHTML = "";
    for (var i = 0; i < nodes.length; i++ )
    {
      innerHTML = innerHTML.concat(nodes[i]);
      innerHTML = innerHTML.concat("<br>");
    }
    document.getElementById("ROSNodes").innerHTML = innerHTML;
  }

};

// window.setInterval(function(){

//   updateTopicsGUI();
//   updateNodesGUI();

// }, 5000);

function validateForm()
{
  ros.attemptConnection();
  return false;
};

function addInputsForConnection()
{

  var innerHTML = "";

  for (var i = 0; i < ros.connectioninfo.length; i ++)
  {

    console.log(ros.connectioninfo[i])
    el = document.getElementById("ConnectionInformation")

    innerHTML = innerHTML.concat("<span class=\"col-sm-1\">");
    innerHTML = innerHTML.concat("<input type=\"text\" class=\"form-control\" value=\"");
    innerHTML = innerHTML.concat(ros.connectioninfo[i])
    innerHTML = innerHTML.concat("\"/>")
    innerHTML = innerHTML.concat("</span>")
    if(i >0 && i < 4)
    {
      innerHTML = innerHTML.concat("<span class=\"col-sxm-1\">.</span>")
    }


  }
  el.innerHTML = innerHTML;

  console.log(innerHTML)


}

function mylog(input)
{
  console.log(input)
}





