﻿var CarCurrent = {}

CarCurrent.Init = function(){
    this.Url='/GetPoint';
    this.async=true;
    this.httpMethod='post';
    this.httpParams={ uid: uidkey};
    this.callbackArgsArray = '';
    this.JsonData={};
    this.speed = 6000; // speed of animation
	this.timer = null; // timer of animation
	this.first=0;
}

CarCurrent.Update = function(){
    
    this.timer=null;
    var ok=0;
    this.httpParams={ uid: uidkey};
    try {
	    Ext.Ajax.request({
			url: this.Url,
			params: this.httpParams,
			success: this.Callback,
			failure:this.Onerror,
			scope: this
		});
		
    } catch (err){}
}

CarCurrent.Onerror = function (){
}

CarCurrent.Callback = function (form, action){
    try {    
        CarCurrent.JsonData= JSON.parse(form.responseText); 
        CarMaps.UpdateData(this.JsonData);
        CarUserList.Update(this.JsonData);
        if (this.first==0) this.first=1;  
	    else CarCurrent.timer = setTimeout(function(){CarCurrent.Update();$("#main").trigger('click');}, this.speed);
       
    } catch (err)
    { 	
        this.first=0;
     //    console.log('ошибка');
    } finally 	
    { 	
    	//alert('Завершающие действия');
    }; 

}

CarCurrent.Stop = function(){
	clearTimeout(this.timer);
	this.timer=null;
}
