New functionality: loading event details. TODO: add phase information

This commit is contained in:
Kasper D. Fischer 2014-05-06 16:55:31 +00:00
parent 3f3754a5e4
commit 6f2bfad0e5
Notes: subgit 2018-03-07 17:58:48 +01:00
r616 www/trunk

View File

@ -85,7 +85,6 @@ function ajaxLoadEvents(stime, etime) {
var otime = $(this).find('origin > time > value').text(); var otime = $(this).find('origin > time > value').text();
var lng = $(this).find('origin > longitude > value').text(); var lng = $(this).find('origin > longitude > value').text();
var lat = $(this).find('origin > latitude > value').text(); var lat = $(this).find('origin > latitude > value').text();
var mag = $(this).find('magnitude > mag > value').text();
var evaluationMode = $(this).find('evaluationMode').text(); var evaluationMode = $(this).find('evaluationMode').text();
var evaluationStatus = $(this).find('evaluationStatus').text(); var evaluationStatus = $(this).find('evaluationStatus').text();
var type = $(this).find('type').last().text(); var type = $(this).find('type').last().text();
@ -107,7 +106,7 @@ function ajaxLoadEvents(stime, etime) {
+ '<td><a href="#" class="toggle" eventid="'+id+'">'+location+'</a><a class="map-link" href="#" eventid="'+id+'">Karte</a></td>' + '<td><a href="#" class="toggle" eventid="'+id+'">'+location+'</a><a class="map-link" href="#" eventid="'+id+'">Karte</a></td>'
+ '</tr>'; + '</tr>';
row += '<tr class="tablesorter-childRow">' row += '<tr class="tablesorter-childRow">'
+ '<td colspan="4" eventid="'+id+'">not implemented</td></tr>'; + '<td colspan="4" eventid="'+id+'">Daten werden geladen ...</td></tr>';
var added = $('#eventstable tbody').append(row); var added = $('#eventstable tbody').append(row);
added.find('.tablesorter-childRow td').hide(); added.find('.tablesorter-childRow td').hide();
$('#eventstable').find('td.utctime-date').each(function() { $('#eventstable').find('td.utctime-date').each(function() {
@ -145,6 +144,60 @@ function ajaxLoadEvents(stime, etime) {
}); });
}; };
/* ajaxLoadEventInfo */
function ajaxLoadEventInfo(id) {
var request_data = {
eventid: id,
includeArrivals: true,
};
$.ajax({
type: "GET",
url: config['ajax']['eventURL'],
data: request_data,
dataType: "xml",
success: function (xml) {
eventDetails[id] = true;
$(xml).find('event').each(function () {
var mag = $(this).find('magnitude > mag > value').text();
var otime = $(this).find('origin > time > value').text();
var lng = $(this).find('origin > longitude > value').text();
var lng_err = $(this).find('origin > longitude > uncertainty').text();
var lat = $(this).find('origin > latitude > value').text();
var lat_err = $(this).find('origin > latitude > uncertainty').text();
var depth = $(this).find('origin > depth > value').text();
var depth_err = $(this).find('origin > depth > uncertainty').text();
var rms = $(this).find('origin > quality > standardError').text();
var gap = $(this).find('origin > quality > azimuthalGap').text();
var phases_count = $(this).find('origin > quality > usedPhaseCount').text();
var type = $(this).find('type').last().text();
var row = "<pre>"
+ sprintf("ID %32s\n", id)
+ sprintf("Type %30s\n\n", type)
+ "Origin\n"
+ sprintf("Magnitude %13.1f\n", Number(mag))
+ sprintf("Date %18s\n", otime.split('T')[0])
+ sprintf("Time %18s UTC\n", otime.split('T')[1].substring(0, 11))
+ sprintf("Latitude %14.4f °N +- %4.1f km\n",Number(lat), Number(lat_err))
+ sprintf("Longitude %13.4f °E +- %4.1f km\n", Number(lng), Number(lng_err))
+ sprintf("Depth %14.1f km +- %4.1f km\n", Number(depth)/1000., Number(depth_err)/1000.)
+ sprintf("Residual RMS %7.1f sec\n", Number(rms))
+ sprintf("Azimuthal gap %6.1f °\n\n", Number(gap))
+ sprintf("%d Phase arrivals:\n", Number(phases_count))
+ "sta net dist azi phase time res wt sta\n";
row = row + '</pre>';
$('#eventstable > tbody > tr.tablesorter-childRow > td[eventid='+id+']').html(row);
});
},
complete: function () {
console.log('Fetched details for event '+id);
},
error: function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
}
});
};
/* add row to table /* add row to table
obsolete */ obsolete */
function addEventRow(id, props) { function addEventRow(id, props) {
@ -311,6 +364,10 @@ $(document).ready(function() {
// show / hide event info // show / hide event info
$('#eventstable').delegate('.toggle', 'click' , function(){ $('#eventstable').delegate('.toggle', 'click' , function(){
// load event details
var eventid = $(this).attr('eventid');
( eventDetails[eventid] ) ? null : ajaxLoadEventInfo(eventid);
// toggle visibility of selected row // toggle visibility of selected row
$(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle('slow'); $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle('slow');
@ -319,7 +376,7 @@ $(document).ready(function() {
$(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').addClass('selected-now'); $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').addClass('selected-now');
$(this).closest('tbody').find('td.selected').each(function(){ $(this).closest('tbody').find('td.selected').each(function(){
if ( ! $(this).hasClass('selected-now') ) { if ( ! $(this).hasClass('selected-now') ) {
$(this).hide('slow'); $(this).hide();
$(this).removeClass('selected'); $(this).removeClass('selected');
}; };
}); });