-
Notifications
You must be signed in to change notification settings - Fork 362
Save user solutions and show them on page #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Click a solution to fill it in the editor
Minor typo :)
…Only your solutions. Items in menu also don't have selectors in them.
…hen your input is clear
… game will load them before triggering Win
…let you pass level 6 because the game actually checks the selector on html different from HTML Editor window. Now it properly parses html from level.boardMarkup
| .display-help solution { | ||
| display: inline-block; | ||
| color: #AAA; | ||
| background: rgba(255,255,255,.1); | ||
| border: none; | ||
| padding: 0 6px 0 6px; | ||
| margin: 2px 4px 2px 0; | ||
| font-size: 13px; | ||
| font-family: menlo,monospace; | ||
| font-weight: normal; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste from tag but with slighlty different margins to look good inline
| solution { | ||
| cursor: pointer; | ||
| padding: 0 3px; | ||
| color: #AAA; | ||
| font-size: 13px; | ||
| font-weight: bold; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show it's clickable via pointer cursor
| <h4 class="solutions-title">Solutions</h4> | ||
| <div class="solutions"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Sulotions title and container much like examples
| var solutions = [] | ||
| if (progress.guessHistory[currentLevel]) { | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| solutions = progress.guessHistory[currentLevel].solutions; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get solutions from progress. If the progress exists it will populate its solutions. But additional check is needed because level progress might exist without solutions and in that case progress.guessHistory[currentLevel].solutions will return undefined which is obviously not iterable
| if (progress.guessHistory[currentLevel]) { | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| if (!progress.guessHistory[currentLevel].solutions.includes(rule)) { | ||
| $(".display-help .solutions-title").show(); | ||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").append(solution); | ||
| } | ||
| } | ||
| } | ||
| else { | ||
| console.log('shit') | ||
| $(".display-help .solutions-title").show(); | ||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").append(solution); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are solutions check the input rule if it matches existing solution. If it's new then add it to solutions container.
If there were no solutions previously you need to show solutions-title also
js/restaurant.js
Outdated
| if (progress.guessHistory[currentLevel]) { | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| if (!progress.guessHistory[currentLevel].solutions.includes(rule)) { | ||
| $(".display-help .solutions-title").show(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this line is redundant since if we have solutions the title should have been shown
| if (localStorage.getItem("hardcore") === "1" && progress.guessHistory[currentLevel]) { | ||
| for (let s of document.querySelectorAll('.display-help .solutions *')) { | ||
| if (s.textContent === rule) { | ||
|
|
||
| $(".strobe").removeClass("strobe"); | ||
| ruleSelected.removeClass("strobe"); | ||
| ruleSelected.addClass("shake"); | ||
|
|
||
| s.classList.add("shake") | ||
| setTimeout(function(){ | ||
| s.classList.remove("shake"); | ||
| $(".shake").removeClass("shake"); | ||
| $(".strobe").removeClass("strobe"); | ||
| levelSelected.addClass("strobe"); | ||
| },500); | ||
|
|
||
| $(".result").fadeOut(); | ||
|
|
||
| return; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the solution exists find it in the solutions container and shake it to indicate it's there
js/restaurant.js
Outdated
| if (progress.guessHistory[currentLevel]) { | ||
| $(".display-help .solutions-title").show(); | ||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").show(); | ||
| if (progress.guessHistory[currentLevel].solutions) { | ||
| if (!progress.guessHistory[currentLevel].solutions.includes(rule)) { | ||
| $(".display-help .solutions-title").show(); | ||
| let solution = $("<solution>" + rule + "</solution>"); | ||
| $(".display-help .solutions").append(solution); | ||
| } | ||
| } | ||
| else { | ||
| $(".display-help .solutions").append(solution); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay this fixes the redundancy from previous commit
Click a solution to fill it in the editor