document.addEventListener('DOMContentLoaded', function () { let oneToThree = ["낮", "논", "닭", "땀", "못", "빛", "솥", "짐", "턱", "코", "학", "회", "힘", "털", "칼", "춤", "칡", "죄", "값", "겁", "공", "너", "돌", "롤", "망", "벗", "실", "윷", "중", "초", "칼", "통", "폰", "홀", "검도", "결혼", "녹차", "나비", "행운", "등교", "루비", "만두", "무용", "박사", "보물", "사랑", "수리", "어깨", "역사", "윤곽", "자연", "저축", "졸업", "행복", "공간", "궁궐", "남자", "농심", "동심", "달력", "락스", "라임", "모집", "명동", "바람", "보정", "성종", "식기", "유행", "여우", "종점", "자리", "초코", "추위", "킬러", "콩밥", "틴더", "터널", "필적", "포도", "홍수", "형제", "자긍심", "전염병", "주인공", "칸막이", "친근감", "태양풍", "폐막식", "하반신", "황무지", "횡격막", "경기도", "농산물", "단백질", "대통령", "대장균", "동남아", "무기질", "오렌지", "캥거루", "칼국수", "거제도", "공유기", "네이버", "놀이터", "두리안", "달걀찜", "루시퍼", "롤리팝", "망아지", "메아리", "비비빅", "바밤바", "송중기", "성시경", "우리집", "아버지", "지킴이", "정관장", "청국장", "청록색", "큐피드", "코레일", "탕후루", "탕평책", "피해자", "폴라포", "헤이즈", "하르방"]; let fourToSix = ["어림짐작", "인문과학", "작심삼일", "착시효과", "중구난방", "천재지변", "팔방미인", "포화상태", "하루아침", "해수욕장", "허수아비", "홍익인간", "훈민정음", "거두절미", "대중교통", "두드러기", "만유인력", "물리화학", "가시광선", "고등학교", "가위눌림", "고기국수", "나무위키", "너비아니", "데리야끼", "도리토스", "라면사리", "롯데마트", "마음가짐", "모의재판", "보니하니", "바이올린", "세일즈맨", "삼단화환", "오징어회", "어버이날", "장례식장", "종종걸음", "초코머핀", "총알받이", "키득키득", "카이스트", "텔레토비", "토카토카", "피실험자", "페퍼로니", "호랑이굴", "하이마트", "우스갯소리", "청딱따구리", "크리스마스", "아르헨티나", "헌법재판소", "황소개구리", "게으름뱅이", "이데올로기", "순두부찌개", "대중목욕탕", "동음이의어", "프로그래밍", "정월대보름", "식기세척기", "지구온난화", "아이스크림", "오케스트라", "김치볶음밥", "최소공배수", "장수풍댕이", "괭이갈매기", "거짓말쟁이", "나이지리아", "나이팅게일", "담쟁이덩굴", "뒤치닥거리", "라티푼디움", "룩셈부르크", "막대그래프", "뮤직비디오", "바빌로니아", "바다코끼리", "산후조리원", "삼강행실도", "오므라이스", "오리온자리", "중모리장단", "증조할머니", "초코바나나", "초조대장경", "카트라이더", "카자흐스탄", "토이스토리", "타임스퀘어", "폴리에틸렌", "페이퍼타올", "하늘바라기", "하룻강아지", "어중이떠중이", "자이로스코프", "진인사대천명", "한해살이식물", "목도리도마뱀", "패러글라이딩", "자유의여신상", "콘트라베이스", "베이킹파우더", "에스컬레이터", "장대높이뛰기", "히말라야산맥", "나무아미타불", "스카치테이프", "아르키메데스", "조선왕조실록", "증조할아버지", "가시불가사리", "금메달리스트", "폭탄먼지벌레", "가슴지느러미", "가운뎃발가락", "고구마잎벌레", "고리대금업자", "네안데르탈인", "뉴펀들랜드주", "덩굴무늬매듭", "덧치마저고리", "라스베이거스", "라이스페이퍼", "마다가스카르", "마이크로미터", "빨강불가사리", "브레인스토밍", "상정고금예문", "샌프란시스코", "아메리칸드림", "알렉산드리아", "작은할아버지", "전민변정도감", "청분홍메뚜기", "콤팩트디스크", "코니아일랜드", "타이포그래피", "트리케라톱스", "파운드케이크", "프랑켄슈타인", "피보나치수열"]; let words = []; let currentIndex = 0; let onecurrentIndex = 0; let fourcurrentIndex = 0; let wordsNumber = 10; let curEnd = 0; let testType = []; let curTest = 0; // 사이트 로드시 리스트 섞기 oneToThree = oneToThree.sort(() => Math.random() - 0.5); fourToSix = fourToSix.sort(() => Math.random() - 0.5); console.log('Mixed') console.log(oneToThree); console.log(fourToSix); const wordDisplay = document.getElementById('Word'); const startButton = document.getElementById('start'); startButton.addEventListener('click', () => { for (i of document.getElementById('TypeList').value.split(' ')) { let curType = []; if (i.charAt(0) === 'A') { curType.push(13) } else { curType.push(46) } if (i.charAt(1) === 'C') { curType.push(2000) } else { curType.push(3000) } if (i.charAt(2) === 'E') { curType.push(10) } else { curType.push(20) } testType.push(curType); } document.getElementById('settings').style.display = 'none'; newTest() }); const newTest = () => { if (testType[curTest][0] === 13) { words = oneToThree; curEnd = onecurrentIndex + testType[curTest][2]; currentIndex = onecurrentIndex; } else { words = fourToSix; curEnd = fourcurrentIndex + testType[curTest][2]; currentIndex = fourcurrentIndex; } document.getElementById('wordNumberValue').textContent = `${testType[curTest][2]}개의 ${(testType[curTest][0] === 13) ? '짧은' : '긴'} 무작위 단어들이 제시됩니다.`; document.getElementById('intervalValue').textContent = `단어당 제시되는 시간은 ${testType[curTest][1] / 1000}초이며 후에 1초의 공백이 표시됩니다.`; document.getElementById('Word').style.display = 'none'; document.getElementById('Intro').style.display = 'block'; wordDisplay.style.color = '#000000'; } document.addEventListener('keydown', function (event) { if (event.code === 'Space') { test() document.getElementById('Intro').style.display = 'none'; document.getElementById('Word').style.display = 'block'; console.log(words.slice(currentIndex, curEnd)); sendDataToServer(document.getElementById('TypeList').value.split(' ')[currentIndex], words.slice(currentIndex, curEnd)); } }); const test = () => { if (currentIndex == curEnd) { wordDisplay.textContent = 'Finish'; wordDisplay.style.color = '#D1080B'; if (testType[curTest][0] === 13) { onecurrentIndex = currentIndex; } else { fourcurrentIndex = currentIndex; } if (curTest < 7) { setTimeout(() => { curTest += 1; newTest() }, 5000) } return } wordDisplay.textContent = words[currentIndex]; setTimeout(() => { wordDisplay.textContent = ''; setTimeout(() => { currentIndex += 1; test(); }, 1000) }, testType[curTest][1]) }; }); function sendDataToServer(ty ,li) { console.log(JSON.stringify({ list: li })) fetch('/your-endpoint', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ type: ty, list: li }) }) .then(response => response.json()) .then(data => console.log('Success:', data)) .catch((error) => console.error('Error:', error)); }