Skip to content

Commit

Permalink
QQ and UC meta
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed Jun 18, 2018
1 parent 45cd85f commit 0e7e19c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
27 changes: 26 additions & 1 deletion pwacompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,28 @@
}
});

const isCapable = capableDisplayModes.indexOf(manifest['display']) !== -1;
const display = manifest['display'];
const isCapable = capableDisplayModes.indexOf(display) !== -1;
meta('mobile-web-app-capable', isCapable);
updateThemeColor(manifest['theme_color'] || 'black');

if (isEdge) {
meta('msapplication-starturl', manifest['start_url'] || '/');
meta('msapplication-TileColor', manifest['theme_color']);
}

// TODO(samthor): We don't detect QQ or UC, we just set the vars anyway.
const orientation = simpleOrientationFor(manifest['orientation']);
meta('x5-orientation', orientation); // QQ
meta('screen-orientation', orientation); // UC
if (display === 'fullscreen') {
meta('x5-fullscreen', 'true'); // QQ
meta('full-screen', 'yes'); // UC
} else if (isCapable) {
meta('x5-page-mode', 'app'); // QQ
meta('browsermode', 'application'); // UC
}

if (!isSafari) {
return; // the rest of this file is for Safari
}
Expand Down Expand Up @@ -211,6 +225,17 @@
return itunes;
}

function simpleOrientationFor(v) {
v = String(v || '');
const prefix = v.substr(0, 3);
if (prefix === 'por') {
return 'portrait';
} else if (prefix === 'lan') {
return 'landscape';
}
return '';
}

/**
* @param {string} color
*/
Expand Down
18 changes: 9 additions & 9 deletions pwacompat.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0e7e19c

Please sign in to comment.