!function() { "use strict"; function a(a) { function b() { ma = $("#Correct"), na = $("#Wrong"), oa = $("#TooLate"), ya.on("vclick", L), a.find(".finishButton").on("vclick", T); } function c(a, b) { a.domain = 1; a.speed = ""; a.touch = "click"; a.count = ""; return Da = !0, aa = b, $("#akriddle-game").addClass(ea[Math.floor(Math.random() * ea.length)]), $("#QuestAnimation").show(), v(), b ? (d.on("multiPlayer", n), d.connect(), $("#multi-message").show(), void d.getSettings(function(a, b) { m(a, b); })) : (Ia = [], V = 0, Y = 0, ca = a.speed, da = a.touch, Z = a.count, fa = a.domain, _ = a, "max20" === Z ? ga = 20 : "max10" === Z && (ga = 10), $(document).off("keypress").on("keypress", J), $(document).off("keydown").on("keydown", I), void k(h)); } function h() { g && console.log("running with questions", ha), (-1 === ga || ga > ha.length) && (ga = ha.length), ha.forEach(function(a) { a.time.veryslow = 2 * a.time.slow; }); var a = $.now() + 9100; x(a, w.bind(null, 0)); } function i(a, b) { g && console.log("loading js", a); var c = document.getElementsByTagName("head")[0], d = document.createElement("script"); $(d).load(function() { g && console.log("loaded questions", topicQuestions), ha = topicQuestions, b(); }), d.type = "text/javascript", d.src = a + "/quests.js", c.appendChild(d); } function j(a, b) { g && console.log("loading js", a), a = a.substr(0, a.length - 5), dataManager.getJSON(a, function(a, c) { return a ? console.error(a) : (ha = c.questions, void b()); }); } function k(a) { function b(a) { var b = []; return a.forEach(function(a) { b.push(a.data); }), g && console.log("received questions from server:", a), b; } if (Ba = null, window.MasterCom) window.serverCom.hasQuestionList(f, function(c, d) { var e = d.settings; return !c && e ? ("speed" in e && (_.speed = ca = e.speed), "touch" in e && (_.touch = da = e.touch), "count" in e && (_.count = Z = e.count), void window.MasterCom.getQuestionlist(f, function(c, d) { g && console.log("received question list", d), Ba = d.id, ha = b(d.list), ga = -1, a(); })) : void window.serverCom.getQuestions(f, fa, function(c, d) { ha = TOOLS.SHUFFLE(b(d)), a(); }); }); else { var c = e[fa].path, d = c.split("."); "json" === d[d.length - 1] ? j(c, a) : i(c, a); } } function l() { $.each(Ea, function(a, b) { b.stop(); }), Ha && (clearInterval(Ha), Ha = null), Ga && (clearInterval(Ga), Ga = null), Fa && (clearInterval(Fa), Fa = null); } function m(a, b) { ca = "normal", da = "time", !a && b.speed && (ca = b.speed); } function n(a) { g && console.log("processing", a); var b = { startGame: t, start: w, question: r, stop: s, prepareStart: o, init: s, results: A }; return b[a] ? void b[a].apply(null, $.makeArray(arguments).slice(1)) : void console.error("unknown tag:", a); } function o(a) { x(a), Ca = !0; } function p(a) { if (a.imageData) return "data:image/png;base64," + a.imageData; var b = void 0 !== a.topic ? a.topic : fa, c = a.image; return c.length < 5 ? "gfx/akriddle/question3.png" : a.imagepath ? a.imagepath + c : e[b].path + "/images/" + c; } function q(a) { var b = new Image(); $(b).addClass("qimage"), b.onerror = function() { b.src = "gfx/akriddle/question3.png"; }, b.src = p(ha[a]), Ia[a] = b; } function r(a, b, c) { g && console.log("adding question ", a, "of", c, ":", b), ha[a] = b, ga = c, q(a); } function s() { Da = !1, Ca = !1, v(), $("#QuestAnimation").fadeIn(), $("#message-starting").hide(), $("#message-waiting").show(); } function t(a) { Ia = [], Da = !0, ia = a, d.getSettings(function(a, b) { g && console.log("received settongs:", a, b), m(a, b); }), g && console.log("starting with", a), v(), $("#message-waiting").hide(), $("#message-starting").show().find(".number").text(a + 1); } function u(a, b, c) { c || (c = !1), d.processResult({ points: a, correct: b, timeout: c, number: ia }, V), ia === ga - 1 && (Fa = setTimeout(A, 3e3), Ca = !1); } function v() { $(document).off("keypress", J), $(document).off("keydown", I), l(), V = 0, ba.forEach(function(a) { a.points = 0; }), F(-1), Y = 0, ua.hide(), ra.hide(), Aa.hide(), va.hide(), $("#StartCounter").hide(), $(".app").show(); } function w(a) { $("#QuestAnimation").hide(), $("#StartCounter").fadeOut(), ua.show(), ra.show(), qa.show(), pa.show(), z(qa), G(a); } var waitStart; var dtCountdownFinish; var countdownB; function updateContdown(a) { var b = a - 2; 1 === a && (b = "Go!!"), $("#StartCounter").find(".item").text(b); } var isGameStarted = false; function checkStart() { $.ajax({ dataType: "json", url: "multiplayer//status.json", async: true, cache: false, success: function(jsonStatus) { if (jsonStatus.isStarted) { isGameStarted = true; clearInterval(waitStart); dtCountdownFinish = $.now() + 9100; Ea.push(new CountDown(dtCountdownFinish, updateContdown, { "final": countdownB })); } } }); } function x(a, b) { g && console.log("include sound"), $("#QuestAnimation").fadeOut(), $("#StartCounter").fadeIn().find(".item").text("").end(); loadPoints(0,0); $("#StartCounter").fadeIn().find(".item").text("Warte auf das Startsignal"); countdownB = b; $.ajax({ dataType: "json", url: "multiplayer//status.json", async: false, cache: false, success: function(jsonStatus) { if (jsonStatus.isStarted) { isGameStarted = true; } } }); if (isGameStarted) { $("#StartCounter").fadeIn().find(".item").text("Spiel läuft - Teilnahme nicht mehr möglich!"); } else { waitStart = setInterval(checkStart, 300); } } function y(a, b) { var c = {}; $.extend(c, b); var d = $(a), e = d.attr("data-scroller-id"); e ? Ja[e].destroy() : (e = "" + Ka++, d.attr("data-scroller-id", e)); var f = new MyScroll(a, c); return Ja[e] = f, f; } function z(a, b) { function c(c) { c.sort(function(a, b) { return b.points - a.points; }); for (var d = "", e = 1, f = null, g = 0; g < c.length; g++) { var h = g + 1; c[g].points === f && (h = e), e = h, f = c[g].points; var i = ""; c[g].self && (i = 'class="self"', 1 === h && b && SOUND.play("win")), d = d + ""; } a.html(d + "
" + h + "" + c[g].player + "" + c[g].points + "
"); var j = y(a[0], { scrollShadow: !1 }); setTimeout(function() { j.refresh(); var b = a.find("tr.self"); b.length && j.scrollToElement(b[0]); }, 50); } if (aa) d.getResults(function(a, b) { var d = MasterCom.getUser(); $.each(b, function(a, b) { return b.player === d ? (b.self = !0, !1) : !0; }), c(b); }); else { var e; ba = loadPoints(V,intQuestion); waitForCountdown(); e = ba.slice(), c(e); } } var intQuestionCounterTime = 3; function showQuestionCounter(intTime) { $("#QuestionCounter").find(".item").text(intTime) $("#QuestionCounter").fadeIn(); function countertextHandle() { intQuestionCounterTime = intQuestionCounterTime - 1; var b = intQuestionCounterTime; 0 === intQuestionCounterTime && (b = "Go!!"), $("#QuestionCounter").find(".item").text(b); if (intQuestionCounterTime > 0) { setTimeout(countertextHandle, 1e3); } } intQuestionCounterTime = intTime; setTimeout(countertextHandle, 1e3); } function hideQuestionCounter() { $("#QuestionCounter").fadeOut(); console.log("hide Counter"); } function A() { Da = !1, l(), pa.hide(), va.fadeOut(), ua.hide(), ra.hide(), ga / 2 > Y ? (Aa.find(".img-win").hide(), Aa.find(".img-loose").show()) : (Aa.find(".img-win").show(), Aa.find(".img-loose").hide()), Aa.show().find(".text").html("Richtig: " + Y + " von " + ga), aa || (ga / 2 > Y ? SOUND.play("loose") : SOUND.play("win"), SCORE.submit(f, settingsControl.scoreMode(f, _), { points: V, grade: SCORE.MARKNUMERIC(Y, ga), right: Y, total: ga }, Ba, $.noop)), setTimeout(function() { z(Aa.find(".stat-box"), !!aa); }, 200)/*, setTimeout(function() { pageControl.changePage("highscore.php"); }, 5e3)*/, ia = null; } function B() { switch (pa.removeClass("vibrate"), da) { case "click": null === ja ? P() : R(); //P(); break; case "time": null === ja ? P() : R(); } H(); } function C(a) { function b() { SOUND.play("ring"), pa.addClass("vibrate"), Ha = setTimeout(B, a - $.now()); } Ha = setTimeout(b, a - $.now() - 1e3); } function D(a) { function b() { var a = f * (e + 1) - ($.now() - d); Ga = setTimeout(c, a); } function c() { if (X = a - $.now(), f === ta.length || !U) return void (Ga = clearInterval(Ga)); ta.eq(f).parent().addClass("active"); var c = [ 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4 ]; if (f < c.length && SOUND.play("time", "time" + c[f]), U.advices) { var d = { 5: 0, 8: 1, 11: 2 }; f in d && U.advices[d[f]] && $(".p" + (d[f] + 1)).html(U.advices[d[f]].text); } f += 1, b(); } var d = $.now(), e = (a - $.now()) / (ka + 1), f = 0; b(); } function E(a) { la.css({ backgroundImage: "url(" + a + ")" }); } function F(a) { var strKonto = (boolaPoints[intQNr] ? intaPoints[intQNr] : V); $(".p1").html(""), $(".p2").html(""), $(".p3").html(""), xa.html(""), 0 > a ? wa.html("") : (a >= ga ? wa.html("Ende!") : wa.html("Frage " + (a + 1) + " von " + ga), xa.html("Konto: " + strKonto)), ja = null, za.html(""), E("gfx/akriddle/question3.png"), $(".variant").removeClass("active"), pa.removeClass("vibrate"), l(), ta.each(function(a, b) { $(b).parent().removeClass("active"); }); } var intQuestion = 1; function G(b) { if (0 === b && SOUND.play("gong"), F(b), g && console.log("RUN QUESTION: " + b), intQuestion = b+1, ia = b, U = ha[ia], b >= ga) return void (aa || A()); if (za.html(U.text), Ia[b]) E(Ia[b].src); else { var c = p(U); E(c); } for (var d = [ "A", "B", "C", "D", "E" ], e = a.find(".variantRow").hide(), f = 0; f < U.variants.length; f++) { var h = U.variants[f].text; h && "-" !== h && (e.filter(":nth-child(" + (f + 1) + ")").show(), a.find(".topic_" + (f + 1)).html(d[f]), a.find(".topic_txt_" + (f + 1)).html(U.variants[f].text)); } U.correctVariant = d[U.answerId - 1], va.hide(); var i = U.time[ca]; g && console.log("time limit:", U.time[ca]); var j = $.now() + 1e3 * i; g && console.log("remaining time", 1e3 * i, ca, U.time); var k = U.points / ta.length; ta.each(function(a, b) { $(b).parent().removeClass("active"), $(b).html(Math.round(U.points - a * k)); }), C(j), D(j); var l = y(a.find(".smallLayout")[0]); l.scrollTo(0, 0), setTimeout(function() { l.refresh(); }, 50); } function H() { showQuestionCounter(3); aa || setTimeout(function() { hideQuestionCounter(); w(ia + 1); }, 3e3); } function I(a) { 8 === a.which && (a.preventDefault(), a.stopPropagation()); } function J(a) { a.stopPropagation(), a.preventDefault(); var b = String.fromCharCode(a.which).toUpperCase(), c = "ABCDE".indexOf(b) + 1; 0 >= c || c > U.variants.length || K(c); } function K(a) { if (a !== ja) switch (ja = a, SOUND.play("select"), W = X, da) { case "click": R();//, H(); break; case "time": $(".variant").removeClass("active"), ya.filter("[data-id=" + a + "]").find(".variant").addClass("active"); break; } } function L() { var a = $(this); K(parseInt(a.attr("data-id"))); } function M(a, b, c) { var strKonto = (boolaPoints[intQNr] ? intaPoints[intQNr] : V); if (V += a, pa.removeClass("vibrate"), xa.html("Konto: " + strKonto), aa) u(a, b, c); else for (var d = 0; d < ba.length; d++) { var e = ba[d]; /* if (e.self) { e.points = V; } else { var g = Math.round(U.points * Math.random()); g = Math.random() < e.iq ? g : -g, e.points += g; } */ } var h = "correct"; b || (h = c ? "timeout" : "wrong"), SCORE.addQuestionResult(f, Ba, { res: h, points: a }); } function N(a) { var b = aa ? 1e3 : 0; setTimeout(function() { z(a); }, b); } function O() { SOUND.play("correct"); if (!boolaAnswered[intQNr]) { Y++; boolaAnswered[intQNr] = true; } var a = Math.round(U.points / U.time[ca] * W / 1e3); g && console.log(U.points, U.time[ca], W), M(a, !0), ma.find(".message").html('' + a + " Punkte"), N(ma.find(".stat-box")), ma.fadeIn(), ua.hide(), ra.hide(); } function P() { SOUND.play("wrong"); var a = -500; oa.find(".message").html('-500 Punkte
Richtig: ' + U.correctVariant + ": " + U.variants[U.answerId - 1].text), M(a, !1, !0), N(oa.find(".stat-box")), oa.fadeIn(), ua.hide(), ra.hide(); } function Q() { SOUND.play("wrong"); var a = -Math.round(U.points / U.time[ca] * W / 1e3), b = "" + a + " Punkte
Richtig: " + U.correctVariant + ": " + U.variants[U.answerId - 1].text; na.find(".message").html(b), M(a, !1), N(na.find(".stat-box")), na.fadeIn(), ua.hide(), ra.hide(); } function R() { //Ha && clearInterval(Ha), Ga && clearInterval(Ga); var a = ja === U.answerId; a ? O() : Q(); } function S() { d && (d.off("multiPlayer", n), d.disconnect()), v(); } function T() { Da && A(); } function waitForCountdown() { return true; } function loadPoints(intMyPoints,intQuestionNr) { intQNr = intQuestionNr; if (intQuestionNr > 1 || (intQuestionNr == 1 && intMyPoints != 0)) { if (!boolaPoints[intQuestionNr]) { intaPoints[intQuestionNr] = intMyPoints; boolaPoints[intQuestionNr] = true; } else { V = intaPoints[intQuestionNr]; } } var intPoints = V; var url = "pointsupdate.php?user=&group=&points=" + intPoints+"&question=" + intQNr; var pointdata = []; $.ajax({ dataType: "json", url: url, dataType: "text", async: false, success: function(data) { pointdata = JSON.parse(data); } }); return pointdata; } var U, V, W, X, Y, Z, _, aa, ba = [], ca = "normal", da = "click", ea = [ "page-bg0", "page-bg1", "page-bg2", "page-bg3", "page-bg4", "page-bg5", "page-bg6", "page-bg7", "page-bg8", "page-bg9" ], fa = -1, ga = 20, ha = [], ia = null, ja = null, ka = 15, la = a.find(".PictureBox"), ma = null, na = null, oa = null, pa = a.find(".clock"), qa = a.find(".game-stat-box"), ra = a.find(".progressBarHolder"), sa = $("#ProgressBar"), ta = sa.find(".item"), ua = a.find(".game"), va = $("#Correct, #Wrong, #TooLate"), wa = a.find(".labStatusLeft .questionNo"), xa = a.find(".labStatusLeft .points"), ya = a.find(".variantRow"), za = a.find(".question"), Aa = a.find(".stats"), Ba = null, Ca = !1, Da = !1, Ea = [], Fa = null, Ga = 0, Ha = 0, Ia = [], Ja = {}, Ka = 1; this.abort = T, this.init = b, this.start = c, this.stop = S; } var intaPoints = [0]; var intQNr = 1; var boolaPoints = [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]; var boolaAnswered = [false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]; function b() { var a = $("#kataloge"); $.each(e, function(b, c) { try { if (getFragenkatalogId(c.title)==strFragenkatalogId){ a.append($("