update to laptop

This commit is contained in:
silas
2018-07-06 18:39:42 +02:00
parent f04c9ec9b7
commit eea36bb922
11 changed files with 206 additions and 85 deletions

File diff suppressed because one or more lines are too long

View File

@@ -3107,13 +3107,16 @@ class ParentSegment extends Segment {
this.rotation %= 360;
this._updateRotationClass();
this.getLevel().checkHasWon(new Promise((resolve, reject) => {
this.element.addEventListener("animationend", resolve);
}));
// return new DelayPromise(250);
return new Promise(function (resolve) {
this.element.classList.add("rotating");
let self = this;
let delayPromise = new Promise(function (resolve) {
setTimeout(resolve, 250);
}).then(()=>{
self.element.classList.remove("rotating");
});
this.getLevel().checkHasWon(delayPromise);
return delayPromise;
}
}
@@ -3180,13 +3183,18 @@ class ParentSegment extends Segment {
this._updateRotationClass();
const self = this;
this.element.onclick = function () {
this.element.onclick = function (e) {
self.rotate();
e.stopPropagation();
};
for (let i = 0, n = this.children.length; i < n; i++) {
this.children[i]._updateElement();
childContainer.appendChild(this.children[i].getElement());
if (i%2 === 1 && this.children.length-1 !== i)
{
childContainer.appendChild(document.createElement("br"));
}
}
}
}
@@ -3357,6 +3365,24 @@ class RowSegment extends ParentSegment{
}
return rotations;
}
_updateElement() {
const childContainer = this.element.querySelector(".child-container");
childContainer.removeAllChildren();
this._updateRotationClass();
const self = this;
this.element.onclick = function (e) {
self.rotate();
e.stopPropagation();
};
for (let i = 0, n = this.children.length; i < n; i++) {
this.children[i]._updateElement();
childContainer.appendChild(this.children[i].getElement());
}
}
}
class RowLevel extends Level {
@@ -3425,11 +3451,11 @@ class SixWordsRowLevel extends Level {
) {
let leafsWords = [];
leafsWords[0] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[1] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[2] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[3] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[4] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[5] = Level._createLeafsForWord(this.words[0], this.templateContainer.copyLeafTemplate());
leafsWords[1] = Level._createLeafsForWord(this.words[1], this.templateContainer.copyLeafTemplate());
leafsWords[2] = Level._createLeafsForWord(this.words[2], this.templateContainer.copyLeafTemplate());
leafsWords[3] = Level._createLeafsForWord(this.words[3], this.templateContainer.copyLeafTemplate());
leafsWords[4] = Level._createLeafsForWord(this.words[4], this.templateContainer.copyLeafTemplate());
leafsWords[5] = Level._createLeafsForWord(this.words[5], this.templateContainer.copyLeafTemplate());
let rootSegment = new RowSegment(this.templateContainer.copyRowTemplate());
for (let i = 0, n = this.wordLength / 4; i < n; i++) {
@@ -3492,8 +3518,13 @@ class SixWordsRowLevel extends Level {
triangle.getElement().classList.add("type-1");
}
else {
triangle.addChild(parents[0]);
triangle.addChild(parents[1]);
let rowSegment = new RowSegment(this.templateContainer.copyRowTemplate());
rowSegment.addChild(parents[0]);
rowSegment.addChild(parents[1]);
triangle.addChild(rowSegment);
triangle.addChild(parent);
parent.addChild(parents[2]);
@@ -3510,12 +3541,18 @@ class SixWordsRowLevel extends Level {
}
}
class ThreeWordsRowLevel8 extends SixWordsRowLevel {
class SixWordsRowLevel8 extends SixWordsRowLevel {
constructor(templateContainer) {
super(templateContainer, 8);
}
}
class SixWordsRowLevel12 extends SixWordsRowLevel {
constructor(templateContainer) {
super(templateContainer, 12);
}
}
class LevelHelper {
static setLevelType(typeId, level) {
LevelHelper.types[typeId] = level;
@@ -3545,7 +3582,8 @@ LevelHelper.types = {
20: SimpleLevel,
40: RowLevel8,
60: RowLevel10,
100: ThreeWordsRowLevel8,
100: SixWordsRowLevel8,
140: SixWordsRowLevel12,
};
class WordRotatorDb extends MyDb {
@@ -3599,10 +3637,6 @@ class WordRotatorDb extends MyDb {
}
}
console.log("levels count:", newLevels.length);
console.log("new levels:", newLevels);
console.log("wrong levels:", wrongLevels);
if (newLevels.length === 0) {
return null;
}
@@ -3689,8 +3723,8 @@ class LevelSite extends AbstractSite$1 {
this._siteContent.classList.remove('won');
const db = WordRotatorDb.getInstance();
const nextLevelJson = await db.loadNextLevel([20,40,60]);
// const nextLevelJson = await db.loadNextLevel([100]);
// const nextLevelJson = await db.loadNextLevel([20,40,60, 100]);
const nextLevelJson = await db.loadNextLevel([140]);
if (nextLevelJson === null) {
this.startSite(EndSite);
return;