diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-06-07 02:02:56 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-06-07 02:02:56 +0900 |
| commit | 86bbcd5ea2ed5f7af805b742fe2d80322f7d74a3 (patch) | |
| tree | decfd3ac799e5684b73ef8f201de126c13b51b0c /src | |
| parent | Refactor (diff) | |
| download | sharkey-86bbcd5ea2ed5f7af805b742fe2d80322f7d74a3.tar.gz sharkey-86bbcd5ea2ed5f7af805b742fe2d80322f7d74a3.tar.bz2 sharkey-86bbcd5ea2ed5f7af805b742fe2d80322f7d74a3.zip | |
Fix bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/app/boot.js | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 2671d372fd..2686559e2d 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -11,53 +11,55 @@ 'use strict'; -// Get the current url information -const url = new URL(location.href); +{ + // Get the current url information + const url = new URL(location.href); -// Extarct the (sub) domain part of the current url -// -// e.g. -// misskey.alice => misskey -// misskey.strawberry.pasta => misskey -// dev.misskey.alice.tachibana => dev -let app = url.host.split('.')[0]; + // Extarct the (sub) domain part of the current url + // + // e.g. + // misskey.alice => misskey + // misskey.strawberry.pasta => misskey + // dev.misskey.alice.tachibana => dev + let app = url.host.split('.')[0]; -// Detect the user language -// Note: The default language is English -let lang = navigator.language.split('-')[0]; -if (!/^(en|ja)$/.test(lang)) lang = 'en'; + // Detect the user language + // Note: The default language is English + let lang = navigator.language.split('-')[0]; + if (!/^(en|ja)$/.test(lang)) lang = 'en'; -// Detect the user agent -const ua = navigator.userAgent.toLowerCase(); -const isMobile = /mobile|iphone|ipad|android/.test(ua); + // Detect the user agent + const ua = navigator.userAgent.toLowerCase(); + const isMobile = /mobile|iphone|ipad|android/.test(ua); -// Get the <head> element -const head = document.getElementsByTagName('head')[0]; + // Get the <head> element + const head = document.getElementsByTagName('head')[0]; -// If mobile, insert the viewport meta tag -if (isMobile) { - const meta = document.createElement('meta'); - meta.setAttribute('name', 'viewport'); - meta.setAttribute('content', [ - ['width', 'device-width'], - ['initial-scale', '1'], - ['minimum-scale', '1'], - ['maximum-scale', '1'], - ['user-scalable', 'no'] - ].map(x => x.join('=')).join(',')); - head.appendChild(meta); -} + // If mobile, insert the viewport meta tag + if (isMobile) { + const meta = document.createElement('meta'); + meta.setAttribute('name', 'viewport'); + meta.setAttribute('content', [ + ['width', 'device-width'], + ['initial-scale', '1'], + ['minimum-scale', '1'], + ['maximum-scale', '1'], + ['user-scalable', 'no'] + ].map(x => x.join('=')).join(',')); + head.appendChild(meta); + } -// Switch desktop or mobile version -if (app == 'misskey') { - app = isMobile ? 'mobile' : 'desktop'; -} + // Switch desktop or mobile version + if (app == 'misskey') { + app = isMobile ? 'mobile' : 'desktop'; + } -// Load an app script -// Note: 'async' make it possible to load the script asyncly. -// 'defer' make it possible to run the script when the dom loaded. -const script = document.createElement('script'); -script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`); -script.setAttribute('async', 'true'); -script.setAttribute('defer', 'true'); -head.appendChild(script); + // Load an app script + // Note: 'async' make it possible to load the script asyncly. + // 'defer' make it possible to run the script when the dom loaded. + const script = document.createElement('script'); + script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`); + script.setAttribute('async', 'true'); + script.setAttribute('defer', 'true'); + head.appendChild(script); +} |