Merge branch 'pr3'
This commit is contained in:
commit
2fa4648f8a
@ -23,18 +23,24 @@
|
||||
<hr id="DHR" style="margin:0px; width:100%; position:relative; top:3px; border-top:1px solid black;">
|
||||
</div>
|
||||
<div class="bgColor textColor mainHight" style="display:none; position:relative; width: 1000px; margin: auto;" id="display">
|
||||
<img id="schweinchenImg" style="margin-left: 200px; margin-top: 70px;" src="./img/schweinchen.jpg">
|
||||
<img id="schweinchenImg" style="margin-left: 200px; margin-top: 70px; display: none;" src="./img/schweinchen.jpg">
|
||||
<img id="schweinchen1Img" style="margin-left: 200px; margin-top: 70px; display: none;" src="./img/schweinchen1.jpg">
|
||||
<img id="schweinchen2Img" style="margin-left: 200px; margin-top: 70px; display: none;" src="./img/schweinchen2.jpg">
|
||||
<div id="displayQuestions" class="textColor">
|
||||
</div>
|
||||
<div id="answers">
|
||||
|
||||
</div>
|
||||
<div class="noIntro" id="result" style="position:absolute; bottom:115px; right:38px; font-size: 1.5em;">
|
||||
<div style="float:left; padding-right: 20px;">SUMME</div>
|
||||
<div style="float:left; padding-right: 20px;" class="header_summe">SUMME</div>
|
||||
<div style="float:left; font-size: 0.8em; position: relative; top: 12; left:14px; color: red; cursor:pointer;" class="controller" id="pointsToTheLeft"><i class="fa fa-chevron-left"></i></div>
|
||||
<div class="noIntro" style="width:50px; float: left; text-align:right;" id="SumRes">0</div>
|
||||
<div style="float:left; font-size: 0.8em; position: relative; top: 12; color: red; cursor:pointer;" class="controller" id="pointsToTheRight"><i class="fa fa-chevron-right"></i></div>
|
||||
</div>
|
||||
<div class="noIntro" id="resultFinal" style="position:absolute; bottom:115px; right:465px; font-size: 1.5em; display: none;">
|
||||
<div class="noIntro" style="width:50px; float: left; text-align:right;" id="SumRes_player1"></div>
|
||||
<div class="noIntro" style="width:50px; float: left; text-align:right;" id="SumRes_player2"></div>
|
||||
</div>
|
||||
<div class="noIntro footer" id="footer1" style="position:absolute; bottom:50px; width:100%; height:50px; font-size: 2em;">
|
||||
<div style="position:absolute; left:5px; top: -5px;" class="pointsLeft">0</div>
|
||||
<div style="position:absolute; right:5px; top: -5px;" class="pointsRight">0</div>
|
||||
@ -64,10 +70,10 @@
|
||||
<td><b>Global</b></td>
|
||||
<td><b>Server</b></td>
|
||||
<td><b>Intro</b></td>
|
||||
<td><b>Jeopardy</b></td>
|
||||
<td><b>Schweinchen</b></td>
|
||||
<td><b>Clear Fails</b></td>
|
||||
<td><b>Punkte</b></td>
|
||||
<td><b>Finalmodus</b> <input id="modeFinal" type="checkbox"> <button style="float:right;" id="finalmodusInfoBtn">Info</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><img id="toggleSoundImg" style="cursor:pointer;" width="35px;" src="./img/soundOn.png"></td>
|
||||
@ -81,14 +87,9 @@
|
||||
Blackscreen: <input id="blackScreenCheck" checked="checked" type="checkbox">
|
||||
</td>
|
||||
<td>
|
||||
<button id="startJeopardybtn"><i class="fa fa-play"></i> Jeopardy</button><br>
|
||||
<button id="stopJeopardybtn"><i class="fa fa-stop"></i> Jeopardy</button><br>
|
||||
<img width="20px;" src="./img/noSound.png">
|
||||
<input id="jeopardyVolume" style="width: 50px;" type="range" value="10" name="points" min="0" max="10">
|
||||
<img width="20px;" src="./img/soundOn.png">
|
||||
</td>
|
||||
<td>
|
||||
<button id="startScheinchenbtn"><i class="fa fa-play"></i> Schweinchen</button><br>
|
||||
<button id="startScheinchenbtn" value="1"><i class="fa fa-play"></i> Schweinchen</button><br>
|
||||
<button id="startScheinchenbtn2" value="2"><i class="fa fa-play"></i> Schweinchen (2x)</button><br>
|
||||
<button id="startScheinchenbtn3" value="3"><i class="fa fa-play"></i> Schweinchen (3x)</button><br>
|
||||
<button id="stopScheinchenbtn"><i class="fa fa-stop"></i> Schweinchen</button><br>
|
||||
<img width="20px;" src="./img/noSound.png">
|
||||
<input id="schweinchenVolume" style="width: 50px;" type="range" value="10" name="points" min="0" max="10">
|
||||
@ -107,6 +108,24 @@
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<button id="startAnswerFailBtn"><i class="fa fa-play"></i> Antwort falsch</button><br>
|
||||
<img width="20px;" src="./img/noSound.png">
|
||||
<input id="answerFailVolume" style="width: 50px;" type="range" value="10" name="points" min="0" max="10">
|
||||
<img width="20px;" src="./img/soundOn.png">
|
||||
<div>
|
||||
<lable>Spieler 1: <input class="playerTgl finalElement" disabled="true" checked="true" type="radio" value="1" name="fmod"></lable><br>
|
||||
<lable>Spieler 2: <input class="playerTgl finalElement" disabled="true" type="radio" value="2" name="fmod"></lable><br>
|
||||
Frage: <select class="finalElement" disabled="true" id="finalFragenSelect">
|
||||
<option value="0"> 1</option>
|
||||
<option value="1"> 2</option>
|
||||
<option value="2"> 3</option>
|
||||
<option value="3"> 4</option>
|
||||
<option value="4"> 5</option>
|
||||
</select><br>
|
||||
Alternative Antwort (0 Punkte):<br> <input class="finalElement" id="alternateAnswer" maxlength="20" disabled="true" type="text" name=""><button class="finalElement" id="alternateAnswerBtn" disabled="true">Setzten</button><button class="finalElement" id="alternateAnswerPBtn" disabled="true">0</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
|
BIN
web/img/schweinchen1.jpg
Executable file
BIN
web/img/schweinchen1.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
web/img/schweinchen2.jpg
Executable file
BIN
web/img/schweinchen2.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
209
web/js/main.js
209
web/js/main.js
@ -1,9 +1,9 @@
|
||||
var fragen = null;
|
||||
var intro = null;
|
||||
var introVolume = 1;
|
||||
var jeopardy = null;
|
||||
var answerFail = null;
|
||||
var schweinchenVolume = 1;
|
||||
var jeopardyVolume = 1;
|
||||
var answerFailVolume = 1;
|
||||
var schweinchen = null;
|
||||
|
||||
$(document).ready(function() {
|
||||
@ -23,28 +23,39 @@ $(document).ready(function() {
|
||||
wsSend("toggleBlackScreen", "");
|
||||
});
|
||||
|
||||
$("#startJeopardybtn").click(function() {
|
||||
$("#startJeopardybtn").attr("disabled", "disabled");
|
||||
wsSend("startJeopardy", "");
|
||||
$("#modeFinal").change(function() {
|
||||
var status = $('#modeFinal').is(':checked');
|
||||
wsSend("toggleFinalMode", status);
|
||||
});
|
||||
|
||||
$("#stopJeopardybtn").click(function() {
|
||||
$("#startJeopardybtn").removeAttr("disabled");
|
||||
wsSend("stopJeopardy", "");
|
||||
$(".playerTgl").change(function() {
|
||||
var player = $(this).val() == 1 ? false : true;
|
||||
wsSend("setPlayer2ForFinalMode", player);
|
||||
});
|
||||
|
||||
$("#jeopardyVolume").on("input", function() {
|
||||
$("#startAnswerFailBtn").click(function() {
|
||||
wsSend("startAnswerFail", "");
|
||||
});
|
||||
|
||||
$("#answerFailVolume").on("input", function() {
|
||||
var v = parseFloat($(this).val()) / 10;
|
||||
wsSend("setJeopardyVolume", v);
|
||||
wsSend("setAnswerFailVolume", v);
|
||||
});
|
||||
|
||||
$("#startScheinchenbtn").click(function() {
|
||||
$("#startScheinchenbtn").attr("disabled", "disabled");
|
||||
$("button[id^='startScheinchenbtn']").each(function(){
|
||||
$(this).click(function() {
|
||||
var status = $(this).attr('value');
|
||||
console.log('status' + status);
|
||||
wsSend("setRunde", status);
|
||||
$(this).attr("disabled", "disabled");
|
||||
wsSend("startSchweinchen", "");
|
||||
});
|
||||
});
|
||||
|
||||
$("#stopScheinchenbtn").click(function() {
|
||||
$("#startScheinchenbtn").removeAttr("disabled");
|
||||
$("button[id^='startScheinchenbtn']").each(function(){
|
||||
$(this).removeAttr("disabled");
|
||||
});
|
||||
wsSend("stopSchweinchen", "");
|
||||
});
|
||||
|
||||
@ -121,8 +132,39 @@ $(document).ready(function() {
|
||||
wsSend("setRightPoints", $("#mPunkteRight").val());
|
||||
});
|
||||
|
||||
$("#alternateAnswerBtn").click(function(){
|
||||
var is = $("#finalFragenSelect").val();
|
||||
var answer = $("#alternateAnswer").val();
|
||||
wsSend("setAnswer", is+"###"+answer);
|
||||
});
|
||||
|
||||
$("#alternateAnswerPBtn").click(function(){
|
||||
var is = $("#finalFragenSelect").val();
|
||||
wsSend("setAnz", is+"###0");
|
||||
});
|
||||
|
||||
$("#finalmodusInfoBtn").click(function(){
|
||||
alert("Im Finalmodus geklickte Antworten und Punkte werden nur auf dem Display angezeigt!")
|
||||
});
|
||||
});
|
||||
|
||||
function setFinalMode(status){
|
||||
isFinalMode = status == "true" ? true : false;
|
||||
$(".finalElement").attr("disabled", !isFinalMode);
|
||||
var index = $("#questionsSelcet>option:selected").index();
|
||||
index = index > 0 ? index : 0;
|
||||
loadQuestionToGui(index);
|
||||
}
|
||||
|
||||
function setPlayer2(value){
|
||||
value = value == "true" ? true : false;
|
||||
player2 = value;
|
||||
}
|
||||
|
||||
function setRunde(value){
|
||||
runde = value;
|
||||
}
|
||||
|
||||
function showQuestionsAsPrint() {
|
||||
var ges = '<h2 style="margin-left:30px;">Familienduell Fragen</h2><ol>';
|
||||
for(var i=0;i<fragen.length;i++) {
|
||||
@ -150,22 +192,23 @@ function setRightPoints(newPoints) {
|
||||
}
|
||||
}
|
||||
|
||||
function startJeopardy() {
|
||||
function startAnswerFail() {
|
||||
if(sounds && (display || serverSound)) {
|
||||
jeopardy = new Audio('./sounds/jeopardy.mp3');
|
||||
jeopardy.volume = jeopardyVolume;
|
||||
jeopardy.play();
|
||||
}
|
||||
}
|
||||
|
||||
function stopJeopardy() {
|
||||
if(jeopardy) {
|
||||
jeopardy.pause();
|
||||
answerFail = new Audio('./sounds/failFinal.mp3');
|
||||
answerFail.volume = answerFailVolume;
|
||||
answerFail.play();
|
||||
}
|
||||
}
|
||||
|
||||
function startSchweinchen() {
|
||||
if (runde == 2){
|
||||
$("#schweinchen2Img").show();
|
||||
} else if (runde == 3){
|
||||
$("#schweinchenImg").show();
|
||||
} else {
|
||||
$("#schweinchen1Img").show();
|
||||
}
|
||||
|
||||
$("#answers").hide();
|
||||
$("#displayQuestions").hide();
|
||||
|
||||
@ -182,6 +225,8 @@ function stopSchweinchen() {
|
||||
changeFrage();
|
||||
|
||||
$("#schweinchenImg").hide();
|
||||
$("#schweinchen1Img").hide();
|
||||
$("#schweinchen2Img").hide();
|
||||
$("#answers").show();
|
||||
$("#displayQuestions").show();
|
||||
if(schweinchen) {
|
||||
@ -233,30 +278,75 @@ function changeFrage() {
|
||||
|
||||
function loadQuestionToGui(index) {
|
||||
$("#schweinchenImg").hide();
|
||||
$("#schweinchen1Img").hide();
|
||||
$("#schweinchen2Img").hide();
|
||||
if (!(player2 && display)) {
|
||||
$("#answers").empty();
|
||||
}
|
||||
|
||||
$('.footer').toggle(!isFinalMode);
|
||||
$('.xmarker').toggle(!isFinalMode);
|
||||
$("#ResSum_player1").toggle(isFinalMode);
|
||||
$("#ResSum_player2").toggle(isFinalMode);
|
||||
if (!isFinalMode){
|
||||
$("#resultFinal").hide();
|
||||
} else {
|
||||
$("#resultFinal").show();
|
||||
}
|
||||
$("#result").toggle(!isFinalMode);
|
||||
|
||||
if(index > -1) {
|
||||
$("#displayQuestions").html(fragen[index]["frage"]);
|
||||
if (isFinalMode){
|
||||
$("#displayQuestions").hide();
|
||||
} else {
|
||||
$("#displayQuestions").show();
|
||||
}
|
||||
for(var i=0;i<fragen[index]["antworten"].length;i++) {
|
||||
if(fragen[index]["antworten"][i]["antwort"] != "") {
|
||||
if (!isFinalMode) {
|
||||
var oneLine = $('<div style="height:55px">' +
|
||||
'<div style="width: 52px; float: left;" class="nr">' + (i + 1) + '.</div>' +
|
||||
'<div style="width: 860px; float: left;" class="answer"></div>' +
|
||||
'<div style="width: 52px; float: left;" class="points"></div>' +
|
||||
'</div>');
|
||||
if(display) {
|
||||
oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
|
||||
oneLine.find(".points").text("--");
|
||||
} else {
|
||||
var oneLine = $('<div style="margin-left: 20px; height:55px">' +
|
||||
'<div style="margin-left: 15px; width: 400px; float: left;" class="answer"></div>' +
|
||||
'<div style="width: 52px; float: left;" class="points"></div>' +
|
||||
'<div style="width: 65px; float: left;" class="points_player2"></div>' +
|
||||
'<div style="width: 400px; float: left;" class="answer_player2"></div>' +
|
||||
'</div>');
|
||||
}
|
||||
if(display && !player2) {
|
||||
if (isFinalMode) {
|
||||
oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _ _");
|
||||
} else {
|
||||
oneLine.find(".answer").text("_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _");
|
||||
}
|
||||
oneLine.find(".points").text("--");
|
||||
if (isFinalMode){
|
||||
oneLine.find(".points_player2").text("--");
|
||||
oneLine.find(".answer_player2").text("_ _ _ _ _ _ _ _ _ _ _");
|
||||
}
|
||||
} else if (!display) {
|
||||
oneLine.find(".answer").html('<span class="markOnHover">'+getAnswerString(fragen[index]["antworten"][i]["antwort"])+'</span>');
|
||||
oneLine.find(".points").html('<span class="markOnHover">'+fragen[index]["antworten"][i]["anz"]+'</span>');
|
||||
(function() {
|
||||
var is = i;
|
||||
var is2 = i;
|
||||
var frage = fragen[index];
|
||||
oneLine.find(".answer").click(function() {
|
||||
wsSend("setAnswer", is+"###"+frage["antworten"][is]["antwort"]);
|
||||
if (isFinalMode){
|
||||
is = $("#finalFragenSelect").val();
|
||||
}
|
||||
wsSend("setAnswer", is+"###"+frage["antworten"][is2]["antwort"]);
|
||||
});
|
||||
oneLine.find(".points").click(function() {
|
||||
wsSend("setAnz", is+"###"+frage["antworten"][is]["anz"]);
|
||||
if (isFinalMode){
|
||||
is = $("#finalFragenSelect").val();
|
||||
}
|
||||
wsSend("setAnz", is+"###"+frage["antworten"][is2]["anz"]);
|
||||
});
|
||||
})();
|
||||
}
|
||||
@ -264,13 +354,31 @@ function loadQuestionToGui(index) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFinalMode) {
|
||||
$("#SumRes").text("0");
|
||||
}
|
||||
if(!display)
|
||||
$("#resultFinal").hide();
|
||||
|
||||
if (isFinalMode){
|
||||
if (!player2) {
|
||||
$('#SumRes_player1').html("0");
|
||||
$('#SumRes_player2').html("0");
|
||||
}
|
||||
}
|
||||
if (!player2) {
|
||||
recalcSum(0);
|
||||
}
|
||||
}
|
||||
|
||||
function setAnswer(index, answer) {
|
||||
if(!(isFinalMode && !display)) { //not do it at final mode and controller
|
||||
var answer_select = ".answer";
|
||||
if (player2){
|
||||
answer_select = '.answer_player2';
|
||||
}
|
||||
answer = getAnswerString(answer);
|
||||
var el = $($("#answers").find(".answer")[index]);
|
||||
var el = $($("#answers").find(answer_select)[index]);
|
||||
el.empty();
|
||||
if(sounds && (display || serverSound)) {
|
||||
audio = new Audio('./sounds/textRichtig.mp3');
|
||||
@ -278,12 +386,22 @@ function setAnswer(index, answer) {
|
||||
}
|
||||
el.typed({
|
||||
strings: [answer],
|
||||
typeSpeed: 20
|
||||
typeSpeed: 10,
|
||||
showCursor: false,
|
||||
cursorChar: "",
|
||||
fadeOut: true,
|
||||
fadeOutDelay: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setAnz(index, nr) {
|
||||
var el = $($("#answers").find(".points")[index]);
|
||||
if(!(isFinalMode && !display)) { //not do it at final mode and controller
|
||||
var points_select = ".points";
|
||||
if (player2){
|
||||
points_select = '.points_player2';
|
||||
}
|
||||
var el = $($("#answers").find(points_select)[index]);
|
||||
el.text(nr);
|
||||
if(sounds && (display || serverSound)) {
|
||||
audio = new Audio('./sounds/zahlRichtig.mp3');
|
||||
@ -291,9 +409,30 @@ function setAnz(index, nr) {
|
||||
}
|
||||
recalcSum(nr);
|
||||
}
|
||||
}
|
||||
|
||||
function recalcSum(s) {
|
||||
$("#SumRes").text(parseFloat($("#SumRes").text())+parseFloat(s));
|
||||
var sum_selector = '#SumRes';
|
||||
if (isFinalMode) {
|
||||
var p1p = 0;
|
||||
var p2p = 0;
|
||||
$.each($(".points"), function() {
|
||||
var v = $(this).text();
|
||||
if(v != "--") {
|
||||
p1p = p1p + parseFloat(v);
|
||||
}
|
||||
});
|
||||
$.each($(".points_player2"), function() {
|
||||
var v = $(this).text();
|
||||
if(v != "--") {
|
||||
p2p = p2p + parseFloat(v);
|
||||
}
|
||||
});
|
||||
$("#SumRes_player1").text(p1p);
|
||||
$("#SumRes_player2").text(p2p);
|
||||
} else {
|
||||
$(sum_selector).text(parseFloat($(sum_selector).text())+parseFloat(s));
|
||||
}
|
||||
}
|
||||
|
||||
function getAnswerString(str) {
|
||||
@ -302,7 +441,11 @@ function getAnswerString(str) {
|
||||
str+="_";
|
||||
}
|
||||
anz = str.length;
|
||||
while(str.length < 40) {
|
||||
var maxLength = 40;
|
||||
if (isFinalMode){
|
||||
maxLength = 20;
|
||||
}
|
||||
while(str.length < maxLength) {
|
||||
str+= " _";
|
||||
}
|
||||
return str;
|
||||
|
441
web/js/typed.js
441
web/js/typed.js
@ -1,6 +1,6 @@
|
||||
// The MIT License (MIT)
|
||||
|
||||
// Typed.js | Copyright (c) 2014 Matt Boldt | www.mattboldt.com
|
||||
// Typed.js | Copyright (c) 2016 Matt Boldt | www.mattboldt.com
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@ -23,19 +23,37 @@
|
||||
|
||||
|
||||
|
||||
!function($){
|
||||
! function(window, document, $) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var Typed = function(el, options) {
|
||||
var self = this;
|
||||
|
||||
// chosen element to manipulate text
|
||||
this.el = $(el);
|
||||
this.el = el;
|
||||
|
||||
// options
|
||||
this.options = $.extend({}, $.fn.typed.defaults, options);
|
||||
this.options = {};
|
||||
Object.keys(defaults).forEach(function(key) {
|
||||
self.options[key] = defaults[key];
|
||||
});
|
||||
Object.keys(options).forEach(function(key) {
|
||||
self.options[key] = options[key];
|
||||
});
|
||||
|
||||
// attribute to type into
|
||||
this.isInput = this.el.tagName.toLowerCase() === 'input';
|
||||
this.attr = this.options.attr;
|
||||
|
||||
// show cursor
|
||||
this.showCursor = this.isInput ? false : this.options.showCursor;
|
||||
|
||||
// text content of element
|
||||
this.text = this.el.text();
|
||||
this.elContent = this.attr ? this.el.getAttribute(this.attr) : this.el.textContent;
|
||||
|
||||
// html or plain text
|
||||
this.contentType = this.options.contentType;
|
||||
|
||||
// typing speed
|
||||
this.typeSpeed = this.options.typeSpeed;
|
||||
@ -49,6 +67,18 @@
|
||||
// amount of time to wait before backspacing
|
||||
this.backDelay = this.options.backDelay;
|
||||
|
||||
// Fade out instead of backspace
|
||||
this.fadeOut = this.options.fadeOut;
|
||||
this.fadeOutClass = this.options.fadeOutClass;
|
||||
this.fadeOutDelay = this.options.fadeOutDelay;
|
||||
|
||||
// div containing strings
|
||||
if($ && this.options.stringsElement instanceof $) {
|
||||
this.stringsElement = this.options.stringsElement[0]
|
||||
} else {
|
||||
this.stringsElement = this.options.stringsElement;
|
||||
}
|
||||
|
||||
// input strings of text
|
||||
this.strings = this.options.strings;
|
||||
|
||||
@ -58,9 +88,6 @@
|
||||
// current array position
|
||||
this.arrayPos = 0;
|
||||
|
||||
// current string based on current values[] array position
|
||||
this.string = this.strings[this.arrayPos];
|
||||
|
||||
// number to stop backspacing on.
|
||||
// default 0, can change depending on how many chars
|
||||
// you want to remove at the time
|
||||
@ -69,46 +96,90 @@
|
||||
// Looping logic
|
||||
this.loop = this.options.loop;
|
||||
this.loopCount = this.options.loopCount;
|
||||
this.curLoop = 1;
|
||||
if (this.loop === false){
|
||||
// number in which to stop going through array
|
||||
// set to strings[] array (length - 1) to stop deleting after last string is typed
|
||||
this.stopArray = this.strings.length-1;
|
||||
}
|
||||
else{
|
||||
this.stopArray = this.strings.length;
|
||||
}
|
||||
this.curLoop = 0;
|
||||
|
||||
// for stopping
|
||||
this.stop = false;
|
||||
|
||||
// custom cursor
|
||||
this.cursorChar = this.options.cursorChar;
|
||||
|
||||
// shuffle the strings
|
||||
this.shuffle = this.options.shuffle;
|
||||
// the order of strings
|
||||
this.sequence = [];
|
||||
|
||||
// All systems go!
|
||||
this.build();
|
||||
}
|
||||
};
|
||||
|
||||
Typed.prototype = {
|
||||
|
||||
constructor: Typed
|
||||
constructor: Typed,
|
||||
|
||||
, init: function(){
|
||||
// begin the loop w/ first current string (global self.string)
|
||||
init: function() {
|
||||
// begin the loop w/ first current string (global self.strings)
|
||||
// current string will be passed as an argument each time after this
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
self.timeout = setTimeout(function() {
|
||||
for (var i=0;i<self.strings.length;++i) self.sequence[i]=i;
|
||||
|
||||
// shuffle the array if true
|
||||
if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
|
||||
|
||||
var elContent;
|
||||
if (self.isInput) {
|
||||
elContent = self.el.value;
|
||||
} else if (self.contentType === 'html') {
|
||||
elContent = self.el.innerHTML;
|
||||
} else {
|
||||
elContent = self.el.textContent;
|
||||
}
|
||||
// Start typing
|
||||
self.typewrite(self.string, self.strPos)
|
||||
// Check if there is some text in the element, if yes start by backspacing the default message
|
||||
if (elContent.length == 0) {
|
||||
self.typewrite(self.strings[self.sequence[self.arrayPos]], self.strPos);
|
||||
} else {
|
||||
self.backspace(elContent, elContent.length);
|
||||
}
|
||||
}, self.startDelay);
|
||||
}
|
||||
},
|
||||
|
||||
, build: function(){
|
||||
build: function() {
|
||||
var self = this;
|
||||
// Insert cursor
|
||||
//this.el.after("<span id=\"typed-cursor\">|</span>");
|
||||
if (this.showCursor === true) {
|
||||
this.cursor = document.createElement('span');
|
||||
this.cursor.className = 'typed-cursor';
|
||||
this.cursor.innerHTML = this.cursorChar;
|
||||
this.el.parentNode && this.el.parentNode.insertBefore(this.cursor, this.el.nextSibling);
|
||||
}
|
||||
if (this.stringsElement) {
|
||||
this.strings = [];
|
||||
this.stringsElement.style.display = 'none';
|
||||
var strings = Array.prototype.slice.apply(this.stringsElement.children);
|
||||
strings.forEach(function(stringElement){
|
||||
self.strings.push(stringElement.innerHTML);
|
||||
});
|
||||
}
|
||||
this.init();
|
||||
},
|
||||
|
||||
// pass current string state to each function, types 1 char per call
|
||||
typewrite: function(curString, curStrPos) {
|
||||
// exit when stopped
|
||||
if (this.stop === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// pass current string state to each function
|
||||
, typewrite: function(curString, curStrPos){
|
||||
if (this.fadeOut && this.el.classList.contains(this.fadeOutClass)) {
|
||||
this.el.classList.remove(this.fadeOutClass);
|
||||
this.cursor.classList.remove(this.fadeOutClass);
|
||||
}
|
||||
|
||||
// varying values for setTimeout during typing
|
||||
// can't be global since number changes each time loop is executed
|
||||
var humanize = Math.round(Math.random() * (30 - 30)) + this.typeSpeed;
|
||||
var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;
|
||||
var self = this;
|
||||
|
||||
// ------------- optional ------------- //
|
||||
@ -119,87 +190,121 @@
|
||||
// }
|
||||
// else{ self.backDelay = 500; }
|
||||
|
||||
// contain typing function in a timeout
|
||||
setTimeout(function() {
|
||||
|
||||
// make sure array position is less than array length
|
||||
if (self.arrayPos < self.strings.length){
|
||||
|
||||
// contain typing function in a timeout humanize'd delay
|
||||
self.timeout = setTimeout(function() {
|
||||
// check for an escape character before a pause value
|
||||
if (curString.substr(curStrPos, 1) === "^") {
|
||||
var charPauseEnd = curString.substr(curStrPos + 1).indexOf(" ");
|
||||
var charPause = curString.substr(curStrPos + 1, charPauseEnd);
|
||||
// format: \^\d+ .. eg: ^1000 .. should be able to print the ^ too using ^^
|
||||
// single ^ are removed from string
|
||||
var charPause = 0;
|
||||
var substr = curString.substr(curStrPos);
|
||||
if (substr.charAt(0) === '^') {
|
||||
var skip = 1; // skip atleast 1
|
||||
if (/^\^\d+/.test(substr)) {
|
||||
substr = /\d+/.exec(substr)[0];
|
||||
skip += substr.length;
|
||||
charPause = parseInt(substr);
|
||||
}
|
||||
|
||||
// strip out the escape character and pause value so they're not printed
|
||||
curString = curString.replace("^" + charPause, "");
|
||||
curString = curString.substring(0, curStrPos) + curString.substring(curStrPos + skip);
|
||||
}
|
||||
|
||||
if (self.contentType === 'html') {
|
||||
// skip over html tags while typing
|
||||
var curChar = curString.substr(curStrPos).charAt(0);
|
||||
if (curChar === '<' || curChar === '&') {
|
||||
var tag = '';
|
||||
var endTag = '';
|
||||
if (curChar === '<') {
|
||||
endTag = '>'
|
||||
}
|
||||
else {
|
||||
var charPause = 0;
|
||||
endTag = ';'
|
||||
}
|
||||
while (curString.substr(curStrPos + 1).charAt(0) !== endTag) {
|
||||
tag += curString.substr(curStrPos).charAt(0);
|
||||
curStrPos++;
|
||||
if (curStrPos + 1 > curString.length) { break; }
|
||||
}
|
||||
curStrPos++;
|
||||
tag += endTag;
|
||||
}
|
||||
}
|
||||
|
||||
// timeout for any pause after a character
|
||||
setTimeout(function() {
|
||||
self.timeout = setTimeout(function() {
|
||||
if (curStrPos === curString.length) {
|
||||
// fires callback function
|
||||
self.options.onStringTyped(self.arrayPos);
|
||||
|
||||
// start typing each new char into existing string
|
||||
// curString is function arg
|
||||
self.el.text(self.text + curString.substr(0, curStrPos));
|
||||
// is this the final string
|
||||
if (self.arrayPos === self.strings.length - 1) {
|
||||
// animation that occurs on the last typed string
|
||||
self.options.callback();
|
||||
|
||||
// check if current character number is the string's length
|
||||
// and if the current array position is less than the stopping point
|
||||
// if so, backspace after backDelay setting
|
||||
if (curStrPos > curString.length && self.arrayPos < self.stopArray){
|
||||
clearTimeout(clear);
|
||||
self.options.onStringTyped();
|
||||
var clear = setTimeout(function(){
|
||||
self.backspace(curString, curStrPos);
|
||||
}, self.backDelay);
|
||||
self.curLoop++;
|
||||
|
||||
// quit if we wont loop back
|
||||
if (self.loop === false || self.curLoop === self.loopCount)
|
||||
return;
|
||||
}
|
||||
|
||||
self.timeout = setTimeout(function() {
|
||||
self.backspace(curString, curStrPos);
|
||||
}, self.backDelay);
|
||||
|
||||
} else {
|
||||
|
||||
/* call before functions if applicable */
|
||||
if (curStrPos === 0) {
|
||||
self.options.preStringTyped(self.arrayPos);
|
||||
}
|
||||
|
||||
// start typing each new char into existing string
|
||||
// curString: arg, self.el.html: original text inside element
|
||||
var nextString = curString.substr(0, curStrPos + 1);
|
||||
if (self.attr) {
|
||||
self.el.setAttribute(self.attr, nextString);
|
||||
} else {
|
||||
if (self.isInput) {
|
||||
self.el.value = nextString;
|
||||
} else if (self.contentType === 'html') {
|
||||
self.el.innerHTML = nextString;
|
||||
} else {
|
||||
self.el.textContent = nextString;
|
||||
}
|
||||
}
|
||||
|
||||
// else, keep typing
|
||||
else{
|
||||
// add characters one by one
|
||||
curStrPos++;
|
||||
// loop the function
|
||||
self.typewrite(curString, curStrPos);
|
||||
// if the array position is at the stopping position
|
||||
// finish code, on to next task
|
||||
if (self.loop === false){
|
||||
if (self.arrayPos === self.stopArray && curStrPos === curString.length){
|
||||
// animation that occurs on the last typed string
|
||||
// fires callback function
|
||||
var clear = self.options.callback();
|
||||
clearTimeout(clear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// end of character pause
|
||||
}, charPause);
|
||||
}
|
||||
// if the array position is greater than array length
|
||||
// and looping is active, reset array pos and start over.
|
||||
else if (self.loop === true && self.loopCount === false){
|
||||
self.arrayPos = 0;
|
||||
self.init();
|
||||
}
|
||||
else if(self.loopCount !== false && self.curLoop < self.loopCount){
|
||||
self.arrayPos = 0;
|
||||
self.curLoop = self.curLoop+1;
|
||||
self.init();
|
||||
}
|
||||
|
||||
// humanized value for typing
|
||||
}, humanize);
|
||||
|
||||
},
|
||||
|
||||
backspace: function(curString, curStrPos) {
|
||||
var self = this;
|
||||
// exit when stopped
|
||||
if (this.stop === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
, backspace: function(curString, curStrPos){
|
||||
if (this.fadeOut){
|
||||
this.initFadeOut();
|
||||
return;
|
||||
}
|
||||
|
||||
// varying values for setTimeout during typing
|
||||
// can't be global since number changes each time loop is executed
|
||||
var humanize = Math.round(Math.random() * (100 - 30)) + this.backSpeed;
|
||||
var self = this;
|
||||
|
||||
setTimeout(function() {
|
||||
self.timeout = setTimeout(function() {
|
||||
|
||||
// ----- this part is optional ----- //
|
||||
// check string array position
|
||||
@ -214,9 +319,24 @@
|
||||
// self.stopNum = 0;
|
||||
// }
|
||||
|
||||
if (self.contentType === 'html') {
|
||||
// skip over html tags while backspacing
|
||||
if (curString.substr(curStrPos).charAt(0) === '>') {
|
||||
var tag = '';
|
||||
while (curString.substr(curStrPos - 1).charAt(0) !== '<') {
|
||||
tag -= curString.substr(curStrPos).charAt(0);
|
||||
curStrPos--;
|
||||
if (curStrPos < 0) { break; }
|
||||
}
|
||||
curStrPos--;
|
||||
tag += '<';
|
||||
}
|
||||
}
|
||||
|
||||
// ----- continue important stuff ----- //
|
||||
// replace text with current text + typed characters
|
||||
self.el.text(self.text + curString.substr(0, curStrPos));
|
||||
// replace text with base text + typed characters
|
||||
var nextString = curString.substr(0, curStrPos);
|
||||
self.replaceText(nextString);
|
||||
|
||||
// if the number (id of character in current string) is
|
||||
// less than the stop number, keep going
|
||||
@ -229,49 +349,170 @@
|
||||
// if the stop number has been reached, increase
|
||||
// array position to next string
|
||||
else if (curStrPos <= self.stopNum) {
|
||||
clearTimeout(clear);
|
||||
var clear = self.arrayPos = self.arrayPos+1;
|
||||
// must pass new array position in this instance
|
||||
// instead of using global arrayPos
|
||||
self.typewrite(self.strings[self.arrayPos], curStrPos);
|
||||
self.arrayPos++;
|
||||
|
||||
if (self.arrayPos === self.strings.length) {
|
||||
self.arrayPos = 0;
|
||||
|
||||
// Shuffle sequence again
|
||||
if(self.shuffle) self.sequence = self.shuffleArray(self.sequence);
|
||||
|
||||
self.init();
|
||||
} else
|
||||
self.typewrite(self.strings[self.sequence[self.arrayPos]], curStrPos);
|
||||
}
|
||||
|
||||
// humanized value for typing
|
||||
}, humanize);
|
||||
|
||||
},
|
||||
|
||||
// Adds a CSS class to fade out current string
|
||||
initFadeOut: function(){
|
||||
self = this;
|
||||
this.el.className += ' ' + this.fadeOutClass;
|
||||
this.cursor.className += ' ' + this.fadeOutClass;
|
||||
return setTimeout(function() {
|
||||
self.arrayPos++;
|
||||
self.replaceText('');
|
||||
|
||||
// Resets current string if end of loop reached
|
||||
if(self.strings.length > self.arrayPos) {
|
||||
self.typewrite(self.strings[self.sequence[self.arrayPos]], 0);
|
||||
} else {
|
||||
self.typewrite(self.strings[0], 0);
|
||||
self.arrayPos = 0;
|
||||
}
|
||||
}, self.fadeOutDelay);
|
||||
},
|
||||
|
||||
// Replaces current text in the HTML element
|
||||
replaceText: function(str) {
|
||||
if (this.attr) {
|
||||
this.el.setAttribute(this.attr, str);
|
||||
} else {
|
||||
if (this.isInput) {
|
||||
this.el.value = str;
|
||||
} else if (this.contentType === 'html') {
|
||||
this.el.innerHTML = str;
|
||||
} else {
|
||||
this.el.textContent = str;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Shuffles the numbers in the given array.
|
||||
shuffleArray: function(array) {
|
||||
var tmp, current, top = array.length;
|
||||
if(top) while(--top) {
|
||||
current = Math.floor(Math.random() * (top + 1));
|
||||
tmp = array[current];
|
||||
array[current] = array[top];
|
||||
array[top] = tmp;
|
||||
}
|
||||
return array;
|
||||
},
|
||||
|
||||
// Start & Stop currently not working
|
||||
|
||||
// , stop: function() {
|
||||
// var self = this;
|
||||
|
||||
// self.stop = true;
|
||||
// clearInterval(self.timeout);
|
||||
// }
|
||||
|
||||
// , start: function() {
|
||||
// var self = this;
|
||||
// if(self.stop === false)
|
||||
// return;
|
||||
|
||||
// this.stop = false;
|
||||
// this.init();
|
||||
// }
|
||||
|
||||
// Reset and rebuild the element
|
||||
reset: function() {
|
||||
var self = this;
|
||||
clearInterval(self.timeout);
|
||||
var id = this.el.getAttribute('id');
|
||||
this.el.textContent = '';
|
||||
if (typeof this.cursor !== 'undefined' && typeof this.cursor.parentNode !== 'undefined') {
|
||||
this.cursor.parentNode.removeChild(this.cursor);
|
||||
}
|
||||
this.strPos = 0;
|
||||
this.arrayPos = 0;
|
||||
this.curLoop = 0;
|
||||
// Send the callback
|
||||
this.options.resetCallback();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Typed.new = function(selector, option) {
|
||||
var elements = Array.prototype.slice.apply(document.querySelectorAll(selector));
|
||||
elements.forEach(function(element) {
|
||||
var instance = element._typed,
|
||||
options = typeof option == 'object' && option;
|
||||
if (instance) { instance.reset(); }
|
||||
element._typed = instance = new Typed(element, options);
|
||||
if (typeof option == 'string') instance[option]();
|
||||
});
|
||||
};
|
||||
|
||||
if ($) {
|
||||
$.fn.typed = function(option) {
|
||||
return this.each(function() {
|
||||
var $this = $(this)
|
||||
, data = $this.data('typed')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('typed', (data = new Typed(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
var $this = $(this),
|
||||
data = $this.data('typed'),
|
||||
options = typeof option == 'object' && option;
|
||||
if (data) { data.reset(); }
|
||||
$this.data('typed', (data = new Typed(this, options)));
|
||||
if (typeof option == 'string') data[option]();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$.fn.typed.defaults = {
|
||||
window.Typed = Typed;
|
||||
|
||||
var defaults = {
|
||||
strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],
|
||||
stringsElement: null,
|
||||
// typing speed
|
||||
typeSpeed: 0,
|
||||
// time before typing starts
|
||||
startDelay: 0,
|
||||
// backspacing speed
|
||||
backSpeed: 0,
|
||||
// shuffle the strings
|
||||
shuffle: false,
|
||||
// time before backspacing
|
||||
backDelay: 500,
|
||||
// Fade out instead of backspace
|
||||
fadeOut: false,
|
||||
fadeOutClass: 'typed-fade-out',
|
||||
fadeOutDelay: 500, // milliseconds
|
||||
// loop
|
||||
loop: false,
|
||||
// false = infinite
|
||||
loopCount: false,
|
||||
// ending callback function
|
||||
callback: function(){ null },
|
||||
// show cursor
|
||||
showCursor: true,
|
||||
// character for cursor
|
||||
cursorChar: "|",
|
||||
// attribute to type (null == text)
|
||||
attr: null,
|
||||
// either html or text
|
||||
contentType: 'html',
|
||||
// call when done callback function
|
||||
callback: function() {},
|
||||
// starting callback function before each string
|
||||
preStringTyped: function() {},
|
||||
//callback for every typed string
|
||||
onStringTyped: function(){ null }
|
||||
}
|
||||
onStringTyped: function() {},
|
||||
// callback for reset
|
||||
resetCallback: function() {}
|
||||
};
|
||||
|
||||
|
||||
}(window.jQuery);
|
||||
}(window, document, window.jQuery);
|
||||
|
@ -15,6 +15,9 @@ var ws;
|
||||
var display = true;
|
||||
var audio = null;
|
||||
var serverSound = false;
|
||||
var isFinalMode = false;
|
||||
var player2 = false;
|
||||
var runde = 1;
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#displayBtn").click(function() {
|
||||
@ -124,6 +127,7 @@ var connectWs = function() {
|
||||
}
|
||||
}
|
||||
} else if(key == "loadQuestion") {
|
||||
if(!(display && isFinalMode))
|
||||
loadQuestionToGui(value);
|
||||
} else if(key == "setAnswer") {
|
||||
setAnswer(value, messageParts_a[2]);
|
||||
@ -141,14 +145,12 @@ var connectWs = function() {
|
||||
setLeftPoints(value);
|
||||
} else if(key == "setRightPoints") {
|
||||
setRightPoints(value);
|
||||
} else if(key == "startJeopardy") {
|
||||
startJeopardy();
|
||||
} else if(key == "stopJeopardy") {
|
||||
stopJeopardy();
|
||||
} else if(key == "setJeopardyVolume") {
|
||||
jeopardyVolume = value;
|
||||
if(jeopardy != null)
|
||||
jeopardy.volume = jeopardyVolume;
|
||||
} else if(key == "startAnswerFail") {
|
||||
startAnswerFail();
|
||||
} else if(key == "setAnswerFailVolume") {
|
||||
answerFailVolume = value;
|
||||
if(answerFail != null)
|
||||
answerFail.volume = answerFailVolume;
|
||||
} else if(key == "startSchweinchen") {
|
||||
startSchweinchen();
|
||||
} else if(key == "stopSchweinchen") {
|
||||
@ -161,6 +163,15 @@ var connectWs = function() {
|
||||
if(display) {
|
||||
$("#blackScreen").toggle();
|
||||
}
|
||||
} else if (key == "toggleFinalMode"){
|
||||
setFinalMode(value);
|
||||
}
|
||||
else if (key == "setPlayer2ForFinalMode"){
|
||||
setPlayer2(value);
|
||||
}
|
||||
else if (key == "setRunde"){
|
||||
console.log('Set Runde to ' + value);
|
||||
setRunde(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
web/sounds/failfinal.mp3
Executable file
BIN
web/sounds/failfinal.mp3
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user