From a15b6c45eeb471ed4ebba98fb2788f813262854a Mon Sep 17 00:00:00 2001 From: ZiYi <1756318241@qq.com> Date: Tue, 7 Sep 2021 15:26:54 +0800 Subject: [PATCH] fix bugs --- static/js/index.js | 77 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 01451aa..a0324ab 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -2,6 +2,7 @@ $(document).ready(function () { var results = Array(); var ctime; + var flag_again = false; var flag_create = false; var score = 0; var usetime = 0; @@ -25,25 +26,71 @@ $(document).ready(function () { }); $("#create").click(function (e) { e.preventDefault(); - $("#show").hide(); - if (module) { - if (parseFloat(btn.text()) == 0 || btn.text() == "") { - results = []; - score = 0; - usetime = 0; - begin(); - } else { - return; + if (!flag_again) { + flag_again = true; + console.log(flag_again); + if (language == 1 && confirm("答题须知:除法的商请以分数形式输入!示例:1 ÷ 2 = 1/2!")) { + $("#show").hide(); + if (module) { + if (parseFloat(btn.text()) == 0 || btn.text() == "") { + results = []; + score = 0; + usetime = 0; + begin(); + } else { + return; + } + } else { + if (language != -1) { + alert("请先选择出题模式。"); + } else { + alert("Please Choose Module First!"); + } + } + } else if (language == -1 && confirm("Answer note: Please enter the quotient of division as a fraction! Such as: 1 ÷ 2 = 1/2!")) { + + $("#show").hide(); + if (module) { + if (parseFloat(btn.text()) == 0 || btn.text() == "") { + results = []; + score = 0; + usetime = 0; + begin(); + } else { + return; + } + } else { + if (language != -1) { + alert("请先选择出题模式。"); + } else { + alert("Please Choose Module First!"); + } + } } } else { - if (language != -1) { - alert("请先选择出题模式。"); + $("#show").hide(); + if (module) { + if (parseFloat(btn.text()) == 0 || btn.text() == "") { + results = []; + score = 0; + usetime = 0; + begin(); + } else { + return; + } } else { - alert("Please Choose Module First!"); + if (language != -1) { + alert("请先选择出题模式。"); + } else { + alert("Please Choose Module First!"); + } } } - console.log(results); + + + + //console.log(results); }); $("#exchange").change(function (e) { e.preventDefault(); @@ -155,7 +202,9 @@ $(document).ready(function () { var tmp = res[i].result; var reg = /\s+/g; //console.log(typeof tmp + " " + tmp); - tmp = tmp.replace(reg, ""); + if (typeof tmp == "string") { + tmp = tmp.replace(reg, ""); + } //results.push(res[i].result); results.push(tmp); }