This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathGeckoVersionIndicator.ejs
69 lines (60 loc) · 1.67 KB
/
GeckoVersionIndicator.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<%
// Displays an indicator indicating the Gecko compatibility range for a technology
// or API term.
//
// The indicator is not displayed if the Gecko version is more than 10 releases
// old.
//
// Parameters:
//
// $0 Indicator type (0 = badge, 2 = banner; 1 for icon will draw as badge)
// $1 Minimum Gecko version
// $2 Additional text (displayed in tooltip for badge or in the banner)
var lang = env.locale;
var primaryText = "";
var versionDetails = "";
// Determine if we should display anything at all by comparing the current
// Gecko version to the one specified.
var currentGecko = await template("CurrentGecko");
if (parseInt(currentGecko, 10) - parseInt($1, 10) <= 10) {
// At this point, we know we need to show the indicator, so build the version
// required string.
switch(lang) {
case 'fr':
primaryText = "Nécessite Gecko " + $1;
break;
case 'ja':
primaryText = "Gecko " + $1 + " が必要";
break;
case 'pl':
primaryText = "Wymaga Gecko " + $1;
break;
case 'pt':
primaryText = "Requer Gecko " + $1;
break;
case 'de':
primaryText = "Ab Gecko " + $1;
break;
case 'es':
primaryText = "Requiere Gecko " + $1;
break;
case 'ru':
primaryText = "Требуется Gecko " + $1;
break;
default:
primaryText = "Requires Gecko " + $1;
break;
}
// Fetch the version details
versionDetails = await template("geckoRelease", [$1]);
switch(parseInt($0, 10)) {
case 0:
case 1:
%><%-await template("SimpleBadge", [primaryText, "geckoVersionBadge", versionDetails])%><%
break;
case 2:
%><%-await template("SimpleBanner", [primaryText + " " + versionDetails, "geckoVersionBadge", $2])%><%
break;
}
}
%>