Completed
Push — master ( 8704ae...909b54 )
by Yannick
98:22 queued 71:19
created

map.common.js ➔ clickDisplayFires   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
nc 1
dl 0
loc 4
rs 10
nop 1
1
function getCookie(cname) {
2
    var name = cname + "=";
3
    var ca = document.cookie.split(';');
4
    for(var i=0; i<ca.length; i++) {
5
	var c = ca[i];
6
	while (c.charAt(0)==' ') c = c.substring(1);
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...
7
	if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
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...
8
    }
9
    return "";
10
}
11
12
function delCookie(cname) {
13
    document.cookie = cname + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
14
}
15
16
function createCookie(name, value, days) {
17
    var date, expires;
18
    if (days) {
19
        date = new Date();
20
        date.setTime(date.getTime()+(days*24*60*60*1000));
21
        expires = "; expires="+date.toGMTString();
22
    } else {
23
        expires = "";
24
    }
25
    document.cookie = name+"="+value+expires+"; path=/";
26
}
27
28
function mapType(selectObj) {
29
    var idx = selectObj.selectedIndex;
30
    var atype = selectObj.options[idx].value;
31
    var type = atype.split('-');
32
    document.cookie =  'MapType='+type+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
33
    if (type[0] == 'Mapbox') {
34
	document.cookie =  'MapType='+type[0]+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
35
	document.cookie =  'MapTypeId='+type[1]+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
36
    } else {
37
	document.cookie =  'MapType='+atype+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
38
    }
39
    window.location.reload();
40
}
41
42
function terrainType(selectObj) {
43
    var idx = selectObj.selectedIndex;
44
    var atype = selectObj.options[idx].value;
45
    var type = atype.split('-');
46
    document.cookie =  'MapTerrain='+type+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
47
    window.location.reload();
48
}
49
50
function sattypes(selectObj) {
51
    var sattypes = [], sattype;
52
    for (var i=0, len=selectObj.options.length; i< len;i++) {
53
	sattype = selectObj.options[i];
54
	if (sattype.selected) {
55
	    sattypes.push(sattype.value);
56
	}
57
    }
58
    //document.cookie =  'sattypes='+sattypes.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
59
    createCookie('sattypes',sattypes.join(),2);
60
    updateSat();
61
}
62
function airlines(selectObj) {
63
    var airs = [], air;
64
    for (var i=0, len=selectObj.options.length; i< len;i++) {
65
	air = selectObj.options[i];
66
	if (air.selected) {
67
	    airs.push(air.value);
68
	}
69
    }
70
    //document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
71
    createCookie('filter_Airlines',airs.join(),2);
72
}
73
function airlinestype(selectObj) {
74
    var idx = selectObj.selectedIndex;
75
    var airtype = selectObj.options[idx].value;
76
    //document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
77
    createCookie('filter_airlinestype',airtype,2);
78
}
79
function alliance(selectObj) {
80
    var idx = selectObj.selectedIndex;
81
    var alliance = selectObj.options[idx].value;
82
    //document.cookie =  'filter_alliance='+alliance+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
83
    createCookie('filter_alliance',alliance,2);
84
}
85
function identfilter() {
86
    var ident = $("#identfilter").value;
87
    //document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
88
    createCookie('filter_ident',ident,2);
89
}
90
function removefilters() {
91
    // Get an array of all cookie names (the regex matches what we don't want)
92
    var cookieNames = document.cookie.split(/=[^;]*(?:;\s*|$)/);
93
    // Remove any that match the pattern
94
    for (var i = 0; i < cookieNames.length; i++) {
95
    if (/^filter_/.test(cookieNames[i])) {
96
        document.cookie = cookieNames[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
97
        }
98
    }
99
    window.location.reload();
100
}
101
function sources(selectObj) {
102
    var sources = [], source;
103
    for (var i=0, len=selectObj.options.length; i< len;i++) {
104
	source = selectObj.options[i];
105
	if (source.selected) {
106
	    sources.push(source.value);
107
	}
108
    }
109
    //document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
110
    createCookie('filter_Sources',sources.join(),2);
111
}
112
113
114
function show2D() {
115
    //document.cookie =  'MapFormat=2d; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
116
    createCookie('MapFormat','2d',10);
117
    window.location.reload();
118
}
119
function show3D() {
120
    //document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
121
    createCookie('MapFormat','3d',10);
122
    window.location.reload();
123
}
124
function clickPolar(cb) {
125
    document.cookie =  'polar='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
126
    window.location.reload();
127
}
128
function clickDisplayAirports(cb) {
129
    document.cookie =  'displayairports='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
130
    window.location.reload();
131
}
132
function clickDisplayISS(cb) {
133
    document.cookie =  'displayiss='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
134
    updateSat();
135
}
136
function clickDisplayMinimap(cb) {
137
    document.cookie =  'displayminimap='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
138
    window.location.reload();
139
}
140
function clickVATSIM(cb) {
141
    //document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
142
    createCookie('filter_ShowVATSIM',cb.checked,2);
143
}
144
function clickIVAO(cb) {
145
     //document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
146
     createCookie('filter_ShowIVAO',cb.checked,2);
147
}
148
function clickphpVMS(cb) {
149
    //document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
150
    createCookie('filter_ShowVMS',cb.checked,2);
151
}
152
function clickSBS1(cb) {
153
    //document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
154
    createCookie('filter_ShowSBS1',cb.checked,2);
155
}
156
function clickAPRS(cb) {
157
    //document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/';
158
    createCookie('filter_ShowAPRS',cb.checked,2);
159
}
160
function clickDisplayGroundStation(cb) {
161
    createCookie('show_GroundStation',cb.checked,2);
162
    window.location.reload();
163
}
164
function clickDisplayWeatherStation(cb) {
165
    createCookie('show_WeatherStation',cb.checked,2);
166
    window.location.reload();
167
}
168
function clickDisplayLightning(cb) {
169
    createCookie('show_Lightning',cb.checked,2);
170
    window.location.reload();
171
}
172
function clickDisplayFires(cb) {
173
    createCookie('show_Fires',cb.checked,2);
174
    window.location.reload();
175
}
176
function unitdistance(selectObj) {
177
    var idx = selectObj.selectedIndex;
178
    var unit = selectObj.options[idx].value;
179
    document.cookie =  'unitdistance='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
180
}
181
function unitspeed(selectObj) {
182
    var idx = selectObj.selectedIndex;
183
    var unit = selectObj.options[idx].value;
184
    document.cookie =  'unitspeed='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
185
}
186
function unitaltitude(selectObj) {
187
    var idx = selectObj.selectedIndex;
188
    var unit = selectObj.options[idx].value;
189
    document.cookie =  'unitaltitude='+unit+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
190
}
191