diff --git a/www/events.js b/www/events.js index cbe7c05..af76769 100644 --- a/www/events.js +++ b/www/events.js @@ -85,7 +85,6 @@ function ajaxLoadEvents(stime, etime) { var otime = $(this).find('origin > time > value').text(); var lng = $(this).find('origin > longitude > 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 evaluationStatus = $(this).find('evaluationStatus').text(); var type = $(this).find('type').last().text(); @@ -107,7 +106,7 @@ function ajaxLoadEvents(stime, etime) { + ''+location+'Karte' + ''; row += '' - + 'not implemented'; + + 'Daten werden geladen ...'; var added = $('#eventstable tbody').append(row); added.find('.tablesorter-childRow td').hide(); $('#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 = "
"
+					+ 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 + '
'; + $('#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 obsolete */ function addEventRow(id, props) { @@ -311,6 +364,10 @@ $(document).ready(function() { // show / hide event info $('#eventstable').delegate('.toggle', 'click' , function(){ + // load event details + var eventid = $(this).attr('eventid'); + ( eventDetails[eventid] ) ? null : ajaxLoadEventInfo(eventid); + // toggle visibility of selected row $(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('tbody').find('td.selected').each(function(){ if ( ! $(this).hasClass('selected-now') ) { - $(this).hide('slow'); + $(this).hide(); $(this).removeClass('selected'); }; });