(function(){
const root=document.querySelector(‘[data-practice=”apartment”]’);
if(!root) return;
const data={“words”:[[“아파트”,”a-pa-teu”,”apartment”,”Apartment complex or building.”,”아파트 입구”],[“동”,”dong”,”building number”,”Apartment building number.”,”101동”],[“호”,”ho”,”unit number”,”Apartment unit.”,”1203호”],[“층”,”cheung”,”floor”,”ชั้น.”,”5층”],[“입구”,”ip-gu”,”entrance”,”Place to enter.”,”입구”],[“관리사무소”,”gwal-li-sa-mu-so”,”management office”,”Apartment office.”,”관리사무소”],[“주차장”,”ju-cha-jang”,”parking lot”,”Parking area.”,”지하 주차장”],[“지하”,”ji-ha”,”basement”,”Underground level.”,”지하 1층”],[“엘리베이터”,”el-li-be-i-teo”,”elevator”,”Lift inside building.”,”엘리베이터”],[“경비실”,”gyeong-bi-sil”,”security office”,”Guard office.”,”경비실”]],”situations”:[[“In 101동 1203호, which part is the building?”,”101동”,[“1203호”,”101동”,”5층”,”입구”],”동 marks the apartment building number.”],[“You need help from the apartment office. Which sign should you look for?”,”관리사무소”,[“경비실”,”관리사무소”,”주차장”,”호”],”관리사무소 is the management office.”]]};
let flash=0, mc=0, spell=0, sit=0, score=0, total=0, missed=[];
const $=(sel)=>root.querySelector(sel);
function showFlash(){
const w=data.words[flash % data.words.length];
$(‘.flash-word’).textContent=w[0];
$(‘.flash-roman’).textContent=w[1];
$(‘.flash-meaning’).textContent=’Click “Show Meaning” to check yourself.’;
$(‘.flash-example’).textContent=w[4];
}
function showMeaning(){
const w=data.words[flash % data.words.length];
$(‘.flash-meaning’).textContent=w[2]+’ – ‘+w[3];
}
function nextFlash(){ flash++; showFlash(); }
function makeOptions(answer, source){
const pool=source.filter(v=>v!==answer).sort(()=>Math.random()-0.5).slice(0,3);
return [answer,…pool].sort(()=>Math.random()-0.5);
}
function updateScore(){ $(‘.score’).textContent=score+’ / ‘+total; $(‘.missed’).innerHTML=missed.length?missed.map(m=>’