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)) {

View File

@@ -14,6 +14,7 @@ export class WordRotatorDb extends MyDb {
}
upgrade(db, oldVersion, newVersion, e) {
console.log("upgrading!");
if (Helper.isNull(oldVersion) || oldVersion < 1 && newVersion >= 1) {
let levelObjectStore = db.createObjectStore(WordRotatorDb.OBJECT_STORE.LEVEL, {"keyPath": "id"});
}
@@ -28,7 +29,9 @@ export class WordRotatorDb extends MyDb {
};
async saveManyLevels(levels) {
return this.saveMany(levels, WordRotatorDb.OBJECT_STORE.LEVEL);
return this.saveMany(levels, WordRotatorDb.OBJECT_STORE.LEVEL).catch(e => {
console.error("insert error!", e);
});
}
async loadLevel(levelId) {

View File

@@ -72,11 +72,12 @@ export class MenuSite extends WordRotatorBaseSite {
let levelSegment = this.findBy("#level");
let scaleHelper = new ScaleHelper();
scaleHelper.scaleToFull(levelSegment, levelSegment.parentElement, false, false, 2, 8, null, false);
await scaleHelper.scaleToFull(levelSegment, levelSegment.parentElement, false, false, 2, 8, null, false);
// debugger;
let levelStyle = getComputedStyle(levelSegment);
playButton.style.width = levelStyle.getPropertyValue("width");
scaleHelper.scaleToFull(playButton.children[0], playButton, null, null, null, null, null, false);
scaleHelper.scaleToFull(playButton.children[0], playButton, null, null, null, 4, null, false);
await scaleHelper.scaleTo(0.2, levelNumber.parentElement, levelNumber.parentElement.parentElement, null, null, null, 10, null, false);
scaleHelper.scaleToFull(levelNumber, levelNumber.parentElement, false, false, 8, null, null, false);
@@ -88,9 +89,9 @@ export class MenuSite extends WordRotatorBaseSite {
//Musikbuttons update, falls in den Einstellungen umgestellt
let settingsManager = SettingsManager.getInstance();
let playSoundButton = this.findBy("#play-sound");
playSoundButton.checked = settingsManager.getSetting("play-sound", true);
playSoundButton.checked = (settingsManager.getSetting("play-sound", "1") === "1");
let playMusicButton = this.findBy("#play-music");
playMusicButton.checked = settingsManager.getSetting("play-music", true);
playMusicButton.checked = (settingsManager.getSetting("play-music", "1") === "1");
return res;
}
@@ -206,6 +207,7 @@ export class MenuSite extends WordRotatorBaseSite {
}
}
let levels = await Promise.all(levelPromises);
console.log("levels to save", levels);
await db.saveManyLevels(levels);
if (newLastSync != null && newLastSync !== "null") {