Created
March 17, 2011 22:52
-
-
Save tordans/875309 to your computer and use it in GitHub Desktop.
Quick and dirty JavaScript that exports station-data. Find the final dataset at http://goo.gl/iDo0N
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.1.min.js"></script> | |
<h1>Find the final data at http://goo.gl/iDo0N</h1> | |
<table> | |
<tr> | |
<td>Station_ID</td><td>Site_ID</td><td>Site_Name_JP</td><td>Site_Name_EN</td><td>Prefecture_ID</td><td>Prefecture_Name_JP</td><td>Prefecture_Name_EN</td><td>Station</td><td>Station_Name_JP</td><td>-</td><td>Station_Name_EN</td><td>Latitude</td><td>Longitude</td> | |
</tr> | |
<tr> | |
<td>area_data/post_id</td><td>-</td><td>area_def/name</td><td>area_def/name_en</td><td>area_data/pref/pref_id</td><td>area_data/pref/pref_name</td><td>-</td><td>-</td><td>area_data/data/station</td><td>area_data/data/name</td><td>-</td><td>area_data/data/lat</td><td>area_data/data/long</td> | |
</tr> | |
</table> | |
<script type="text/javascript"> | |
// Data-Source: | |
// http://www.bousai.ne.jp/vis/bin/area.php?site=2&func=getData&eo=UTF-8 | |
// http://www.bousai.ne.jp/vis/bin/area.php?site=####&func=getData&eo=UTF-8 | |
// ... | |
// http://www.bousai.ne.jp/vis/bin/area.php?site=16&func=getData&eo=UTF-8 | |
var callcounter = 1; | |
var datastore = []; | |
var sep_start = '<td>'; | |
var sep_end = '</td>'; | |
var sep = '</td><td>'; | |
function getData(data) { | |
$.each( data.area_data, | |
function(index, stations) { | |
$.each( stations.data, | |
function( index, station) { | |
// TODO: data.area_data[0].* has to be changed to something like stations.*... | |
$('body').append($('<tr>'+ sep_start + station.post_id + sep + callcounter + sep + data.area_def.name + sep + data.area_def.name_en + sep + data.area_data[0].pref.pref_id + sep + data.area_data[0].pref.pref_name + sep + '-' + sep + '-' + sep + station.station + sep + station.name + sep + '-' + sep + station.pos[0] + sep + station.pos[1] + sep + sep_end + '</tr>')); | |
datastore[callcounter] = data; | |
callcounter++; | |
} ); | |
} ); | |
}; | |
</script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=1&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=2&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=3&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=4&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=5&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=6&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=7&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=8&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=9&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=10&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=11&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=12&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=13&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=14&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=15&func=getData&eo=UTF-8"></script> | |
<script type="text/javascript" src="http://www.bousai.ne.jp/vis/bin/area.php?site=16&func=getData&eo=UTF-8"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment