PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/js/geo_position_js_simulator.js

http://geo-location-javascript.googlecode.com/
JavaScript | 42 lines | 29 code | 2 blank | 11 comment | 2 complexity | e2508e5d24ab7645ad10469c0ff797ce MD5 | raw file
 1/*!
 2 * geo-location-javascript v0.4.1  Simulator
 3 * http://code.google.com/p/geo-location-javascript/
 4 *
 5 * Copyright (c) 2009 Stan Wiechers
 6 * Licensed under the MIT licenses.
 7 *
 8 * Revision: $Rev: 62 $: 
 9 * Author: $Author: whoisstan $:
10 * Date: $Date: 2009-12-17 15:46:49 -0500 (Thu, 17 Dec 2009) $:    
11 */
12var geo_position_js_simulator=function(){
13
14	var pub = {};
15	var current_pos=null;
16	pub.init = function(array)
17	{
18		var next=0;
19		for (i in array)
20		{
21				if(i==0)
22				{
23					current_pos=array[i];
24				}
25				else
26				{
27					setTimeout((function(pos) { 
28					      return function() { 
29					        current_pos=pos; 									
30					      } 
31					    })(array[i]),next);
32				}
33				next+=array[i].duration;							
34		}
35	}
36
37	pub.getCurrentPosition = function(locationCallback,errorCallback)
38	{
39		locationCallback(current_pos);
40	}
41	return pub;
42}();