diff --git a/iplookup/functions.js b/iplookup/functions.js index 2ee5802a236fc..529e01070ecab 100644 --- a/iplookup/functions.js +++ b/iplookup/functions.js @@ -23,19 +23,21 @@ */ function iplookup_load(latitude, longitude) { - if (GBrowserIsCompatible()) { - var map = new GMap2(document.getElementById("map")); - map.addControl(new GSmallMapControl()); - map.addControl(new GMapTypeControl()); - var point = new GLatLng(latitude, longitude); - map.setCenter(point, 4); - map.addOverlay(new GMarker(point)); - map.setMapType(G_HYBRID_MAP); - } + if (GBrowserIsCompatible()) { + var map = new GMap2(document.getElementById("map")); + map.addControl(new GSmallMapControl()); + map.addControl(new GMapTypeControl()); + var point = new GLatLng(latitude, longitude); + map.setCenter(point, 4); + map.addOverlay(new GMarker(point)); + map.setMapType(G_HYBRID_MAP); + + YAHOO.utils.Event.addListener(document.body, 'unload', iplookup_unload); + } } function iplookup_unload() { - if (GBrowserIsCompatible()) { - GUnload(); - } + if (GBrowserIsCompatible()) { + GUnload(); + } } diff --git a/iplookup/index.php b/iplookup/index.php index dfa6b88a6ae45..1cc15aed113f1 100644 --- a/iplookup/index.php +++ b/iplookup/index.php @@ -137,14 +137,17 @@ $dx = round((($longitude + 180) * ($imgwidth / 360)) - $imgwidth - $dotwidth/2); $dy = round((($latitude + 90) * ($imgheight / 180))); - print_header(get_string('iplookup', 'admin').': '.$info, $info); + $PAGE->set_title(get_string('iplookup', 'admin').': '.$info); + $PAGE->set_heading($info); + echo $OUTPUT->header(); echo '
'; echo ''; echo ''; echo '
'; echo '
'.$note.'
'; - print_footer('empty'); + + echo $OUTPUT->footer(); } else { $info = implode(' - ', $info); @@ -152,16 +155,16 @@ $PAGE->requires->js("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey", true)->in_head(); $PAGE->requires->js('/iplookup/functions.js')->in_head(); + $PAGE->requires->yui_lib('event'); + $PAGE->requires->js_function_call('iplookup_load', array($latitude, $longitude)); - print_header(get_string('iplookup', 'admin').': '.$info, $info); + $PAGE->set_title(get_string('iplookup', 'admin').': '.$info); + $PAGE->set_heading($info); + echo $OUTPUT->header(); echo '
'; echo '
'.$note.'
'; - $PAGE->requires->js_function_call('iplookup_load', array($latitude, $longitude)); - - //TODO: MDL-19875 - call uplookup_unload() js function when page unloads, previously in meta parameter - echo $OUTPUT->footer(); }