From 580e06360ea8b430d4cc1b358bd487598b7267c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?syuilo=E2=AD=90=EF=B8=8F?= Date: Mon, 17 Apr 2017 15:52:38 +0900 Subject: [PATCH] Update script.js --- src/web/app/client/script.js | 41 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/web/app/client/script.js b/src/web/app/client/script.js index fd0c20e012..465d3edb38 100644 --- a/src/web/app/client/script.js +++ b/src/web/app/client/script.js @@ -1,30 +1,29 @@ /** * MISSKEY CLIENT ENTRY POINT */ -{ - const head = document.getElementsByTagName('head')[0]; - // Detect user language - let lang = navigator.language.split('-')[0]; - if (!/^(en|ja)$/.test(lang)) lang = 'en'; +const head = document.getElementsByTagName('head')[0]; - // Detect user agent - const ua = navigator.userAgent.toLowerCase(); - const isMobile = /mobile|iphone|ipad|android/.test(ua); +// Detect user language +let lang = navigator.language.split('-')[0]; +if (!/^(en|ja)$/.test(lang)) lang = 'en'; - const app = isMobile ? 'mobile' : 'desktop'; +// Detect user agent +const ua = navigator.userAgent.toLowerCase(); +const isMobile = /mobile|iphone|ipad|android/.test(ua); - // Load app script - const script = document.createElement('script'); - script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`); - script.setAttribute('async', 'true'); - script.setAttribute('defer', 'true'); - head.appendChild(script); +const app = isMobile ? 'mobile' : 'desktop'; - 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'); - head.appendChild(meta); - } +// Load app script +const script = document.createElement('script'); +script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`); +script.setAttribute('async', 'true'); +script.setAttribute('defer', 'true'); +head.appendChild(script); + +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'); + head.appendChild(meta); }