From 774121e9873c2399e91462500c5fde624f436151 Mon Sep 17 00:00:00 2001 From: bastianonm Date: Tue, 20 Dec 2011 17:38:41 +0000 Subject: [PATCH] --- WP-GPX-Maps.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/WP-GPX-Maps.js b/WP-GPX-Maps.js index f32ed01..3c34db2 100644 --- a/WP-GPX-Maps.js +++ b/WP-GPX-Maps.js @@ -10,28 +10,33 @@ var loc_it = }; var loc = loc_en; -function sleep(ms) -{ - var dt = new Date(); - dt.setTime(dt.getTime() + ms); - while (new Date().getTime() < dt.getTime()); +var t; +var funqueue = []; +var wrapFunction = function(fn, context, params) { + return function() { + fn.apply(context, params); + }; } function wpgpxmaps(targhetId,mapType,mapData,graphData) { - var i = 0; - while ((google == undefined || google.maps == undefined || google.visualization == undefined)) - { - sleep(100); - i++; - if (i== 100) - { - return; - } - } - _wpgpxmaps(targhetId,mapType,mapData,graphData); + funqueue.push( wrapFunction(_wpgpxmaps, this, [targhetId,mapType,mapData,graphData])); + unqueue(); } +function unqueue() +{ + if ((google == undefined || google.maps == undefined || google.visualization == undefined)) + { + t = setTimeout("unqueue()",200); + } + else + { + while (funqueue.length > 0) { + (funqueue.shift())(); + } + } +} function _wpgpxmaps(targhetId,mapType,mapData,graphData) {