{"version":3,"file":"random_examdk-C_WE1f-_.js","sources":["../../../app/frontend/entrypoints/random_examdk.js"],"sourcesContent":["window.addEventListener('DOMContentLoaded', () => {\n const randoms = idr.value.split('[\"');\n const random = randoms[1].split('\"]');\n const randomUrl = random[0].split('\", \"');\n if (idu.value === randomUrl[0]) {\n const cookies = document.cookie;\n const cookiesArray = cookies.split('; ');\n let deleteFlag = false;\n for (var c of cookiesArray) {\n var cArray = c.split('=');// 名前とvalueの分解\n\n // 前方一致の処理\n if (cArray[0].indexOf('random1') === 0) {\n const cookieUrl = cArray[0].split('-');\n if (cookieUrl[1] !== idu.value) {\n deleteFlag = true;\n }\n }\n }\n if (deleteFlag) {\n for (var c of cookiesArray) {\n var cArray = c.split('=');// 名前とvalueの分解\n\n // 前方一致の処理\n if (cArray[0].indexOf('random') === 0) {\n document.cookie = `${cArray[0]}=;max-age=0`;\n }\n }\n }\n }\n\n randomPagemove();\n randomCookie();\n\n // `解答する`ボタン押下によるアクション\n document.getElementById('answer_button').onclick = () => {\n const radioElements = document.getElementsByName('radio');\n const unselectedElement = document.getElementById('misentaku');\n\n let selectedValue = 0;\n for (let i = 0; i < radioElements.length; i += 1) {\n if (radioElements[i].checked) {\n selectedValue = radioElements[i].value;\n break;\n }\n }\n\n // 未選択時はここで終了\n if (selectedValue === 0) {\n unselectedElement.innerHTML = '選択されていません';\n return;\n }\n\n unselectedElement.innerHTML = '';\n\n const answerHiddenInputValue = document.getElementById('ida').value;\n const correctElement = document.getElementById('correct');\n const incorrectElement = document.getElementById('incorrect');\n const answerButtonElement = document.getElementById('button_kotae');\n let cookieValue;\n\n if (selectedValue === answerHiddenInputValue) {\n correctElement.innerHTML = '正解';\n incorrectElement.innerHTML = '';\n answerButtonElement.style.display = 'none';\n const answerElement = document.getElementById('answer');\n answerElement.innerHTML = '';\n cookieValue = 0;\n } else if (selectedValue !== 0) {\n correctElement.innerHTML = '';\n incorrectElement.innerHTML = '不正解';\n answerButtonElement.style.display = 'inline-block';\n cookieValue = 1;\n }\n saveRandomCookie(cookieValue);\n\n // 解説を表示\n const jsExplanation = document.querySelector('.js-exam-explanation');\n if (jsExplanation) {\n jsExplanation.classList.remove('-display-none');\n }\n };\n\n function saveRandomCookie(value) {\n const randoms = idr.value.split('[\"');\n const random = randoms[1].split('\"]');\n const randomUrl = random[0].split('\", \"');\n const number = Number(idn.value) + 1;\n let name;\n\n if (idu.value === randomUrl[number - 1]) {\n if (number === 1) {\n name = `random${number}-${randomUrl[0]}`;\n } else {\n name = `random${number}`;\n }\n }\n\n const period = 1; // 有効期限日数(有効期限がないと、ブラウザを閉じた時点で cookieは無効)\n const nowtime = new Date().getTime();\n const clearTime = new Date(nowtime + (60 * 60 * 24 * 1000 * period));\n const expires = clearTime.toGMTString();// クッキーの発行(書き込み)\n const cookies = document.cookie;\n const cookiesArray = cookies.split('; ');\n let flag = true;\n for (const c of cookiesArray) {\n const cArray = c.split('=');// 名前とvalueの分解\n if (cArray[0] === name) {\n flag = false;\n break;\n }\n }\n if (flag) {\n document.cookie = `${name}=${escape(value)}; expires=${expires}`;\n randomCookie();\n }\n }\n\n // `答えをみる`ボタン押下によるアクション\n document.getElementById('button_kotae').onclick = () => {\n // 答えを表示\n const answerHiddenInputValue = document.getElementById('ido').value;\n const answerElm = document.getElementById('answer');\n answerElm.innerHTML = answerHiddenInputValue;\n };\n\n function randomPagemove() {\n const number = idn.value;\n if (number >= 1) {\n document.getElementById('button_prev').style.visibility = 'visible';\n } else {\n document.getElementById('button_prev').style.visibility = 'hidden';\n }\n if (number < 9) {\n document.getElementById('button_next').style.visibility = 'visible';\n } else {\n document.getElementById('button_next').style.visibility = 'hidden';\n }\n }\n\n function randomCookie() {\n const cookies = document.cookie;\n const cookiesArray = cookies.split('; ');\n\n let total = 0.0;\n let corTotal = 0.0;\n const corArray = [];\n\n for (const c of cookiesArray) {\n const cArray = c.split('=');// 名前とvalueの分解\n\n for (let t = 1; t <= 10; t += 1) {\n if (t === 1) {\n var name = `random${t}-${randomUrl[0]}`;\n } else {\n var name = `random${t}`;\n }\n if (cArray[0] === name) {\n total += 1;\n if (cArray[1] === '0') {\n corTotal += 1;\n corArray[t] = 0;\n } else {\n corArray[t] = 1;\n }\n }\n }\n }\n if (total === 0) {\n const target = document.getElementById('percent');\n target.innerHTML = 0;\n } else if (total > 0) {\n let percent = (corTotal * 100) / total;\n percent = percent.toFixed();\n const target = document.getElementById('percent');\n target.innerHTML = percent;\n if (total >= 10) {\n const buttonTonext = document.getElementById('button_tonext');\n buttonTonext.style.display = 'inline-block';\n }\n }\n let target = document.getElementById('total');\n target.innerHTML = total;\n target = document.getElementById('cor_total');\n target.innerHTML = corTotal;\n\n for (let i = 1; i <= 10; i += 1) {\n target = document.getElementById(`judg${String(i)}`);\n if (corArray[i] === 0) {\n target.innerHTML = '〇';\n } else if (corArray[i] === 1) {\n target.innerHTML = '×';\n } else {\n target.innerHTML = '―';\n }\n }\n }\n});\n"],"names":["randomUrl","cookiesArray","deleteFlag","c","cArray","randomPagemove","randomCookie","radioElements","unselectedElement","selectedValue","i","answerHiddenInputValue","correctElement","incorrectElement","answerButtonElement","cookieValue","answerElement","saveRandomCookie","jsExplanation","value","number","name","period","nowtime","expires","flag","answerElm","total","corTotal","corArray","target","percent","buttonTonext"],"mappings":"AAAA,OAAO,iBAAiB,mBAAoB,IAAM,CAGhD,MAAMA,EAFU,IAAI,MAAM,MAAM,IAAI,EACb,CAAC,EAAE,MAAM,IAAI,EACX,CAAC,EAAE,MAAM,MAAM,EACxC,GAAI,IAAI,QAAUA,EAAU,CAAC,EAAG,CAE9B,MAAMC,EADU,SAAS,OACI,MAAM,IAAI,EACvC,IAAIC,EAAa,GACjB,QAASC,KAAKF,EAAc,CAC1B,IAAIG,EAASD,EAAE,MAAM,GAAG,EAGpBC,EAAO,CAAC,EAAE,QAAQ,SAAS,IAAM,GACjBA,EAAO,CAAC,EAAE,MAAM,GAAG,EACvB,CAAC,IAAM,IAAI,QACvBF,EAAa,GAGlB,CACD,GAAIA,EAC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