Adding copyright / license information to javascript files.

Reoorganizing code blocks.
This commit is contained in:
Kasper D. Fischer 2014-05-06 13:14:30 +00:00
parent d23b9f2a7c
commit 4b6fb951b2
Notes: subgit 2018-03-07 17:58:47 +01:00
r612 www/trunk
4 changed files with 186 additions and 76 deletions

View File

@ -1,3 +1,27 @@
/**********************************************************************
* events.js *
* script for event specific functions and setup *
**********************************************************************/
/* License
Copyright 2014 Kasper D. Fischer <kasper.fischer@rub.de>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see http://www.gnu.org/licenses/.
$Id$
*/
/* do reverse geolocation lookup */ /* do reverse geolocation lookup */
function getGeolocation(id, lat, lng) { function getGeolocation(id, lat, lng) {
if ( !geolocationTable[id] ) { if ( !geolocationTable[id] ) {
@ -119,7 +143,8 @@ function ajaxLoadEvents(stime, etime) {
}); });
}; };
// add row to table /* add row to table
obsolete */
function addEventRow(id, props) { function addEventRow(id, props) {
$('#eventstable').tablesorter({ $('#eventstable').tablesorter({
sortList: "[[0,0], [1,1]], [2,1]", sortList: "[[0,0], [1,1]], [2,1]",
@ -167,6 +192,79 @@ function addEventRow(id, props) {
$("#eventstable").trigger("update", [true]); $("#eventstable").trigger("update", [true]);
}; };
/* toggles visibility of filtered markers
* only events in the event list are shown */
function toggleFilteredMarkers() {
// show all shown events in map
$("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle({opacity: 1, strokeOpacity: 1, fillOpacity: eventMarkerOpacity});
};
});
// hide filtered events in map
$("#eventstable > tbody > tr.filtered > td > a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle({opacity: 0, strokeOpacity: 0, fillOpacity: 0});
};
});
highlightFirstEvent();
};
/* Highlight the first event of the event list on the map if no
* other event is selected */
function highlightFirstEvent() {
var highlightStyle = {
color: 'red',
fillColor: '#f03',
};
var normalStyle = {
fillColor: "#FFF500",
color: "#FFF500"
};
$("#eventstable a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle(normalStyle);
$(this).removeClass('first');
$(this).text('Karte');
};
});
$("#eventstable > tbody > tr:not(.filtered)").first().find("a.map-link").each(function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle(highlightStyle);
$(this).addClass('first');
$(this).text('Karte (rot)');
};
});
};
function highlightEvent( id ) {
var highlightStyle = {
color: 'red',
fillColor: '#f03',
};
var normalStyle = {
fillColor: "#FFF500",
color: "#FFF500"
};
$("#eventstable > tbody > tr:not(.filtered)").find("a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
if ( $(this).attr("eventid") == id ) {
eventTable[$(this).attr("eventid")].setStyle(highlightStyle);
$(this).addClass('first');
$(this).text('Karte (rot)');
} else {
eventTable[$(this).attr("eventid")].setStyle(normalStyle);
$(this).removeClass('first');
$(this).text('Karte');
}
};
});
};
/**********************************************************************
* document ready *
**********************************************************************/
$(document).ready(function() { $(document).ready(function() {
// tablesorter for event list // tablesorter for event list
$("#eventstable").tablesorter( $("#eventstable").tablesorter(

View File

@ -1,72 +1,26 @@
/* toggles visibility of filtered markers /**********************************************************************
* only events in the event list are shown */ * map.js *
function toggleFilteredMarkers() { * script for map specific functions and setup *
// show all shown events in map **********************************************************************/
$("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle({opacity: 1, strokeOpacity: 1, fillOpacity: eventMarkerOpacity});
};
});
// hide filtered events in map /* License
$("#eventstable > tbody > tr.filtered > td > a.map-link").each( function() { Copyright 2014 Kasper D. Fischer <kasper.fischer@rub.de>
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle({opacity: 0, strokeOpacity: 0, fillOpacity: 0});
};
});
highlightFirstEvent();
};
/* Highlight the first event of the event list on the map if no This program is free software: you can redistribute it and/or modify it
* other event is selected */ under the terms of the GNU General Public License as published by the Free
function highlightFirstEvent() { Software Foundation, either version 3 of the License, or (at your option)
var highlightStyle = { any later version.
color: 'red',
fillColor: '#f03',
};
var normalStyle = {
fillColor: "#FFF500",
color: "#FFF500"
};
$("#eventstable a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle(normalStyle);
$(this).removeClass('first');
$(this).text('Karte');
};
});
$("#eventstable > tbody > tr:not(.filtered)").first().find("a.map-link").each(function() {
if ( $(this).attr("eventid") ) {
eventTable[$(this).attr("eventid")].setStyle(highlightStyle);
$(this).addClass('first');
$(this).text('Karte (rot)');
};
});
};
function highlightEvent( id ) { This program is distributed in the hope that it will be useful, but
var highlightStyle = { WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
color: 'red', or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fillColor: '#f03', for more details.
};
var normalStyle = { You should have received a copy of the GNU General Public License along
fillColor: "#FFF500", with this program. If not, see http://www.gnu.org/licenses/.
color: "#FFF500"
}; $Id$
$("#eventstable > tbody > tr:not(.filtered)").find("a.map-link").each( function() { */
if ( $(this).attr("eventid") ) {
if ( $(this).attr("eventid") == id ) {
eventTable[$(this).attr("eventid")].setStyle(highlightStyle);
$(this).addClass('first');
$(this).text('Karte (rot)');
} else {
eventTable[$(this).attr("eventid")].setStyle(normalStyle);
$(this).removeClass('first');
$(this).text('Karte');
}
};
});
};
/* add station marker */ /* add station marker */
function addStationMarker(id, lat, lng) { function addStationMarker(id, lat, lng) {
@ -144,9 +98,9 @@ function initMapLink() {
}); });
}; };
/****************** /**********************************************************************
* document ready * * document ready *
******************/ **********************************************************************/
$(document).ready(function() { $(document).ready(function() {
// create a map in the "map" div, set the view to a given place and zoom // create a map in the "map" div, set the view to a given place and zoom

View File

@ -1,10 +1,35 @@
// calculate marker radius from magnitude, both formulas have equal radii at mag=1.2 /**********************************************************************
* misc.js *
* script for unspecific functions and setup *
**********************************************************************/
/* License
Copyright 2014 Kasper D. Fischer <kasper.fischer@rub.de>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see http://www.gnu.org/licenses/.
$Id$
*/
/* calculate marker radius from magnitude
* both formulas have equal radii at mag=1.2 */
function mag2radius(mag) { function mag2radius(mag) {
return 400*mag; // radius proportional to magagnitude return 400*mag; // radius proportional to magagnitude
// return 8.104*Math.pow(30,mag) // radius proportional to energy // return 8.104*Math.pow(30,mag) // radius proportional to energy
}; };
// set height of eventlist div /* set height of eventlist div */
function sleep(milliseconds) { function sleep(milliseconds) {
var start = new Date().getTime(); var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) { for (var i = 0; i < 1e7; i++) {
@ -13,6 +38,8 @@ function sleep(milliseconds) {
} }
} }
} }
/* setInfoHeight */
function setInfoHeight() { function setInfoHeight() {
var height = $('div.map').height() - 36; var height = $('div.map').height() - 36;
$('div.info').height(height); $('div.info').height(height);
@ -51,12 +78,12 @@ function getLocation(lat, lng) {
return [ region, regionID ]; return [ region, regionID ];
}; };
// window resize /* window resize */
$( window ).resize(function() { $( window ).resize(function() {
setInfoHeight(); setInfoHeight();
}); });
// create global vars /* create global vars */
var map var map
var eventTable = {}; var eventTable = {};
var eventDetails = {}; var eventDetails = {};
@ -68,7 +95,9 @@ var zoomDefault = 9;
var mapCentreDefault = [51.85, 7.0]; var mapCentreDefault = [51.85, 7.0];
var minMag = 1.2; var minMag = 1.2;
// run when ready /**********************************************************************
* document ready *
**********************************************************************/
$(document).ready(function() { $(document).ready(function() {
// AJAX setup // AJAX setup
$.ajaxSetup({timeout: 15000}); // 15 seconds $.ajaxSetup({timeout: 15000}); // 15 seconds

View File

@ -1,4 +1,28 @@
// Load the stations using ajax /**********************************************************************
* stations.js *
* script for station specific functions and setup *
**********************************************************************/
/* License
Copyright 2014 Kasper D. Fischer <kasper.fischer@rub.de>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see http://www.gnu.org/licenses/.
$Id$
*/
/* Load the stations using ajax */
function loadStations(stime, etime) { function loadStations(stime, etime) {
var mapBounds = map.getBounds(); var mapBounds = map.getBounds();
var N = mapBounds.getNorth(); var N = mapBounds.getNorth();
@ -57,6 +81,7 @@ function loadStations(stime, etime) {
}); });
}; };
/* initStationTable */
function initStationTable() { function initStationTable() {
// tablesorter for station list // tablesorter for station list
$("#stationstable").tablesorter( $("#stationstable").tablesorter(
@ -113,6 +138,10 @@ function initStationTable() {
} }
}); });
}; };
/**********************************************************************
* document ready *
**********************************************************************/
$(document).ready(function() { $(document).ready(function() {
loadStations(); loadStations();
}); });