mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-17 09:33:55 +08:00
MOD: 调整回车键逻辑
This commit is contained in:
File diff suppressed because one or more lines are too long
52
src/app.js
52
src/app.js
@@ -9,6 +9,7 @@ class App{
|
||||
|
||||
#life;
|
||||
#pages;
|
||||
#currentPage;
|
||||
#talentSelected = new Set();
|
||||
#totalMax=20;
|
||||
#isEnd = false;
|
||||
@@ -23,6 +24,14 @@ class App{
|
||||
window.onerror = (event, source, lineno, colno, error) => {
|
||||
this.hint(`[ERROR] at (${source}:${lineno}:${colno})\n\n${error?.stack||error||'unknow Error'}`, 'error');
|
||||
}
|
||||
const keyDownCallback = (keyboardEvent) => {
|
||||
if (keyboardEvent.which === 13 || keyboardEvent.keyCode === 13) {
|
||||
const pressEnterFunc = this.#pages[this.#currentPage]?.pressEnter;
|
||||
pressEnterFunc && typeof pressEnterFunc === 'function' && pressEnterFunc();
|
||||
}
|
||||
}
|
||||
window.removeEventListener('keydown', keyDownCallback);
|
||||
window.addEventListener('keydown', keyDownCallback);
|
||||
}
|
||||
|
||||
initPages() {
|
||||
@@ -273,11 +282,11 @@ class App{
|
||||
});
|
||||
this.switch('trajectory');
|
||||
this.#pages.trajectory.born();
|
||||
$(document).keydown(function(event){
|
||||
if(event.which == 32 || event.which == 13){
|
||||
$('#lifeTrajectory').click();
|
||||
}
|
||||
})
|
||||
// $(document).keydown(function(event){
|
||||
// if(event.which == 32 || event.which == 13){
|
||||
// $('#lifeTrajectory').click();
|
||||
// }
|
||||
// })
|
||||
});
|
||||
|
||||
// Trajectory
|
||||
@@ -391,7 +400,9 @@ class App{
|
||||
this.#pages = {
|
||||
loading: {
|
||||
page: loadingPage,
|
||||
clear: ()=>{},
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'loading';
|
||||
},
|
||||
},
|
||||
|
||||
index: {
|
||||
@@ -400,7 +411,11 @@ class App{
|
||||
btnRestart: indexPage.find('#restart'),
|
||||
hint: indexPage.find('.hint'),
|
||||
cnt: indexPage.find('#cnt'),
|
||||
pressEnter: ()=>{
|
||||
this.#pages.index.btnRestart.click();
|
||||
},
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'index';
|
||||
indexPage.find('.hint').hide();
|
||||
|
||||
const times = this.times;
|
||||
@@ -419,7 +434,21 @@ class App{
|
||||
},
|
||||
talent: {
|
||||
page: talentPage,
|
||||
talentList: talentPage.find('#talents'),
|
||||
btnRandom: talentPage.find('#random'),
|
||||
btnNext: talentPage.find('#next'),
|
||||
pressEnter: ()=>{
|
||||
const talentList = this.#pages.talent.talentList;
|
||||
const btnRandom = this.#pages.talent.btnRandom;
|
||||
const btnNext = this.#pages.talent.btnNext;
|
||||
if (talentList.children().length) {
|
||||
btnNext.click();
|
||||
} else {
|
||||
btnRandom.click();
|
||||
}
|
||||
},
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'talent';
|
||||
talentPage.find('ul.selectlist').empty();
|
||||
talentPage.find('#random').show();
|
||||
this.#totalMax = 20;
|
||||
@@ -427,7 +456,12 @@ class App{
|
||||
},
|
||||
property: {
|
||||
page: propertyPage,
|
||||
btnStart: propertyPage.find('#start'),
|
||||
pressEnter: ()=>{
|
||||
this.#pages.property.btnStart.click();
|
||||
},
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'property';
|
||||
freshTotal();
|
||||
propertyPage
|
||||
.find('#talentSelectedView')
|
||||
@@ -436,7 +470,12 @@ class App{
|
||||
},
|
||||
trajectory: {
|
||||
page: trajectoryPage,
|
||||
lifeTrajectory: trajectoryPage.find('#lifeTrajectory'),
|
||||
pressEnter: ()=>{
|
||||
this.#pages.trajectory.lifeTrajectory.click();
|
||||
},
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'trajectory';
|
||||
trajectoryPage.find('#lifeTrajectory').empty();
|
||||
trajectoryPage.find('#summary').hide();
|
||||
this.#isEnd = false;
|
||||
@@ -448,6 +487,7 @@ class App{
|
||||
summary: {
|
||||
page: summaryPage,
|
||||
clear: ()=>{
|
||||
this.#currentPage = 'summary';
|
||||
const judge = summaryPage.find('#judge');
|
||||
const talents = summaryPage.find('#talents');
|
||||
judge.empty();
|
||||
|
Reference in New Issue
Block a user