Work on location save requesting

pull/73/head
jonsowman 2010-06-08 17:29:38 +01:00
rodzic 89cf9426a3
commit 36ba56364f
5 zmienionych plików z 72 dodań i 1 usunięć

Wyświetl plik

@ -30,6 +30,26 @@ case "JSONexists":
}
break;
case "locationSave":
$lat = $_POST['req_lat'];
$lon = $_POST['req_lon'];
$alt = $_POST['req_alt'];
$locname = $_POST['req_name'];
if ( $locname == '' ) {
echo "false ".$locname;
return;
}
$str = "Latitude: " . $lat . "\n" .
"Longitude: " . $lon . "\n" .
"Altitude: " . $alt . "\n" .
"Name: " . $locname . "\n";
if ( mail($c_admin_email, "Location Request Save", $str) ) {
echo "true";
} else {
echo "false";
}
break;
case "getModelByUUID":
$uuid = ( isset($_GET['uuid']) ? $_GET['uuid'] : false );
if( !uuid ) die ("No uuid given to getModelByUUID");

Wyświetl plik

@ -53,6 +53,18 @@ a { text-decoration: underline; color: #333; cursor: pointer; }
display: none;
}
#location_save {
position: absolute;
left: 50%;
top: 50%;
width: 500px;
margin-left: -250px;
margin-top: -120px;
padding: 1em;
text-align: center;
display: none;
}
.box {
position: absolute;
background-color: white;

Wyświetl plik

@ -1,5 +1,7 @@
<?php
$c_admin_email = "jon@hexoc.com";
$c_preds_path = "preds/";
$c_scenario_file = "scenario.ini";

Wyświetl plik

@ -115,6 +115,19 @@ land: <span id="cursor_pred_landrange">?</span>km
<a style="font-size: 10px" id="about_window_show">About this software</a>
</div>
<!-- save location -->
<div id="location_save" class="box">
<h1>Request Location Save</h1><br />
<form name="location_save_form" id="location_save_form">
Latitude: <input type="text" name="req_lat" id="req_lat"><br />
Longitude: <input type="text" name="req_lon" id="req_lon"><br />
Altitude: <input type="text" name="req_alt" id="req_alt"><br />
Name: <input type="text" name="req_name" id="req_name"><br />
<input type="submit" value="Request" name="submit" id="req_sub_btn">
</form><br />
<a id="req_close">Close this window</a>
</div>
<!-- the about window -->
<div id="about_window" class="box">
<b>Cambridge University Spaceflight Landing Predictor (<a href="http://github.com/jonsowman/cusf-standalone-predictor" target="_blank">github</a>)</b>
@ -152,7 +165,7 @@ No guarantee is given for the accuracy, precision or reliability of the data pro
</tr>
<tr>
<td><a id="setWithClick">Set with map</a></td>
<td><a id="requestLocationSave">Request to save</a></td>
<td><a id="req_open">Request to save</a></td>
</tr>
<tr>
<td>Launch altitude (m):</td>

Wyświetl plik

@ -514,6 +514,19 @@ function setupEventHandlers() {
}
}
});
$("#location_save_form").ajaxForm({
url: 'ajax.php?action=locationSave',
type: 'POST',
success: function(data) {
if (data == "true") {
appendDebug("Server returned OK - closing window");
$("#location_save").fadeOut();
} else {
alert("The server rejected the request for location save");
appendDebug("Failed to request location save from server");
}
}
});
// activate the "Set with Map" link
$("#setWithClick").click(function() {
setLatLonByClick(true);
@ -556,6 +569,17 @@ function setupEventHandlers() {
$("#site").change(function() {
changeLaunchSite();
});
$("#req_close").click(function() {
$("#location_save").fadeOut();
});
$("#req_open").click(function() {
$("#req_lat").val($("#lat").val());
$("#req_lon").val($("#lon").val());
$("#req_alt").val($("#initial_alt").val());
// this is bad, use a geocoder to guess it
$("#req_name").val("Unnamed");
$("#location_save").fadeIn();
});
google.maps.event.addListener(map, 'mousemove', function(event) {
showMousePos(event.latLng);
});