diff --git a/predict/ajax.php b/predict/ajax.php index 8ba5e4a..263ad04 100644 --- a/predict/ajax.php +++ b/predict/ajax.php @@ -3,6 +3,8 @@ require_once("includes/functions.inc.php"); $action = $_GET['action']; +$software_available = array("gfs", "gfs_hd"); + switch($action) { case "getCSV": $uuid = $_GET['uuid']; @@ -35,7 +37,7 @@ case "getModelByUUID": } else { // populate the array, JSON encode it and return $pred_model = parse_ini_file("preds/".$uuid."/scenario.ini"); - if ( verifyModel($pred_model) ){ + if ( verifyModel($pred_model, $software_available) ){ $pred_model['valid'] == true; } else { $pred_model['valid'] == false; @@ -46,8 +48,6 @@ case "getModelByUUID": break; case "submitForm": - $software_available = array("gfs", "gfs_hd"); - $pred_model = array(); if ( isset($_POST['submit'])) { diff --git a/predict/css/pred.css b/predict/css/pred.css index 77b2f93..7891b21 100644 --- a/predict/css/pred.css +++ b/predict/css/pred.css @@ -69,6 +69,8 @@ a { text-decoration: underline; color: #333; cursor: pointer; } left: 0; bottom: 0; border-left: none; border-bottom: none; + max-height: 400px; + overflow: scroll; } #input_form { @@ -77,25 +79,19 @@ a { text-decoration: underline; color: #333; cursor: pointer; } height:350px; width: 400px; padding: 5px; + bottom: 0; right: 0; } #scenario_info { + position: absolute; + top: 25px; + right: 0px; border-right: none; - height:100px; + height:70px; width: 400px; - padding: 5px; - top: -115px; - overflow: hidden; } -#bottom_right { - right: 0; - bottom: 0; - width: 400px; - padding: 0px; -} - td.right-td { text-align: right; } diff --git a/predict/index.php b/predict/index.php index ad18887..00b1e96 100644 --- a/predict/index.php +++ b/predict/index.php @@ -57,15 +57,24 @@ function initialize() { } } }); - //$("#input_form").draggable({containment: '#map_canvas'}); + $("#input_form").draggable({containment: '#map_canvas'}); if ( current_uuid != '0' ) { appendDebug("Got an old UUID to plot:
" + current_uuid); + appendDebug("Trying to populate form with scenario data"); + populateFormByUUID(current_uuid); appendDebug("Trying to get flight path from server..."); getCSV(current_uuid); } - $("#debuginfo").hide(); + $("#scenario_template").hide(); $("#showHideDebug").click(function() { - toggleDebugWindow(); + toggleWindow("scenario_template", "showHideDebug", "Show Debug", "Hide Debug"); + }); + $("#showHideDebug_status").click(function() { + toggleWindow("scenario_template", "showHideDebug", "Show Debug", "Hide Debug"); + }); + $("#showHideForm").click(function() { + toggleWindow("input_form", "showHideForm", "Show Launch Card", + "Hide Launch Card"); }); } @@ -78,9 +87,7 @@ function initialize() {
-

Debug Window - -Show -

+

Debug Window

No Messages
@@ -88,15 +95,17 @@ function initialize() {

-
+
+Toggle Debug -
-info on scenario +

Scenario Information

+Show Debug | +Hide Launch Card
-
+
@@ -176,8 +185,7 @@ info on scenario
-
- +
diff --git a/predict/js/pred.js b/predict/js/pred.js index 07ddabc..aeb6602 100644 --- a/predict/js/pred.js +++ b/predict/js/pred.js @@ -21,9 +21,22 @@ function predSub() { $("#status_message").fadeIn(250); } +function populateFormByUUID(pred_uuid) { + $.get("ajax.php", { "action":"getModelByUUID", "uuid":pred_uuid }, function(data) { + if ( !data.valid ) { + appendDebug("Populating form by UUID failed"); + appendDebug("The server said the model it made was invalid"); + } else { + // we're good to go, populate the form + alert(data); + } + }, 'json'); +} + function handlePred(pred_uuid) { $("#prediction_status").html("Searching for wind data..."); $("#input_form").hide("slide", { direction: "down" }, 500); + $("#scenario_info").hide("slide", { direction: "up" }, 500); $("#map_canvas").fadeTo(1000, 0.2); // ajax to poll for progress ajaxEventHandle = setInterval("getJSONProgress('"+pred_uuid+"')", 2000); @@ -70,6 +83,9 @@ function processProgress(progress) { $("#prediction_percent").html(""); // bring the input form back up $("#input_form").show("slide", { direction: "down" }, 500); + $("#scenario_info").show("slide", { direction: "up" }, 500); + toggleWindow("scenario_template", "showHideDebug", "Show Debug", + "Hide Debug", "hide"); // un-fade the map canvas $("#map_canvas").fadeTo(1500, 1); appendDebug("Server says: the predictor finished running."); @@ -205,16 +221,28 @@ function appendDebug(appendage, clear) { } else { $("#debuginfo").html(""); } + // keep the debug window scrolled to bottom + $("#scenario_template").animate({scrollTop: $('#scenario_template')[0].scrollHeight}); } -function toggleDebugWindow() { - if( $("#debuginfo").css('display') != "none" ){ - $("#debuginfo").hide("slide", { direction: "down" }, 500); - $("#showHideDebug").html("Show"); +function toggleWindow(window_name, linker, onhide, onshow, force) { + if ( force == null ) { + if( $("#"+window_name).css('display') != "none" ){ + $("#"+window_name+"").hide("slide", { direction: "down" }, 500); + $("#"+linker).html(onhide); } else { - $("#debuginfo").show("slide", { direction: "down" }, 500); - $("#showHideDebug").html("Hide"); + $("#"+window_name).show("slide", { direction: "down" }, 500); + $("#"+linker).html(onshow); } + } else if ( force == "hide" ) { + $("#"+window_name+"").hide("slide", { direction: "down" }, 500); + $("#"+linker).html(onhide); + } else if ( force == "show") { + $("#"+window_name).show("slide", { direction: "down" }, 500); + $("#"+linker).html(onshow); + } else { + appendDebug("toggleWindow force parameter unrecognised"); + } } // launch site dropdown switcher