Move variable to the top of the file and reuse

As suggested in https://github.com/openstreetmap/iD/pull/5650#issuecomment-449589375
This commit is contained in:
Tobias
2018-12-23 07:38:00 +01:00
committed by GitHub
parent c97b659a34
commit 5009edee4b
+2 -3
View File
@@ -9,7 +9,8 @@ export function utilDetect(force) {
detected = {};
var ua = navigator.userAgent,
m = null;
m = null,
q = utilStringQs(window.location.hash.substring(1));
m = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i); // Edge
if (m !== null) {
@@ -60,7 +61,6 @@ export function utilDetect(force) {
detected.opera = (detected.browser.toLowerCase() === 'opera' && parseFloat(detected.version) < 15 );
// Set locale based on url param (format 'en-US') or browser lang (default)
var q = utilStringQs(window.location.hash.substring(1));
if (q.hasOwnProperty('locale')) {
detected.locale = q.locale;
detected.language = q.locale.split('-')[0];
@@ -97,7 +97,6 @@ export function utilDetect(force) {
}
// detect text direction
var q = utilStringQs(window.location.hash.substring(1));
var lang = dataLocales[detected.locale];
if ((lang && lang.rtl) || (q.rtl === 'true')) {
detected.textDirection = 'rtl';