diff --git a/src/ts/client/Administrator/HistoryAdministrator.ts b/src/ts/client/Administrator/HistoryAdministrator.ts index 791c45c..14f3843 100644 --- a/src/ts/client/Administrator/HistoryAdministrator.ts +++ b/src/ts/client/Administrator/HistoryAdministrator.ts @@ -7,51 +7,43 @@ import { LanguageInApplication } from "../../type/LanguageInApplication"; export class HistoryAdministrator{ private app:IAppUsedToReadAndChangePage; private urlAd:URLAdministrator - private transitionPile:TransitionItem[] = []; constructor(app:IAppUsedToReadAndChangePage){ this.app = app; this.urlAd = new URLAdministrator(app) - window.addEventListener('popstate', (e) => { - this.back(); + window.addEventListener('popstate', ({state}) => { + this.app.transition(state.pageState,state.requiredObject,{ifAppendHistory:false}) }); } - async appendHistory(){ - this.transitionPile.push({ - pageState:this.app.state.state, - requiredObject:this.app.state.requiredObj - }) - - } clearIntroduction(){ localStorage.setItem("KSSRs::HistoryAdministrator::clearIntroduction_v1","true") - } checkIfIntroductionIsOver(){ return localStorage.getItem("KSSRs::HistoryAdministrator::clearIntroduction_v1") === "true" } registerCurrentPage(){ - localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",JSON.stringify({ + const data = { pageState:this.app.state.state, requiredObject:this.app.state.requiredObj - })) + } + localStorage.setItem("KSSRs::HistoryAdministrator::PreviousPage",JSON.stringify(data)) switch(this.app.state.state){ case "detailView":{ const obj = this.app.state.requiredObj as APIFunctions["record_detail"]["atServer"] - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/ogpDetailView/?state=detailView&gs=${obj.gameSystemEnv.gameSystemID}&gm=${obj.gameSystemEnv.gameModeID}&id=${obj.id}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/ogpDetailView/?state=detailView&gs=${obj.gameSystemEnv.gameSystemID}&gm=${obj.gameSystemEnv.gameModeID}&id=${obj.id}`) break; } case "userPageInWhole":{ const obj = this.app.state.requiredObj as {runnerID:string} - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) break; } case "userPageInSpecific":{ const obj = this.app.state.requiredObj as TargetGameMode&{runnerID:string} - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/?state=userPageInWhole&id=${obj.runnerID}`) break; } default: - history.pushState(null,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/`) + history.pushState(data,`Kirby-Speed/ScoreRecorders:${this.app.state.state}`,`/`) break; } @@ -63,11 +55,6 @@ export class HistoryAdministrator{ console.info(`[KSSRs::HistoryAdministrator::TargetMode] register current target gamemode: ${this.app.state.gameSystemEnvDisplayed.gameSystem?.English} / ${this.app.state.gameSystemEnvDisplayed.gameMode?.Japanese}`) } - back(){ - const past = this.transitionPile.pop(); - if (past === undefined) return; - this.app.transition(past.pageState,past.requiredObject,{ifAppendHistory:false}) - } getPreviousPageData():TransitionItem|"redirect"|null{ const str = localStorage.getItem("KSSRs::HistoryAdministrator::PreviousPage") if (str === null) return null; diff --git a/src/ts/client/App.ts b/src/ts/client/App.ts index d05d336..e3019a6 100644 --- a/src/ts/client/App.ts +++ b/src/ts/client/App.ts @@ -109,8 +109,6 @@ export default class App implements IAppUsedToChangeState{ } async transition(nextState:T, requestObject:RequiredObjectType,{ifAppendHistory=true,title=""}:{ifAppendHistory?:boolean,title?:string} = {}){ this.goToTop(); - if (ifAppendHistory) this.historyAd.appendHistory() - try { await this.transitionAd.transition(nextState,requestObject,{title:title}) if (ifAppendHistory) this.historyAd.registerCurrentPage(); diff --git a/src/ts/client/view/parts/Input/searchConditionSelector.ts b/src/ts/client/view/parts/Input/searchConditionSelector.ts index d2471e6..4a6cc64 100644 --- a/src/ts/client/view/parts/Input/searchConditionSelector.ts +++ b/src/ts/client/view/parts/Input/searchConditionSelector.ts @@ -187,7 +187,7 @@ export class SearchConditionSelectorView implements IView{ new DecideButtonPart(this.container.appendChild(elementWithoutEscaping`
`) as HTMLElement,{ text:{Japanese:"決定",English:"Submit"},language, onClick:() => { - if (!(!this.isAbilitySelectEditor(abilitySelectEditor) && abilitySelectEditor.isFillAllAbility())){ + if (abilitySelectEditor.kind === "PlayersWithAttributesPart" && !abilitySelectEditor.isAttributeConditionWithAbilityCondition()){ errorViewer.innerHTML = choiceString({Japanese:"能力欄の入力が不十分です。(能力属性のみを指定した検索は現在できません。)",English:"The input of Ability isn't enough. (For now, searching with only specifying attributes of ability is not implemented.)"},language) return; } @@ -199,11 +199,6 @@ export class SearchConditionSelectorView implements IView{ if (difficultyID !== undefined) this.getTargetItems(difficultyID).then(targetItems => targetSelectEditor.refreshOption(targetItems)) } - isAbilitySelectEditor(editor:EditorPlayersWithAttributesPart|EditorMultipleIDPart):editor is EditorMultipleIDPart{ - const value = editor.value - if (value === undefined) return false - return typeof value[0] === "string" - } destroy(){ this.editorManager.destroy() } diff --git a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorMultipleIDPart.ts b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorMultipleIDPart.ts index 2fe1afd..7ee3cc1 100644 --- a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorMultipleIDPart.ts +++ b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorMultipleIDPart.ts @@ -11,6 +11,7 @@ import { MultiLanguageDescription } from "../../../../../utility/aboutLang"; import { ILabelledDocument } from "../../../../../type/list/ILabelledDocument"; export class EditorMultipleIDPart implements EditorPart { + public readonly kind = "MultipleIDPart" private container: HTMLElement; private selectInput: SelectChoicesCapsuled; private htmlCon: HTMLConverter; diff --git a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayerWithAttributesPart.ts b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayerWithAttributesPart.ts index 8ab809a..ce4d33a 100644 --- a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayerWithAttributesPart.ts +++ b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayerWithAttributesPart.ts @@ -116,10 +116,10 @@ export class EditorPlayerWithAttributesPart implements EditorPart { get requiredField(){ return this._requiredField; } - isFillAllAbility(){ + isAttributeConditionWithAbilityCondition(){ const abilityFill = this.selectInput.getValueAsArray()[0] !== undefined - const attributeEmpty = this.selectInput.getValueAsArray().length === 0 - return (abilityFill && attributeEmpty) || !attributeEmpty + const attributeConditionExist = this.attributeChoices.some(attributeChoice => attributeChoice.editor.value.length !== 0) + return abilityFill || !attributeConditionExist } destroy(){ if (this.unsubscribe !== null)this.unsubscribe(); diff --git a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayersWithAttributesPart.ts b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayersWithAttributesPart.ts index 39af58b..a5053db 100644 --- a/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayersWithAttributesPart.ts +++ b/src/ts/client/view/parts/SetNewRegulation/Editor/EditorPlayersWithAttributesPart.ts @@ -12,6 +12,7 @@ import { SmallButtonPart } from "../../MultiButtonPart"; type HandledType ={abilityID:string,attribute:OnePlayerOfAbilityAttribute} export class EditorPlayersWithAttributesPart implements EditorPart { + public readonly kind = "PlayersWithAttributesPart" private container: HTMLElement; private playersWithAttributesChoices:EditorPlayerWithAttributesPart[] = []; private htmlCon: HTMLConverter; @@ -142,8 +143,8 @@ export class EditorPlayersWithAttributesPart implements EditorPart editor.isFillAllAbility()) + isAttributeConditionWithAbilityCondition(){ + return this.playersWithAttributesChoices.every((editor) => editor.isAttributeConditionWithAbilityCondition()) } refresh(values:{abilityID:string,attribute:OnePlayerOfAbilityAttribute}[]) { while (true){