2021-02-10 20:42:55 +00:00
|
|
|
|
|
|
|
function checkScaling() {
|
2021-06-28 18:01:08 +00:00
|
|
|
var matches = {
|
|
|
|
'pixel-ratio__1_25': "screen and (-webkit-min-device-pixel-ratio: 1.25) and (-webkit-max-device-pixel-ratio: 1.49), " +
|
|
|
|
"screen and (min-resolution: 1.25dppx) and (max-resolution: 1.49dppx)",
|
|
|
|
'pixel-ratio__1_5': "screen and (-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 1.74), " +
|
|
|
|
"screen and (min-resolution: 1.5dppx) and (max-resolution: 1.74dppx)",
|
|
|
|
'pixel-ratio__1_75': "screen and (-webkit-min-device-pixel-ratio: 1.75) and (-webkit-max-device-pixel-ratio: 1.99), " +
|
|
|
|
"screen and (min-resolution: 1.75dppx) and (max-resolution: 1.99dppx)",
|
|
|
|
};
|
|
|
|
|
|
|
|
for (var c in matches) {
|
|
|
|
if ( window.matchMedia(matches[c]).matches ) {
|
|
|
|
document.body.classList.add(c);
|
|
|
|
break;
|
|
|
|
}
|
2021-02-10 20:42:55 +00:00
|
|
|
}
|
2021-02-19 10:26:55 +00:00
|
|
|
|
|
|
|
if ( !window.matchMedia("screen and (-webkit-device-pixel-ratio: 1.5)," +
|
|
|
|
"screen and (-webkit-device-pixel-ratio: 1)," +
|
|
|
|
"screen and (-webkit-device-pixel-ratio: 2)").matches )
|
|
|
|
{
|
|
|
|
// don't add zoom for mobile devices
|
2021-06-28 14:43:46 +00:00
|
|
|
// if (!(/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent || navigator.vendor || window.opera)))
|
|
|
|
// document.getElementsByTagName('html')[0].setAttribute('style', 'zoom: ' + (1 / window.devicePixelRatio) + ';');
|
2021-02-19 10:26:55 +00:00
|
|
|
}
|
2021-02-10 20:42:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
checkScaling();
|
|
|
|
|
|
|
|
var params = (function() {
|
|
|
|
var e,
|
|
|
|
a = /\+/g, // Regex for replacing addition symbol with a space
|
|
|
|
r = /([^&=]+)=?([^&]*)/g,
|
|
|
|
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
|
|
|
|
q = window.location.search.substring(1),
|
|
|
|
urlParams = {};
|
|
|
|
|
|
|
|
while (e = r.exec(q))
|
|
|
|
urlParams[d(e[1])] = d(e[2]);
|
|
|
|
|
|
|
|
return urlParams;
|
|
|
|
})();
|
|
|
|
|
2021-08-18 10:30:42 +00:00
|
|
|
var checkLocalStorage = (function () {
|
|
|
|
try {
|
|
|
|
var storage = window['localStorage'];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2021-11-19 17:29:36 +00:00
|
|
|
!window.desktop && !!window.AscDesktopEditor &&
|
|
|
|
(window.desktop = window.AscDesktopEditor);
|
|
|
|
|
2021-10-08 22:05:06 +00:00
|
|
|
if ( window.desktop && !!window.RendererProcessVariable ) {
|
|
|
|
var theme = window.RendererProcessVariable.theme
|
|
|
|
|
|
|
|
if ( theme ) {
|
2021-10-14 17:33:30 +00:00
|
|
|
if ( !theme.id && !!theme.type ) {
|
|
|
|
if ( theme.type == 'dark' ) theme.id = 'theme-dark'; else
|
|
|
|
if ( theme.type == 'light' ) theme.id = 'theme-classic-light';
|
|
|
|
}
|
|
|
|
|
2021-10-08 22:05:06 +00:00
|
|
|
if ( theme.id ) {
|
|
|
|
// params.uitheme = undefined;
|
|
|
|
localStorage.setItem("ui-theme-id", theme.id);
|
2021-11-05 21:33:02 +00:00
|
|
|
localStorage.removeItem("ui-theme");
|
2021-10-08 22:05:06 +00:00
|
|
|
}
|
2021-09-20 15:33:39 +00:00
|
|
|
}
|
2021-09-08 07:40:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 10:30:42 +00:00
|
|
|
if ( !!params.uitheme && checkLocalStorage && !localStorage.getItem("ui-theme-id") ) {
|
2021-05-21 12:17:04 +00:00
|
|
|
// const _t = params.uitheme.match(/([\w-]+)/g);
|
|
|
|
|
|
|
|
if ( params.uitheme == 'default-dark' )
|
|
|
|
params.uitheme = 'theme-dark';
|
|
|
|
else
|
|
|
|
if ( params.uitheme == 'default-light' )
|
|
|
|
params.uitheme = 'theme-classic-light';
|
|
|
|
|
2021-09-24 14:12:58 +00:00
|
|
|
localStorage.removeItem("ui-theme");
|
2021-05-21 12:17:04 +00:00
|
|
|
}
|
2021-02-24 20:34:05 +00:00
|
|
|
|
2021-09-24 14:12:58 +00:00
|
|
|
var ui_theme_name = checkLocalStorage && localStorage.getItem("ui-theme-id") ? localStorage.getItem("ui-theme-id") : params.uitheme;
|
2021-05-21 12:48:50 +00:00
|
|
|
if ( !ui_theme_name ) {
|
|
|
|
if ( window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ) {
|
|
|
|
ui_theme_name = 'theme-dark';
|
2021-09-24 14:12:58 +00:00
|
|
|
checkLocalStorage && localStorage.removeItem("ui-theme");
|
2021-05-21 12:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-10 20:42:55 +00:00
|
|
|
if ( !!ui_theme_name ) {
|
|
|
|
document.body.classList.add(ui_theme_name);
|
|
|
|
}
|
2021-11-04 19:44:24 +00:00
|
|
|
|
|
|
|
if ( checkLocalStorage ) {
|
|
|
|
var content_theme = localStorage.getItem("content-theme");
|
|
|
|
if ( content_theme == 'dark' ) {
|
|
|
|
var current_theme = localStorage.getItem("ui-theme");
|
|
|
|
if ( !!current_theme && /type":\s*"dark/.test(current_theme) ) {
|
|
|
|
document.body.classList.add("content-theme-dark");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|