Browse Source

ES6 shorthand method definitions

master
Lyubo Marinov 8 years ago
parent
commit
147ca8e123
1 changed files with 26 additions and 28 deletions
  1. 26
    28
      modules/RTC/RTCBrowserType.js

+ 26
- 28
modules/RTC/RTCBrowserType.js View File

@@ -28,7 +28,7 @@ var RTCBrowserType = {
28 28
      * Gets current browser type.
29 29
      * @returns {string}
30 30
      */
31
-    getBrowserType: function () {
31
+    getBrowserType() {
32 32
         return currentBrowser;
33 33
     },
34 34
 
@@ -36,10 +36,12 @@ var RTCBrowserType = {
36 36
      * Gets current browser name, split from the type.
37 37
      * @returns {string}
38 38
      */
39
-    getBrowserName: function () {
40
-        var browser = currentBrowser.split('rtc_browser.')[1];
39
+    getBrowserName() {
40
+        var browser;
41 41
         if (RTCBrowserType.isAndroid()) {
42 42
             browser = 'android';
43
+        } else {
44
+            browser = currentBrowser.split('rtc_browser.')[1];
43 45
         }
44 46
         return browser;
45 47
     },
@@ -48,7 +50,7 @@ var RTCBrowserType = {
48 50
      * Checks if current browser is Chrome.
49 51
      * @returns {boolean}
50 52
      */
51
-    isChrome: function () {
53
+    isChrome() {
52 54
         return currentBrowser === RTCBrowserType.RTC_BROWSER_CHROME;
53 55
     },
54 56
 
@@ -56,7 +58,7 @@ var RTCBrowserType = {
56 58
      * Checks if current browser is Opera.
57 59
      * @returns {boolean}
58 60
      */
59
-    isOpera: function () {
61
+    isOpera() {
60 62
         return currentBrowser === RTCBrowserType.RTC_BROWSER_OPERA;
61 63
     },
62 64
 
@@ -64,7 +66,7 @@ var RTCBrowserType = {
64 66
      * Checks if current browser is Firefox.
65 67
      * @returns {boolean}
66 68
      */
67
-    isFirefox: function () {
69
+    isFirefox() {
68 70
         return currentBrowser === RTCBrowserType.RTC_BROWSER_FIREFOX;
69 71
     },
70 72
 
@@ -72,7 +74,7 @@ var RTCBrowserType = {
72 74
      * Checks if current browser is Internet Explorer.
73 75
      * @returns {boolean}
74 76
      */
75
-    isIExplorer: function () {
77
+    isIExplorer() {
76 78
         return currentBrowser === RTCBrowserType.RTC_BROWSER_IEXPLORER;
77 79
     },
78 80
 
@@ -80,7 +82,7 @@ var RTCBrowserType = {
80 82
      * Checks if current browser is Safari.
81 83
      * @returns {boolean}
82 84
      */
83
-    isSafari: function () {
85
+    isSafari() {
84 86
         return currentBrowser === RTCBrowserType.RTC_BROWSER_SAFARI;
85 87
     },
86 88
 
@@ -88,7 +90,7 @@ var RTCBrowserType = {
88 90
      * Checks if current environment is NWJS.
89 91
      * @returns {boolean}
90 92
      */
91
-    isNWJS: function () {
93
+    isNWJS() {
92 94
         return currentBrowser === RTCBrowserType.RTC_BROWSER_NWJS;
93 95
     },
94 96
 
@@ -96,7 +98,7 @@ var RTCBrowserType = {
96 98
      * Checks if current environment is Electron.
97 99
      * @returns {boolean}
98 100
      */
99
-    isElectron: function () {
101
+    isElectron() {
100 102
         return currentBrowser === RTCBrowserType.RTC_BROWSER_ELECTRON;
101 103
     },
102 104
 
@@ -104,7 +106,7 @@ var RTCBrowserType = {
104 106
      * Checks if current environment is React Native.
105 107
      * @returns {boolean}
106 108
      */
107
-    isReactNative: function () {
109
+    isReactNative() {
108 110
         return currentBrowser === RTCBrowserType.RTC_BROWSER_REACT_NATIVE;
109 111
     },
110 112
 
@@ -112,7 +114,7 @@ var RTCBrowserType = {
112 114
      * Checks if Temasys RTC plugin is used.
113 115
      * @returns {boolean}
114 116
      */
115
-    isTemasysPluginUsed: function () {
117
+    isTemasysPluginUsed() {
116 118
         // Temasys do not support Microsoft Edge:
117 119
         // http://support.temasys.com.sg/support/solutions/articles/5000654345-can-the-temasys-webrtc-plugin-be-used-with-microsoft-edge-
118 120
         if (RTCBrowserType.isIExplorer()
@@ -129,7 +131,7 @@ var RTCBrowserType = {
129 131
      * @returns {*|boolean} 'true' if the event is supported or 'false'
130 132
      * otherwise.
131 133
      */
132
-    isVideoMuteOnConnInterruptedSupported: function () {
134
+    isVideoMuteOnConnInterruptedSupported() {
133 135
         return RTCBrowserType.isChrome();
134 136
     },
135 137
 
@@ -137,7 +139,7 @@ var RTCBrowserType = {
137 139
      * Returns Firefox version.
138 140
      * @returns {number|null}
139 141
      */
140
-    getFirefoxVersion: function () {
142
+    getFirefoxVersion() {
141 143
         return RTCBrowserType.isFirefox() ? browserVersion : null;
142 144
     },
143 145
 
@@ -145,7 +147,7 @@ var RTCBrowserType = {
145 147
      * Returns Chrome version.
146 148
      * @returns {number|null}
147 149
      */
148
-    getChromeVersion: function () {
150
+    getChromeVersion() {
149 151
         return RTCBrowserType.isChrome() ? browserVersion : null;
150 152
     },
151 153
 
@@ -154,11 +156,11 @@ var RTCBrowserType = {
154 156
      *
155 157
      * @returns {number|null}
156 158
      */
157
-    getIExplorerVersion: function () {
159
+    getIExplorerVersion() {
158 160
         return RTCBrowserType.isIExplorer() ? browserVersion : null;
159 161
     },
160 162
 
161
-    usesPlanB: function() {
163
+    usesPlanB() {
162 164
         return (
163 165
             RTCBrowserType.isChrome()
164 166
                 || RTCBrowserType.isOpera()
@@ -166,7 +168,7 @@ var RTCBrowserType = {
166 168
                 || RTCBrowserType.isTemasysPluginUsed());
167 169
     },
168 170
 
169
-    usesUnifiedPlan: function() {
171
+    usesUnifiedPlan() {
170 172
         return RTCBrowserType.isFirefox();
171 173
     },
172 174
 
@@ -174,7 +176,7 @@ var RTCBrowserType = {
174 176
      * Whether the browser is running on an android device.
175 177
      * @returns {boolean}
176 178
      */
177
-    isAndroid: function() {
179
+    isAndroid() {
178 180
         return isAndroid;
179 181
     },
180 182
 
@@ -182,7 +184,7 @@ var RTCBrowserType = {
182 184
      * Whether jitsi-meet supports simulcast on the current browser.
183 185
      * @returns {boolean}
184 186
      */
185
-    supportsSimulcast: function() {
187
+    supportsSimulcast() {
186 188
         // This mirrors what sdp-simulcast uses (which is used when deciding
187 189
         // whether to actually enable simulcast or not).
188 190
         // TODO: the logic should be in one single place.
@@ -272,7 +274,7 @@ function detectIE() {
272 274
 /**
273 275
  * Detects Electron environment.
274 276
  */
275
-function detectElectron (){
277
+function detectElectron() {
276 278
     var userAgent = navigator.userAgent;
277 279
     if (userAgent.match(/Electron/)) {
278 280
         currentBrowser = RTCBrowserType.RTC_BROWSER_ELECTRON;
@@ -283,7 +285,7 @@ function detectElectron (){
283 285
     return null;
284 286
 }
285 287
 
286
-function detectNWJS (){
288
+function detectNWJS() {
287 289
     var userAgent = navigator.userAgent;
288 290
     if (userAgent.match(/JitsiMeetNW/)) {
289 291
         currentBrowser = RTCBrowserType.RTC_BROWSER_NWJS;
@@ -308,12 +310,8 @@ function detectReactNative() {
308 310
             name = match[1];
309 311
             version = match[2];
310 312
         }
311
-        if (!name) {
312
-            name = 'react-native';
313
-        }
314
-        if (!version) {
315
-            version = 'unknown';
316
-        }
313
+        name || (name = 'react-native');
314
+        version || (version = 'unknown');
317 315
         console.info('This appears to be ' + name + ', ver: ' + version);
318 316
     } else {
319 317
         // We're not running in a React Native environment.

Loading…
Cancel
Save