Added support for detailed station information and download links. Funcionality is still missing.

This commit is contained in:
Kasper D. Fischer 2014-05-15 15:57:52 +00:00
parent f374ee0a1c
commit 5a1b780eaf
Notes: subgit 2018-03-07 17:58:56 +01:00
r655 www/trunk
2 changed files with 64 additions and 15 deletions

View File

@ -127,8 +127,15 @@ var config = {
NL_WIT: 3,
NL_WTSB: 3,
},
networkBlacklist: ['NL', 'X5'],
},
};
var networkText = {
GE: 'GEOFON Program, GFZ Potsdam, Germany',
GR: 'German Regional Seismic Network, BGR Hannover, Germany',
NL: 'Netherlands Seismic Network, The Netherlands',
RN: 'RuhrNet - Ruhr-University Bochum, Germany',
};
/**********************************************************************
* document ready *
@ -168,6 +175,7 @@ $(document).ready(function() {
var tabOptions = {
active: 0,
disabled: [2, 3],
activate: function( event, ui ) { ui['newPanel'].find('table').trigger("update", [true]); },
};
$('#tabs').tabs(tabOptions);
});

View File

@ -40,6 +40,7 @@ function loadStations(stime, etime) {
var request_data = {
endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()),
startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()),
level: 'station',
minlat: S-config['map']['latlngDelta'],
maxlat: N+config['map']['latlngDelta'],
minlon: W-config['map']['latlngDelta'],
@ -53,19 +54,27 @@ function loadStations(stime, etime) {
success: function (xml) {
$(xml).find('Network').each(function () {
var network = $(this).attr('code');
$(this).find('Station').each(function () {
var station = $(this).attr('code'),
lat = $(this).find('Latitude').text(),
lng = $(this).find('Longitude').text(),
stationID = network+'_'+station,
stationText = network+'.'+station;
if ( !stationTable[stationID] ) { // && N >= lat && S <= lat && W<= lng && E >= lng
var row = sprintf('<tr><td>%s</td><td>%s</td><td class="ar">%7.4f</td><td class="ar">%7.4f</td></tr>' , network, station, Number(lat), Number(lng));
var r = $(row);
$('#stationstable tbody').append(r);
addStationMarker(stationID, Number(lat), Number(lng), stationText.toUpperCase());
};
});
if ( $.inArray(network, config['station']['networkBlacklist'])<0 ) {
$(this).find('Station').each(function () {
var station = $(this).attr('code'),
lat = $(this).find('Latitude').text(),
lng = $(this).find('Longitude').text(),
stationID = network+'_'+station,
stationText = network+'.'+station;
if ( !stationTable[stationID] ) {
// general station info (1st line)
var row = sprintf('<tr><td><a href="#" class="toggle">%s</a></td><td><a href="#" class="toggle">%s</a></td><td class="ar">%7.4f</td><td class="ar">%7.4f</td></tr>' , network, station, Number(lat), Number(lng));
// setting up network details (2nd line)
row += sprintf('<tr class="tablesorter-childRow station-details"><td colspan="4">%s</td></tr>', networkText[network] || '');
// setting up station details (3rd line)
row += '<tr class="tablesorter-childRow station-details"><td colspan="4">not implemented</td></tr>';
// setting up download links (4th line)
row += '<tr class="tablesorter-childRow station-download"><td colspan="4">not implemented</td></tr>';
$('#stationstable tbody').append(row);
addStationMarker(stationID, Number(lat), Number(lng), stationText.toUpperCase());
};
});
};
});
},
complete: function () {
@ -110,7 +119,7 @@ function initStationTable() {
// css class names of pager arrows
pager_css: {
container : 'stations-tablesorter-pager',
errorRow : 'tablesorter-errorRow', // error information row (don't include period at beginning)
errorRow : 'stations-tablesorter-errorRow', // error information row (don't include period at beginning)
disabled : 'disabled' // class added to arrows @ extremes (i.e. prev/first arrows "disabled" on first page)
},
// jQuery pager selectors
@ -126,7 +135,7 @@ function initStationTable() {
},
filter_childRows : true,
filter_cssFilter : 'tablesorter-filter',
filter_cssFilter : 'stations-tablesorter-filter',
filter_startsWith : false,
filter_ignoreCase : true,
scroller_height: $('div.map').height() - 250,
@ -137,6 +146,12 @@ function initStationTable() {
showProcessing: true,
}
});
// hide child rows
$('#stationstable > tbody > tr.tablesorter-childRow > td').hide();
// update map after filtering
// $('#stationsstable').bind('filterEnd', function(){
// toggleFilteredMarkers();
// });
};
/**********************************************************************
@ -144,4 +159,30 @@ function initStationTable() {
**********************************************************************/
$(document).ready(function() {
loadStations();
// show / hide station info
$('#stationstable').delegate('.toggle', 'click' , function(){
// toggle visibility of selected row
$(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle('slow');
// mark currently selected row and remove class selected from all other rows
// hide other rows
$(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();
$(this).removeClass('selected');
};
});
$(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').each(function(){
$(this).removeClass('selected-now');
var selected = $(this).hasClass('selected');
if ( selected ) {
$(this).removeClass('selected');
//highlightFirstEvent();
} else {
$(this).addClass('selected');
//toggleHighlightStation($(this).attr('stationid'));
};
});
return false;
});
});