MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: window.cb = function cb(json) { //do what you want with the json document.getElementById('o...") |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
function cb(json) { | |||
//do what you want with the json | //do what you want with the json | ||
document.getElementById('output').innerHTML = json.address.road + ',' + json.address.city; | document.getElementById('output').innerHTML = json.address.road + ',' + json.address.city; | ||
} | } | ||
function nominatimsearch(lat,long) { | |||
var s = document.createElement('script'); | var s = document.createElement('script'); | ||
s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+lat+'&lon='+long+'&addressdetails=1'; | s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+lat+'&lon='+long+'&addressdetails=1'; | ||
document.getElementsByTagName('head')[0].appendChild(s); | document.getElementsByTagName('head')[0].appendChild(s); | ||
}; | }; |
Revision as of 18:28, 1 December 2014
/* Any JavaScript here will be loaded for all users on every page load. */ function cb(json) { //do what you want with the json document.getElementById('output').innerHTML = json.address.road + ',' + json.address.city; } function nominatimsearch(lat,long) { var s = document.createElement('script'); s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+lat+'&lon='+long+'&addressdetails=1'; document.getElementsByTagName('head')[0].appendChild(s); };