Mercurial > hg > batmud > gmap2
changeset 244:5a433ea98f76 gmap2
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Mar 2014 02:53:50 +0200 |
parents | 08b2cc0350d0 |
children | 800c3dba43f3 |
files | lib/util.js |
diffstat | 1 files changed, 23 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/util.js Mon Mar 17 02:48:13 2014 +0200 +++ b/lib/util.js Mon Mar 17 02:53:50 2014 +0200 @@ -1,39 +1,49 @@ -function XCreateXmlHTTPRequest() { +function XCreateXmlHTTPRequest() +{ try { - if (typeof ActiveXObject != 'undefined') { + if (typeof ActiveXObject != 'undefined') return new ActiveXObject('Microsoft.XMLHTTP'); - } else if (window["XMLHttpRequest"]) { + else + if (window["XMLHttpRequest"]) return new XMLHttpRequest(); - } - } catch (e) { + } + catch (e) { changeStatus(e); } return null; -}; +} + -function XDownloadUrl(url, callback) { +function XDownloadUrl(url, callback) +{ var status = -1; var request = XCreateXmlHTTPRequest(); if (!request) return false; - request.onreadystatechange = function() { - if (request.readyState == 4) { + request.onreadystatechange = function() + { + if (request.readyState == 4) + { try { status = request.status; - } catch (e) { + } + catch (e) { // Usually indicates request timed out in FF. } - if (status == 200) { + if (status == 200) + { callback(request.responseText, request.status); request.onreadystatechange = function() {}; } } } + request.open('GET', url, true); try { request.send(null); - } catch (e) { + } + catch (e) { changeStatus(e); } -}; +}