// note: this replacement assumes that the replaced classname is not hte first classname to be modifiedfunctionchangeClassName(old,neew){Array.from(document.getElementsByClassName(old)).forEach((elem)=>{elem.className=elem.className.replace(` ${old}`,` ${neew}`);});}varparams=newURLSearchParams(window.location.search);varcharacters=undefined;varcurrentCharacter=undefined;varcharacterSelector=document.getElementById("characterSelector");/* Get the character names from the character selector. */functiongetCharacterNames(){// @ts-ignorereturnArray.from(characterSelector.childNodes).map((option)=>option.value);}functioncharacterInUrl(){returnparams.get("actingAs");}functionsetCharacter(charName){currentCharacter=charName;characterSelector["value"]=currentCharacter;params.set("actingAs",charName);window.history.replaceState({},"",`${location.pathname}?${params}`);}/* Make the chosen character the current character. */functionmakeCharacterCurrent(characterName){if(characterName!=currentCharacter){// console.log(`Switching to character ${characterName}`)changeClassName("right","left");// move all to the leftchangeClassName(`${characterName} left`,`${characterName} right`);// make current character the current 'a'setCharacter(characterName);}}/* Fetch info about the current characters from the `<select> element.` */functioncacheCharacters(){characters=getCharacterNames();makeCharacterCurrent(characterInUrl()||characters[0]);}functionselectCharacter(e: PointerEvent){// @ts-ignoremakeCharacterCurrent(e.target.value);}cacheCharacters();characterSelector.addEventListener("change",selectCharacter);