bugfix, Cookie-Hinweis angepasst

This commit is contained in:
silas
2018-10-20 23:37:19 +02:00
parent 895d5b9016
commit 79076a695d
11 changed files with 91 additions and 37 deletions

View File

@@ -55,6 +55,8 @@ window["app"] = app;
window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
window["Translator"] = Translator;
window["Translator"]["setLanguage"] = Translator.setLanguage;
window["InitPromise"] = InitPromise;
window["InitPromise"]["addPromise"] = InitPromise.addPromise;
SettingsSite.setTemplate("html/application/setting-template.html");
// SettingsSite.shouldAddSettingsAction = false;
@@ -68,7 +70,7 @@ InitPromise.resolve(app).then(async function(){
let settingsManager = SettingsManager.getInstance();
let soundManager = SoundManager.getInstance();
soundManager.play(SoundManager.CHANNELS.MUSIC, {audio: "sound/brightAndBeautifull__.mp3", loop: true, volume: 0.6, muted: !settingsManager.getSetting("play-music", true)});
soundManager.play(SoundManager.CHANNELS.MUSIC, {audio: "sound/brightAndBeautifull__.mp3", loop: true, volume: 0.6, muted: (settingsManager.getSetting("play-music", "1") !== "1")});
app.start(MenuSite);
Translator.setLanguage("de");

View File

@@ -237,15 +237,22 @@ class ScaleHelper {
container.classList.add("no-transition");
}
const numChanged = 5;
let oldDiffIndex = 0;
let oldDiff = [];
for (let i = 0; i < numChanged; i++) {
oldDiff.push(0);
}
let beforeFontSize = fontElement.style.fontSize;
let currentFontSize = 1;
let diff = 0;
let widthDiff = 0;
let heightDiff = 0;
let containerWidth = 0;
let containerHeight = 0;
do {
currentFontSize += diff / (fontWeight + 1);
currentFontSize += oldDiff[oldDiffIndex] / (fontWeight + 1);
fontElement.style.fontSize = currentFontSize + 'px';
let containerStyle = window.getComputedStyle(container);
@@ -256,11 +263,12 @@ class ScaleHelper {
widthDiff = containerWidth - fontElement.offsetWidth;
heightDiff = containerHeight - fontElement.offsetHeight;
oldDiffIndex = (oldDiffIndex+1)%numChanged;
let newDiff = (ignoreWidth ? heightDiff : (ignoreHeight ? widthDiff : Math.min(widthDiff, heightDiff)));
if (newDiff === diff) {
if (newDiff === oldDiff[(oldDiffIndex+1)%numChanged]) {
break;
}
diff = newDiff;
oldDiff[oldDiffIndex] = newDiff;
} while ((widthDiff > (1 - scale) * containerWidth || ignoreWidth) && (heightDiff > (1 - scale) * containerHeight || ignoreHeight));
currentFontSize -= margin;

View File

@@ -19,17 +19,21 @@ Constants.SCRIPTS = {
};
class DataManager {
static load(url, isCachable, raw) {
static async load(url, isCachable, raw) {
isCachable = Helper.nonNull(isCachable, false);
raw = Helper.nonNull(raw, false);
let fullUrl = (isCachable) ? Helper.basePath(DataManager.cachePath + url) : Helper.basePath(DataManager.dataPath + url);
return fetch(fullUrl, {"credentials": "same-origin"}).then(function (res) {
return this._load(fullUrl, raw);
}
static async _load(url, raw) {
return fetch(url, {"credentials": "same-origin"}).then(function (res) {
if (raw) {
return res.text();
}
return res.json();
}).catch(function (e) {
console.error("error", e);
if (!raw) {
return {
"success": false,
@@ -41,7 +45,14 @@ class DataManager {
});
}
static send(url, params) {
static async loadStatic(url, raw) {
raw = Helper.nonNull(raw, false);
let fullUrl = Helper.basePath(url);
return this._load(fullUrl, raw);
}
static async send(url, params) {
let fullUrl = Helper.basePath(DataManager.dataPath + url);
if (!(params instanceof FormData)) {