Update script.js

This commit is contained in:
syuilo⭐️ 2017-04-17 15:52:38 +09:00 committed by GitHub
parent d0f11c0a52
commit 580e06360e

View File

@ -1,30 +1,29 @@
/** /**
* MISSKEY CLIENT ENTRY POINT * MISSKEY CLIENT ENTRY POINT
*/ */
{
const head = document.getElementsByTagName('head')[0];
// Detect user language const head = document.getElementsByTagName('head')[0];
let lang = navigator.language.split('-')[0];
if (!/^(en|ja)$/.test(lang)) lang = 'en';
// Detect user agent // Detect user language
const ua = navigator.userAgent.toLowerCase(); let lang = navigator.language.split('-')[0];
const isMobile = /mobile|iphone|ipad|android/.test(ua); 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 app = isMobile ? 'mobile' : 'desktop';
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) { // Load app script
const meta = document.createElement('meta'); const script = document.createElement('script');
meta.setAttribute('name', 'viewport'); script.setAttribute('src', `/assets/${app}.${VERSION}.${lang}.js`);
meta.setAttribute('content', 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no'); script.setAttribute('async', 'true');
head.appendChild(meta); 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);
} }