diff --git a/html/index.html b/html/index.html index ad61240316a1356c9ba6a48a3da1e036960ae2bb..ed240ec3f4e841ddcfc9d6f2fb8a24d686d9aabc 100644 --- a/html/index.html +++ b/html/index.html @@ -19,6 +19,8 @@ <script src="./js-yaml/dist/js-yaml.min.js"></script> <link rel="stylesheet" href="style.css"> + + <script> document.title="ADC GUI"; @@ -91,7 +93,7 @@ action_goal.send(); document.getElementById("action_info").innerHTML = "Goal sent. Expecting feedback..."; - document.getElementById("action_info").style.backgroundColor = 'white' ; + document.getElementById("action_info").style.backgroundColor = 'yellow' ; feedback_watchdog_timer(); //action_running=true; //true when received feedback? @@ -286,28 +288,43 @@ } },2000); } - + function load_goals_from_yaml() { - goals_file = document.getElementById("goals_file").value; - var goals_from_yaml; + document.getElementById("goals_info").innerHTML = "Loading file"; + document.getElementById("goals_info").style.backgroundColor = 'yellow' ; + goals_file = document.getElementById("goals_file").value; + var goals_from_yaml; - $.get(goals_file).done(function (data) - //$.get( goals_file, function( data ) - { - goals_from_yaml = jsyaml.load( data ); - - //TODO: check if loaded succesfully or not - //console.log("Loaded goals"); - - goal_array_msg = new ROSLIB.Message( + $.ajax( { - goals: goals_from_yaml - }); + url: goals_file, + success: + function(result) + { + goals_from_yaml = jsyaml.load( result ); - goals_loaded=true; + goal_array_msg = new ROSLIB.Message( + { + goals: goals_from_yaml + }); - }); + goals_loaded=true; + document.getElementById("goals_info").innerHTML = "Loaded"; + document.getElementById("goals_info").style.backgroundColor = 'green' ; + document.getElementById('startStop').disabled=false; + }, + error: + function (xhr, ajaxOptions, thrownError) + { + //alert(xhr.status); + //alert(thrownError); + document.getElementById("goals_info").innerHTML = "Error loading file"; + document.getElementById("goals_info").style.backgroundColor = 'red' ; + document.getElementById('startStop').disabled=true; + } + } + ); } $(document).ready @@ -382,6 +399,8 @@ <input type="text" id="goals_file" value="./data/goals0.yaml" onchange="load_goals_from_yaml()"/> <br> + <span id="goals_info" > </span> + <br> <!--<button class="btn btn-primary" id = "load_goals_button" onclick = "load_goals_from_yaml()">Load goals</button>--> <hr>