View Single Post
Posts: 1,203 | Thanked: 3,027 times | Joined on Dec 2010
#27
Blaizzen:

As I say, I don't have a great deal of experience with Javascript, but could you help me understand the following a bit better.

Code:
var GuidanceModel=new Class({Name:"GuidanceModel",Implements:[EventSource,Destroyable],
_currentRoute:null,
_MANEUVER_ICONS:null,
_guidance:null,
initialize:function(aPluginControl,aRoutingModel,aPositionModel,aMapModel)
{
    var modelInstance=nokia.maps.pfw.PlayerManager.getModelInstance(aPluginControl,this.className);
    if(modelInstance)
    {
        return modelInstance
    }
    else
    {
        nokia.maps.pfw.PlayerManager.addModelInstance(aPluginControl,this.className,this)
    }
    
    this._pluginControl=aPluginControl;
    
    try
    {
        this._guidance=this._pluginControl.getGuidance()
    }
    catch(ex)
    {
        this._guidance=null
    }

    if(!this._guidance)
    {
        this._guidance=new GuidanceMockup()
    }
    
    this._guidance.setOnGuidanceDone(bind(this,this._onGuidanceDone));
    this._routeModel=aRoutingModel;
    this._mapModel=aMapModel;
    this._positionModel=aPositionModel
}
When the code is run on the desktop, you state that GuidanceMockup is used. On the N900, what would happen? Would the class be constructed from the instance received in the first few lines, or would this._guidance be set in the "try" block?

I'm trying to deduce if the code in the HTML file for certain functions is used, if it is replaced by the plugin or it is never called at all. For example:

Code:
pauseNavigation:function(aPause)
{
    if(aPause===true||aPause===undefined)
    {
        this._guidance.pause()
    }
    else
    {
    this._guidance.resume()
    }
}
this._guidance.pause() would obviously be the plugin, but is the function for pauseNavigation in the HTML used or is this replaced by the plugin.