|
@@ -25,10 +25,26 @@ var quesData, quesLen = 0,
|
|
|
quesHtml, quesTimer, quesInter, quesCount = quesEnd = 30,
|
|
|
isQuesEnd = false;
|
|
|
|
|
|
+function getQueryString(name) {
|
|
|
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
+ var r = window.location.search.substr(1).match(reg);
|
|
|
+ if (r != null) return unescape(r[2]);
|
|
|
+ return null;
|
|
|
+}
|
|
|
+var uid = getQueryString('uid');
|
|
|
+var uname = getQueryString('uname');
|
|
|
+var round_id = getQueryString('round_id');
|
|
|
var peopleArr = [];
|
|
|
-$.getJSON("question.json", function(res) {
|
|
|
+var questionUrl = "question.json";
|
|
|
+if (round_id == 2) {
|
|
|
+ questionUrl = "question2.json";
|
|
|
+} else if (round_id == 3) {
|
|
|
+ questionUrl = "question3.json";
|
|
|
+}
|
|
|
+$.getJSON(questionUrl, function(res) {
|
|
|
quesData = res.ques;
|
|
|
quesLen = quesData.length;
|
|
|
+ console.log(quesData);
|
|
|
$("#allQues").html(quesLen);
|
|
|
});
|
|
|
var ansArr = ["A", -1, "B"]
|
|
@@ -52,33 +68,24 @@ function preload(imgs, callback) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function getQueryString(name) {
|
|
|
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
|
|
- var r = window.location.search.substr(1).match(reg);
|
|
|
- if (r != null) return unescape(r[2]);
|
|
|
- return null;
|
|
|
-}
|
|
|
-var uid = getQueryString('uid');
|
|
|
-var uname = getQueryString('uname');
|
|
|
-var round_id = getQueryString('round_id');
|
|
|
if (!uid || !uname) {
|
|
|
- // window.location.href = "http://www.100t.com/gjnh/2022.php";
|
|
|
+ window.location.href = "http://www.100t.com/gjnh/2022.php";
|
|
|
} else {
|
|
|
$.post(registUrl, JSON.stringify({
|
|
|
uid,
|
|
|
uname
|
|
|
}), function(res) {})
|
|
|
+
|
|
|
+ preload(["bg.png", "figure.png", "img1.png", "img2.png", "img3.png", "line.png",
|
|
|
+ "qus-top.png",
|
|
|
+ "text-bg.png",
|
|
|
+ "time-box.png", "trap1.png", "trap2.png", "trap3.png", "trap4.png"
|
|
|
+ ], function() {})
|
|
|
waiting(function() {
|
|
|
- preload(["bg.png", "figure.png", "img1.png", "img2.png", "img3.png", "line.png",
|
|
|
- "qus-top.png",
|
|
|
- "text-bg.png",
|
|
|
- "time-box.png", "trap1.png", "trap2.png", "trap3.png", "trap4.png"
|
|
|
- ], function() {
|
|
|
- $load.fadeOut(function() {
|
|
|
- $(this).remove();
|
|
|
- init();
|
|
|
- });
|
|
|
- })
|
|
|
+ $load.fadeOut(function() {
|
|
|
+ $(this).remove();
|
|
|
+ init();
|
|
|
+ });
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -133,6 +140,11 @@ function startQues() {
|
|
|
return false;
|
|
|
}
|
|
|
resetGame();
|
|
|
+ console.log(quesLen);
|
|
|
+ if(!quesLen){
|
|
|
+ alert("题目出现错误");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if (quesLen != 0 && quesFlag < quesLen && !isQuesEnd) {
|
|
|
$num.html(quesFlag + 1);
|
|
|
var ques = quesData[quesFlag];
|
|
@@ -194,7 +206,11 @@ function emptyRow(i) {
|
|
|
}, 2000, "linear", function() {
|
|
|
removePos($(this)).css("left", 40 + "vw");
|
|
|
})
|
|
|
- var rand = Math.floor(Math.random() * 4) + 1;
|
|
|
+ if (i == 1) {
|
|
|
+ var rand = 4;
|
|
|
+ } else {
|
|
|
+ var rand = Math.floor(Math.random() * 3) + 1;
|
|
|
+ }
|
|
|
return '<div class="trap trap' + rand + ' r' + i + '"></div>';
|
|
|
}
|
|
|
|
|
@@ -203,7 +219,7 @@ function resetGame() {
|
|
|
quesCount = quesEnd;
|
|
|
$countDown.html(quesCount);
|
|
|
$trap.html("").hide();
|
|
|
- $("#ansBox .ans").removeClass("active");
|
|
|
+ $("#ansBox .ans").show().removeClass("active");
|
|
|
}
|
|
|
|
|
|
function fail() {
|
|
@@ -211,10 +227,8 @@ function fail() {
|
|
|
}
|
|
|
|
|
|
function success() {
|
|
|
- $fail.remove();
|
|
|
- $endBox.fadeIn(function() {
|
|
|
- $success.show();
|
|
|
- })
|
|
|
+ // window.location.href = "success.html";
|
|
|
+ console.log("success");
|
|
|
}
|
|
|
// 获取随机答案
|
|
|
function getRandAns() {
|
|
@@ -229,7 +243,7 @@ function getRandAns() {
|
|
|
}
|
|
|
var rand = Math.floor(Math.random() * tempPeople.length);
|
|
|
var id = tempPeople.splice(rand, 1)[0];
|
|
|
- delay = Math.floor(Math.random() * 3000) + "ms";
|
|
|
+ delay = Math.floor(Math.random() * 15000) + "ms";
|
|
|
if (id) {
|
|
|
getIn(id, i, j, delay);
|
|
|
} else {
|
|
@@ -269,7 +283,7 @@ $("#ansBox").on("click", ".ans", function() {
|
|
|
var $this = $(this);
|
|
|
var dataId = $this.attr("data-id");
|
|
|
isAns = true;
|
|
|
- $this.addClass("active").siblings().removeClass("active");
|
|
|
+ $this.addClass("active").siblings().fadeOut();
|
|
|
removePos(me.$id).removeAttr("style").addClass("d" + dataId + "-" + 1).addClass("row" + dataId);
|
|
|
me.row = dataId;
|
|
|
var ans = -1,
|
|
@@ -336,14 +350,14 @@ function waiting(callback) {
|
|
|
}
|
|
|
ws.onmessage = function(e) {
|
|
|
var res = JSON.parse(e.data);
|
|
|
- if (res.status == 1 && isWait&& res.game_status == 1) {
|
|
|
+ if (res.status == 1 && isWait && res.game_status == 1) {
|
|
|
window.location.href = "gameready.html";
|
|
|
}
|
|
|
if (res.status == 1 && isWait && res.game_status != 1) {
|
|
|
isWait = false;
|
|
|
callback();
|
|
|
}
|
|
|
- if (res.status == 2 && !isWait && res.game_status == 1) {
|
|
|
+ if (res.status == 2 && !isWait && res.game_status == 1) {
|
|
|
isQuesEnd = true;
|
|
|
clearTimeout(quesTimer);
|
|
|
success();
|