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

@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
testcafe firefox test/test.testcafe.js #testcafe firefox test/test.testcafe.js
testcafe remote test/test.testcafe.js --qr-code

File diff suppressed because one or more lines are too long

BIN
public/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -3374,17 +3374,21 @@ Constants.SCRIPTS = {
}; };
class DataManager { class DataManager {
static load(url, isCachable, raw) { static async load(url, isCachable, raw) {
isCachable = Helper.nonNull(isCachable, false); isCachable = Helper.nonNull(isCachable, false);
raw = Helper.nonNull(raw, false); raw = Helper.nonNull(raw, false);
let fullUrl = (isCachable) ? Helper.basePath(DataManager.cachePath + url) : Helper.basePath(DataManager.dataPath + url); 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) { if (raw) {
return res.text(); return res.text();
} }
return res.json(); return res.json();
}).catch(function (e) { }).catch(function (e) {
console.error("error", e);
if (!raw) { if (!raw) {
return { return {
"success": false, "success": false,
@ -3396,7 +3400,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); let fullUrl = Helper.basePath(DataManager.dataPath + url);
if (!(params instanceof FormData)) { if (!(params instanceof FormData)) {
@ -4886,15 +4897,22 @@ class ScaleHelper {
container.classList.add("no-transition"); 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 beforeFontSize = fontElement.style.fontSize;
let currentFontSize = 1; let currentFontSize = 1;
let diff = 0;
let widthDiff = 0; let widthDiff = 0;
let heightDiff = 0; let heightDiff = 0;
let containerWidth = 0; let containerWidth = 0;
let containerHeight = 0; let containerHeight = 0;
do { do {
currentFontSize += diff / (fontWeight + 1); currentFontSize += oldDiff[oldDiffIndex] / (fontWeight + 1);
fontElement.style.fontSize = currentFontSize + 'px'; fontElement.style.fontSize = currentFontSize + 'px';
let containerStyle = window.getComputedStyle(container); let containerStyle = window.getComputedStyle(container);
@ -4905,11 +4923,12 @@ class ScaleHelper {
widthDiff = containerWidth - fontElement.offsetWidth; widthDiff = containerWidth - fontElement.offsetWidth;
heightDiff = containerHeight - fontElement.offsetHeight; heightDiff = containerHeight - fontElement.offsetHeight;
oldDiffIndex = (oldDiffIndex+1)%numChanged;
let newDiff = (ignoreWidth ? heightDiff : (ignoreHeight ? widthDiff : Math.min(widthDiff, heightDiff))); let newDiff = (ignoreWidth ? heightDiff : (ignoreHeight ? widthDiff : Math.min(widthDiff, heightDiff)));
if (newDiff === diff) { if (newDiff === oldDiff[(oldDiffIndex+1)%numChanged]) {
break; break;
} }
diff = newDiff; oldDiff[oldDiffIndex] = newDiff;
} while ((widthDiff > (1 - scale) * containerWidth || ignoreWidth) && (heightDiff > (1 - scale) * containerHeight || ignoreHeight)); } while ((widthDiff > (1 - scale) * containerWidth || ignoreWidth) && (heightDiff > (1 - scale) * containerHeight || ignoreHeight));
currentFontSize -= margin; currentFontSize -= margin;
@ -6073,6 +6092,7 @@ class WordRotatorDb extends MyDb {
} }
upgrade(db, oldVersion, newVersion, e) { upgrade(db, oldVersion, newVersion, e) {
console.log("upgrading!");
if (Helper.isNull(oldVersion) || oldVersion < 1 && newVersion >= 1) { if (Helper.isNull(oldVersion) || oldVersion < 1 && newVersion >= 1) {
let levelObjectStore = db.createObjectStore(WordRotatorDb.OBJECT_STORE.LEVEL, {"keyPath": "id"}); let levelObjectStore = db.createObjectStore(WordRotatorDb.OBJECT_STORE.LEVEL, {"keyPath": "id"});
} }
@ -6087,7 +6107,9 @@ class WordRotatorDb extends MyDb {
}; };
async saveManyLevels(levels) { 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) { async loadLevel(levelId) {
@ -6677,11 +6699,12 @@ class MenuSite extends WordRotatorBaseSite {
let levelSegment = this.findBy("#level"); let levelSegment = this.findBy("#level");
let scaleHelper = new ScaleHelper(); 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); let levelStyle = getComputedStyle(levelSegment);
playButton.style.width = levelStyle.getPropertyValue("width"); 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); 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); scaleHelper.scaleToFull(levelNumber, levelNumber.parentElement, false, false, 8, null, null, false);
@ -6693,9 +6716,9 @@ class MenuSite extends WordRotatorBaseSite {
//Musikbuttons update, falls in den Einstellungen umgestellt //Musikbuttons update, falls in den Einstellungen umgestellt
let settingsManager = SettingsManager.getInstance(); let settingsManager = SettingsManager.getInstance();
let playSoundButton = this.findBy("#play-sound"); 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"); let playMusicButton = this.findBy("#play-music");
playMusicButton.checked = settingsManager.getSetting("play-music", true); playMusicButton.checked = (settingsManager.getSetting("play-music", "1") === "1");
return res; return res;
} }
@ -6811,6 +6834,7 @@ class MenuSite extends WordRotatorBaseSite {
} }
} }
let levels = await Promise.all(levelPromises); let levels = await Promise.all(levelPromises);
console.log("levels to save", levels);
await db.saveManyLevels(levels); await db.saveManyLevels(levels);
if (newLastSync != null && newLastSync !== "null") { if (newLastSync != null && newLastSync !== "null") {
@ -7161,6 +7185,8 @@ window["app"] = app;
window["app"]["refreshCurrentSite"] = app.refreshCurrentSite; window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
window["Translator"] = Translator; window["Translator"] = Translator;
window["Translator"]["setLanguage"] = Translator.setLanguage; window["Translator"]["setLanguage"] = Translator.setLanguage;
window["InitPromise"] = InitPromise;
window["InitPromise"]["addPromise"] = InitPromise.addPromise;
SettingsSite.setTemplate("html/application/setting-template.html"); SettingsSite.setTemplate("html/application/setting-template.html");
// SettingsSite.shouldAddSettingsAction = false; // SettingsSite.shouldAddSettingsAction = false;
@ -7174,7 +7200,7 @@ InitPromise.resolve(app).then(async function(){
let settingsManager = SettingsManager.getInstance(); let settingsManager = SettingsManager.getInstance();
let soundManager = SoundManager.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); app.start(MenuSite);
Translator.setLanguage("de"); Translator.setLanguage("de");

File diff suppressed because one or more lines are too long

View File

@ -55,6 +55,8 @@ window["app"] = app;
window["app"]["refreshCurrentSite"] = app.refreshCurrentSite; window["app"]["refreshCurrentSite"] = app.refreshCurrentSite;
window["Translator"] = Translator; window["Translator"] = Translator;
window["Translator"]["setLanguage"] = Translator.setLanguage; window["Translator"]["setLanguage"] = Translator.setLanguage;
window["InitPromise"] = InitPromise;
window["InitPromise"]["addPromise"] = InitPromise.addPromise;
SettingsSite.setTemplate("html/application/setting-template.html"); SettingsSite.setTemplate("html/application/setting-template.html");
// SettingsSite.shouldAddSettingsAction = false; // SettingsSite.shouldAddSettingsAction = false;
@ -68,7 +70,7 @@ InitPromise.resolve(app).then(async function(){
let settingsManager = SettingsManager.getInstance(); let settingsManager = SettingsManager.getInstance();
let soundManager = SoundManager.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); app.start(MenuSite);
Translator.setLanguage("de"); Translator.setLanguage("de");

View File

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

View File

@ -19,17 +19,21 @@ Constants.SCRIPTS = {
}; };
class DataManager { class DataManager {
static load(url, isCachable, raw) { static async load(url, isCachable, raw) {
isCachable = Helper.nonNull(isCachable, false); isCachable = Helper.nonNull(isCachable, false);
raw = Helper.nonNull(raw, false); raw = Helper.nonNull(raw, false);
let fullUrl = (isCachable) ? Helper.basePath(DataManager.cachePath + url) : Helper.basePath(DataManager.dataPath + url); 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) { if (raw) {
return res.text(); return res.text();
} }
return res.json(); return res.json();
}).catch(function (e) { }).catch(function (e) {
console.error("error", e);
if (!raw) { if (!raw) {
return { return {
"success": false, "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); let fullUrl = Helper.basePath(DataManager.dataPath + url);
if (!(params instanceof FormData)) { if (!(params instanceof FormData)) {

View File

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

View File

@ -72,11 +72,12 @@ export class MenuSite extends WordRotatorBaseSite {
let levelSegment = this.findBy("#level"); let levelSegment = this.findBy("#level");
let scaleHelper = new ScaleHelper(); 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); let levelStyle = getComputedStyle(levelSegment);
playButton.style.width = levelStyle.getPropertyValue("width"); 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); 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); 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 //Musikbuttons update, falls in den Einstellungen umgestellt
let settingsManager = SettingsManager.getInstance(); let settingsManager = SettingsManager.getInstance();
let playSoundButton = this.findBy("#play-sound"); 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"); let playMusicButton = this.findBy("#play-music");
playMusicButton.checked = settingsManager.getSetting("play-music", true); playMusicButton.checked = (settingsManager.getSetting("play-music", "1") === "1");
return res; return res;
} }
@ -206,6 +207,7 @@ export class MenuSite extends WordRotatorBaseSite {
} }
} }
let levels = await Promise.all(levelPromises); let levels = await Promise.all(levelPromises);
console.log("levels to save", levels);
await db.saveManyLevels(levels); await db.saveManyLevels(levels);
if (newLastSync != null && newLastSync !== "null") { if (newLastSync != null && newLastSync !== "null") {

View File

@ -1,9 +1,9 @@
import {Selector} from 'testcafe'; import {Selector} from 'testcafe';
import {ClientFunction} from 'testcafe'; import {ClientFunction} from 'testcafe';
let isLocal = false let isLocal = true;
;
const goBack = ClientFunction(() => window.history.back()); const goBack = ClientFunction(() => window.history.back());
const testLocalStorageSet = ClientFunction((key, value) => { const testLocalStorageSet = ClientFunction((key, value) => {
localStorage.setItem(key, value) localStorage.setItem(key, value)
@ -393,11 +393,12 @@ test('LoadLastLevel', async t => {
}); });
test('LevelRotation', async t => { test('LevelRotation', async t => {
await waitForMainMenu(t); await waitForMainMenu(t);
await t.click(Selector('.segment-parent').nth(SEGMENT.THREE)) await t
.click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.wait(3700) .wait(1000)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
@ -413,7 +414,7 @@ test('LevelRotation', async t => {
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.wait(3700) .wait(2000)
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.THREE).getStyleProperty('transform')).eql("matrix(0, -1, 1, 0, 0, 0)")
.expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)") .expect(Selector('.segment-parent').nth(SEGMENT.FOUR).getStyleProperty('transform')).eql("matrix(0, 1, -1, 0, 0, 0)")
.click(Selector('.segment-parent').nth(SEGMENT.THREE)) .click(Selector('.segment-parent').nth(SEGMENT.THREE))
@ -425,7 +426,7 @@ test('LevelRotation', async t => {
.expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("NGAU"); .expect(Selector('.segment-parent').nth(SEGMENT.THREE).textContent).eql("NGAU");
}).before(async t => { }).before(async t => {
await replaceRandom([0.9, 0.5]); await replaceRandom([0.5]);
}); });
test('SendUserstats', async t => { test('SendUserstats', async t => {
await waitForMainMenu(t); await waitForMainMenu(t);