Issues (3)

CountryFlags.js (3 issues)

1
/** global: VRS */
2
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
3
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
0 ignored issues
show
The parameter bootStrap is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
4
            if(VRS.renderPropertyHandlers) {
5
                VRS.renderPropertyHandlers[VRS.RenderProperty.Country] = new VRS.RenderPropertyHandler({
6
                    property:               VRS.RenderProperty.Country,
7
                    surfaces:               VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
8
                    headingKey:             'ListCountry',
9
                    labelKey:               'Country',
10
                    sortableField:          VRS.AircraftListSortableField.Country,
11
                    suppressLabelCallback:  function() { return true; },
12
                    fixedWidth:             function() { return '27px'; },
13
                    hasChangedCallback:     function(aircraft) { return aircraft.country.chg; },
14
                    renderCallback:         function(aircraft) { return customFormatCountryFlagImageHtml(aircraft); },
15
                    tooltipChangedCallback: function(aircraft) { return aircraft.country.chg; },
16
                    tooltipCallback:        function(aircraft) { return aircraft.country.val; }
17
                });                
18
            }
19
        });
20
    }
21
    
22
function customFormatCountryFlagImageHtml(aircraft)
23
    {
24
        var result = '';
25
        if(aircraft.country.val) {
26
            var codeToUse = '';
27
            codeToUse = aircraft.country.val;
28
            //Place images on 'country' folder
29
            result = '<img src="images/web-country/Wdth-27/Hght-20';
30
            if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
31
            result += '/' + encodeURIComponent(codeToUse) +'.bmp" width="27px" height="20px" />';
32
        }
33
        return result;
34
    }
35
    
36
function customPipeSeparatedCode(text, code)
37
    {
38
        var result = text;
39
        if(code && code.length) {
40
            if(result.length) result += '|';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
41
            result += code;
42
        }
43
        return result;
44
    }
45