Implemented saving locations to cookie with Jookie. Removed emailing

pull/73/head
jonsowman 2010-08-10 20:08:46 +00:00
rodzic 20e5661cbd
commit 618093fb7e
3 zmienionych plików z 55 dodań i 14 usunięć

Wyświetl plik

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

Wyświetl plik

@ -33,6 +33,7 @@ google.load("jquery", "1.4.2");
google.load("jqueryui", "1.8.1");
</script>
<script src="js/jquery.form.js" type="text/javascript"></script>
<script src="js/jquery.jookie.js" type="text/javascript"></script>
<script src="js/date.jsport.js" type="text/javascript"></script>
<script src="js/pred.js" type="text/javascript"></script>
<script type="text/javascript">
@ -129,13 +130,18 @@ var hlTimeout = 5000; // high latency
</tr><tr>
<td>Site Name: </td><td><input type="text" name="req_name" id="req_name" size="10"></td>
</tr><tr>
<td></td><td><input type="submit" value="Request" name="submit" id="req_sub_btn"></td>
<td></td><td><input type="button" value="Request" name="submit" id="req_sub_btn"></td>
</tr>
</table>
</form><br />
<a id="req_close">Close this window</a>
</div>
<!-- cookie save location -->
<div id="location_save_local" class="box ui-corner-all">
<b>Saved Locations</b><br />
</div>
<!-- the about window -->
<div id="about_window">
<b>Cambridge University Spaceflight Landing Predictor (<a href="http://github.com/jonsowman/cusf-standalone-predictor" target="_blank">github</a>)</b>
@ -168,8 +174,8 @@ var hlTimeout = 5000; // high latency
<td><input id="lon" type="text" name="lon" value="0.0964" onKeyDown="SetSiteOther()"></td>
</tr>
<tr>
<td><a id="setWithClick">Set with map</a></td>
<td><a id="req_open">Request to save</a></td>
<td><a id="setWithClick">Set With Map</a></td>
<td><a id="req_open">Save Location</a></td>
</tr>
<tr>
<td>Launch altitude (m):</td>

Wyświetl plik

@ -602,19 +602,42 @@ 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");
}
$("#req_sub_btn").click(function() {
// Get the variables from the form
var req_lat = $("#req_lat").val();
var req_lon = $("#req_lon").val();
var req_alt = $("#req_alt").val();
var req_name = $("#req_name").val();
var cookie_name = "cusf_predictor";
// Now let's init the cookie
$.Jookie.Initialise(cookie_name, 99999999);
if ( !$.Jookie.Get(cookie_name, "idx") ) {
$.Jookie.Set(cookie_name, "idx", 0);
var idx = 0;
} else {
var idx = $.Jookie.Get(cookie_name, "idx");
}
if ( $.Jookie.Get(cookie_name, "idx") > 20 ) {
throwError("Too many saved locations");
} else {
idx++;
$.Jookie.Set(cookie_name, idx+"_lat", req_lat);
$.Jookie.Set(cookie_name, idx+"_lon", req_lon);
$.Jookie.Set(cookie_name, idx+"_alt", req_alt);
$.Jookie.Set(cookie_name, idx+"_name", req_name);
// Increase the index
$.Jookie.Set(cookie_name, "idx", idx);
// Close dialog and let the user know it worked
$("#location_save").hide();
throwError("Successfully saved the location to cookie " + cookie_name);
}
});
// activate the "Set with Map" link
$("#setWithClick").click(function() {
setLatLonByClick(true);