Last changes

This commit is contained in:
s434585 2018-01-24 02:16:58 +01:00
parent 2a894b441b
commit 5050b36dba
4 changed files with 156 additions and 117 deletions

3
debug.log Normal file
View File

@ -0,0 +1,3 @@
[0123/200618.034:ERROR:process_info.cc(632)] range at 0xb549376400000000, size 0x215 fully unreadable
[0123/200618.034:ERROR:process_info.cc(632)] range at 0xb54937ca00000000, size 0x215 fully unreadable
[0123/200618.034:ERROR:process_info.cc(632)] range at 0x0, size 0x215 fully unreadable

View File

@ -19,6 +19,7 @@ $(document).ready(function () {
var snake; var snake;
var d = "RIGHT"; var d = "RIGHT";
var gameloop; var gameloop;
var id_question;
function start(gameloop){ function start(gameloop){
@ -27,7 +28,7 @@ $(document).ready(function () {
} }
function reset() { function reset() {
window.location.reload(); window.location.reload();
if(!localStorage.getItem("life_couter") === null ){ if(localStorage.getItem("life_couter") === null ){
setLifeCouter(3); setLifeCouter(3);
} }
} }
@ -90,7 +91,18 @@ $(document).ready(function () {
var form = $(this).serializeArray(); var form = $(this).serializeArray();
e.preventDefault(); e.preventDefault();
form = JSON.stringify(form); form = JSON.stringify(form);
localStorage.setItem("new_question",form); if(localStorage.getItem("new_question") === null){
localStorage.setItem('id_question', 0);
localStorage.setItem("new_question",form);
alert('Dodano pytanie. Wciśnij Ok. Dodaj następne pytanie lub wciśnij F5 i graj');
}
else{
id_question = localStorage.getItem('id_question');
id_question++ ;
localStorage.setItem(`new_question-${id_question}`,form);
localStorage.setItem('id_question', id_question);
alert('Dodano pytanie. Wciśnij Ok. Dodaj następne pytanie lub wciśnij F5 i graj');
}
$(this).closest('form').find("input[type=text]").val(""); $(this).closest('form').find("input[type=text]").val("");
}); });
@ -105,7 +117,19 @@ $(document).ready(function () {
// } // }
// }); // });
$('#clear_local_storage').click(function(){
localStorage.removeItem(`new_question`);
var numberOfQuestions = localStorage.getItem('id_question');
for (var i = 0; i <= numberOfQuestions; i++){
localStorage.removeItem(`new_question-${i}`);
}
localStorage.removeItem('id_question');
})
$('#restart_game').click(function(){
setLifeCouter(3);
setSessionScore(0);
alert('Zresetowałeś swoje życia, wciśnij Ok, a następnie F5 żeby zacząć od nowa');
})
$('#add_question').click(function(){ $('#add_question').click(function(){
var isHidden = localStorage.getItem('isHidden'); var isHidden = localStorage.getItem('isHidden');
if(isHidden === null){ if(isHidden === null){
@ -125,9 +149,12 @@ $(document).ready(function () {
$('#try_again').click(function(){ $('#try_again').click(function(){
tryAgain(); tryAgain();
}) })
$('#session').text(getSessionScore()) $('#session').text(getSessionScore());
$('#lifes').text(localStorage.getItem('life_couter'));
if(localStorage.getItem('life_couter') == 0){
alert(`Koniec gry! Twoj wynik to: ${localStorage.getItem('session_score')}. Jeżeli chcesz zagrać jeszcze raz wciśnij Ok, następnie Resetuj grę, poźniej F5`);
}
function update() { function update() {
if (d == "RIGHT") if (d == "RIGHT")
snake.x = snake.x + 1; snake.x = snake.x + 1;
@ -145,108 +172,58 @@ $(document).ready(function () {
paint_cell(snake.x, snake.y, "green"); paint_cell(snake.x, snake.y, "green");
} }
function randomYes() {
var newClass = "yes";
var randomKey = parseInt(Math.floor(Math.random() * 4));
$("div").each(function () {
var inputsArr = $(this).children("input[name='yes_no']")
var inputYes = $(inputsArr[randomKey]);
inputYes.attr('class', newClass);
inputYes.removeClass("no");
})
}
function showQuestionTask() { function showQuestionTask() {
var pytania ={
"test1":{
"question": "HT products are Not characterized by:",
"answerY": "Longlife",
"answerNone": "Technoligical complexity",
"answerNtwo": "Small initial number of purchasers",
"answerNthree": "Frequent occurrence of technical problems"
},
"test2":{ function pickRandomQuestion(){
"question": "Choose the TRUE characteristics of HT market", var questionKey = 'new_question';
"answerY": "Prices drop rapidly", var id = localStorage.getItem('id_question');
"answerNone": "The competition among manufactures is not challenging", var randomKey = Math.floor(Math.random() * id);
"answerNtwo": "Customers easily adapt themselves to new solutions", if(randomKey === 0){
"answerNthree": "Market is secur for long period of time" var randomQuestion = localStorage.getItem(questionKey);
}, randomQuestion = JSON.parse(randomQuestion);
}else{
"test3":{ questionKey = `new_question-${randomKey}`;
"question": "The uniqueness of HT products is NOT achieved by:", var randomQuestion = localStorage.getItem(questionKey);
"answerY": "Existence of R&D department", randomQuestion = JSON.parse(randomQuestion);
"answerNone": "High invesment", }
"answerNtwo": "Using newest patents of other parties",
"answerNthree": "Introduction of new business models"
},
"test4":{
"question": "Choose the feature that does NOT improve productivity",
"answerY": "Introducing ads into products usage",
"answerNone": "Automatizing simple activities",
"answerNtwo": "Speeding up the learning process",
"answerNthree": "helping to avoid errors"
},
"test5":{
"question": "A HT product may save user`s investment by:",
"answerY": "minimizing the cost of switching into new hardwere",
"answerNone": "hindering (making hard) migration of data",
"answerNtwo": "forcing user to purchase modern hardware",
"answerNthree": "shortening the life of software"
},
"test6":{
"question": "Which of these is NOT a tool intended to minimize cost failure",
"anwerY": "USB",
"answerNone": "Bank machine",
"answerNtwo": "Firewall",
"answerNthree": "antivirus program"
},
"test7":{
"question": "In order to improve the performance - cost factor",
"answerY": "We need to improve efficiency AND lower cost",
"answerNone": "We need to improve efficiency OR lower cost",
"answerNtwo": "We need to lower efficiency AND increase cost",
"answerNThree": "We need to lower efficiency OR increase costs"
},
"test8":{
"question": "A solution is called scalable if",
"answerY": "It can be used for both: amall and big volumes of data",
"answerNone": "It can be used in varios scenarios",
"answerNtwo": "It can be used only for maning big data",
"answerNthree": "It can be used as weight-scale"
},
"test9":{
"question": "Methods thet do NOT serve for roviding entertainment",
"answerY": "Automatization of repeatable activities",
"answerNone": "Gamification",
"answerNtwo": "Relating to hobbies",
"answerNthree": "Relating to leisure time"
},
"test10":{
"question": "Which of below is NOT a key for success in HT?",
"answerY": "High price of the first version",
"answerNone": "Noticeable Performance - Cost improvement",
"answerNtwo": "Clear message",
"answerNthree": "Statisfying of at least 3-4(of 9) success rules"
}
}
function pickRandomQuestion(pytania){
var objKeys = Object.keys(pytania);
var randomKey = objKeys[Math.floor(Math.random() *objKeys.length)];
var randomQuestion = pytania[randomKey];
return randomQuestion; return randomQuestion;
} }
var randomQuestion = pickRandomQuestion(pytania); var randomQuestion = pickRandomQuestion();
console.log(randomQuestion); console.log(randomQuestion);
var current = $('#current').text(); var current = $('#current').text();
$('#final').text(current); $('#final').text(current);
$('h3').text(randomQuestion["question"]); if(randomQuestion === null){
console.log(randomQuestion["answerY"]); alert('Pytania nie zostaly dodane. Wciśnij Ok, następnie F5 i dodaj pytania');
$('#yes').text(randomQuestion["answerY"]); }
$('#no_one').text(randomQuestion["answerNone"]);
$('#no_two').text(randomQuestion["answerNtwo"]); $('h3').text(randomQuestion[0].value);
$('#no_three').text(randomQuestion["answerNthree"]); $('#yes').text(randomQuestion[1].value);
$('#no_one').text(randomQuestion[2].value);
$('#no_two').text(randomQuestion[3].value);
$('#no_three').text(randomQuestion[4].value);
$('#popup').fadeIn(); $('#popup').fadeIn();
randomYes();
// $(".popup-item").each(function(index){
// var newId = "yes";
// });
$('.yes').click(function () { $('.yes').click(function () {
if ($('.yes').is(':checked')) { if ($('.yes').is(':checked')) {
$('#correct').fadeIn('slow'); $('#correct').fadeIn('slow');
@ -259,6 +236,7 @@ $(document).ready(function () {
//fixuj ten projekt //fixuj ten projekt
$('#question_couter').text(questionCouter); $('#question_couter').text(questionCouter);
$('#session').text(sessionScore); $('#session').text(sessionScore);
$('lifes').text(localStorage.getItem('life_couter'))
setSessionScore(sessionScore); setSessionScore(sessionScore);
setQuestionCouter(questionCouter); setQuestionCouter(questionCouter);
$('#restart').fadeIn('slow'); $('#restart').fadeIn('slow');
@ -270,7 +248,7 @@ $(document).ready(function () {
$('#incorrect').fadeIn('slow'); $('#incorrect').fadeIn('slow');
$('.yes').attr('disabled','disabled').delay(1000);; $('.yes').attr('disabled','disabled').delay(1000);;
$('.no').prop('checked', true); $('.no').prop('checked', true);
$('#try_again').fadeIn('slow'); $('#try_again').fadeIn('slow');
} }
}) })
} }
@ -362,8 +340,6 @@ $(document).ready(function () {
} else if (key == "40") { } else if (key == "40") {
snake.y += 1; snake.y += 1;
d = "DOWN"; d = "DOWN";
} else if(key == "32"){
reset();
} }
check_food(); check_food();

View File

@ -20,7 +20,7 @@ body {
#add_question { #add_question {
position : absolute; position : absolute;
top: 100px; top: 100px;
left: 2000px; left: 1750px;
} }
#popup { #popup {
background-color: rgba(0,0,0,.25); background-color: rgba(0,0,0,.25);
@ -34,6 +34,33 @@ body {
width: 100%; width: 100%;
} }
input[type="text"] {
-webkit-transition: all 0.30s ease-in-out;
-moz-transition: all 0.30s ease-in-out;
-ms-transition: all 0.30s ease-in-out;
-o-transition: all 0.30s ease-in-out;
outline: none;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
width: 100%;
background: #fff;
margin-bottom: 4%;
margin-top: 4%;
border: 1px solid #ccc;
padding: 3%;
color: #555;
font: 95% Arial, Helvetica, sans-serif;
}
input[type="text"] {
box-shadow: 0 0 5px #43D1AF;
padding: 3%;
border: 1px solid #43D1AF;
}
#form-popup { #form-popup {
position: absolute; position: absolute;
@ -53,7 +80,7 @@ body {
#popup_question { #popup_question {
position : absolute; position : absolute;
top: 150px; top: 150px;
left: 2000px; left: 1750px;
font-size: 20px; font-size: 20px;
text-align: center; text-align: center;
color: rgb(100, 219, 223); color: rgb(100, 219, 223);
@ -97,7 +124,35 @@ body {
text-shadow:0px 1px 0px #3d768a text-shadow:0px 1px 0px #3d768a
} }
#restart:hover{ #restart_game, #add_question, #clear_local_storage, #send_question{
display: inline;
-moz-box-shadow: 0px 10px 14px -7px #276873;
-webkit-box-shadow: 0px 10px 14px -7px #276873;
box-shadow: 0px 10px 14px -7px #276873;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #599bb3), color-stop(1, #408c99));
background:-moz-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-webkit-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-o-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:-ms-linear-gradient(top, #599bb3 5%, #408c99 100%);
background:linear-gradient(to bottom, #599bb3 5%, #408c99 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#599bb3', endColorstr='#408c99',GradientType=0);
background-color:#599bb3;
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:20px;
font-weight:bold;
padding:13px 32px;
margin-bottom: 8%;
text-decoration:none;
text-shadow:0px 1px 0px #3d768a
}
#restart:hover, #restart_game:hover, #clear_local_storage:hover, #send_question:hover, #add_question:hover{
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #408c99), color-stop(1, #599bb3)); background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #408c99), color-stop(1, #599bb3));
background:-moz-linear-gradient(top, #408c99 5%, #599bb3 100%); background:-moz-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:-webkit-linear-gradient(top, #408c99 5%, #599bb3 100%); background:-webkit-linear-gradient(top, #408c99 5%, #599bb3 100%);
@ -108,7 +163,7 @@ body {
background-color:#408c99; background-color:#408c99;
} }
#restart:active{ #restart:active, #restart_game:active, #clear_local_storage:active, #send_question:active{
position:relative; position:relative;
top:1px; top:1px;
} }
@ -118,9 +173,10 @@ body {
height: 100px; height: 100px;
margin: auto; margin: auto;
background-color: grey; background-color: grey;
font-size: 25px;
} }
#current, #highest, #session, #question_couter { #current, #highest, #session, #question_couter, #lifes {
font-size : 25px; font-size : 25px;
color: black; color: black;
text-align: center; text-align: center;

View File

@ -8,42 +8,46 @@
<body> <body>
<div id="container"> <div id="container">
<button id="add_question">AddQuestion</button> <button id="add_question">Dodaj pytanie!</button>
<form id='popup_question'> <form id='popup_question'>
<input type="text" name="question" placeholder="Podaj pytanie"><br> <input type="text" name="question" placeholder="Podaj pytanie"><br>
<input type="text" name="answer1" placeholder="Podaj odpowiedz 1"><br> <input type="text" name="answer" placeholder="Podaj odpowiedz 1 (poprawną)"><br>
<input type="text" name="answer2" placeholder="Podaj odpowiedz 2"><br> <input type="text" name="answer" placeholder="Podaj odpowiedz 2"><br>
<input type="text" name="answer3" placeholder="Podaj odpowiedz 3"><br> <input type="text" name="answer" placeholder="Podaj odpowiedz 3"><br>
<input type="text" name="answer4" placeholder="Podaj odpowiedz 4"><br> <input type="text" name="answer" placeholder="Podaj odpowiedz 4"><br>
<button id="send_question" type="submit">Wyslij</button> <button id="send_question" type="submit">Wyslij</button>
<br>
<a id="clear_local_storage">Wyczyść bazę pytań</a>
</form> </form>
<div id="popup"> <div id="popup">
<div id="form-popup"> <div id="form-popup">
<h2>Odpowiedz na pytanie!</h2> <h2>Odpowiedz na pytanie!</h2>
<br> <br>
<h3>Czy lubisz jablka?</h3> <h3>Czy lubisz jablka?</h3>
<input class="yes" class="popup-item" type="radio" value="option1" name="yes_no"><span id="yes">odpowiedz1</span><br> <input class="no" class="popup-item" type="radio" value="option1" name="yes_no"><span id="yes">odpowiedz1</span><br>
<input class="no" class="popup-item" type="radio" value="option2" name="yes_no"><span id="no_one">odpowiedz2</span><br> <input class="no" class="popup-item" type="radio" value="option2" name="yes_no"><span id="no_one">odpowiedz2</span><br>
<input class="no" class="popup-item" type="radio" value="option3" name="yes_no"><span id="no_two">odpowiedz3</span><br> <input class="no" class="popup-item" type="radio" value="option3" name="yes_no"><span id="no_two">odpowiedz3</span><br>
<input class="no" class="popup-item" type="radio" value="option4" name="yes_no"><span id="no_three">odpowiedz4</span><br> <input class="no" class="popup-item" type="radio" value="option4" name="yes_no"><span id="no_three">odpowiedz4</span><br>
<!-- <button id="accept" type="submit">DALEJ!</button> --> <!-- <button id="accept" type="submit">DALEJ!</button> -->
<br><span id="correct">To jest dobra odpowiedz, mozesz grac dalej!</span><br> <br><span id="correct">To jest dobra odpowiedz, mozesz grac dalej!</span><br>
<!-- <button id="continue_game">Ruszaj dalej!</button> --> <!-- <button id="continue_game">Ruszaj dalej!</button> -->
<span id="incorrect">To jest zla odpowiedz! Przegrales! <span id="incorrect">To jest zla odpowiedz! Graj dalej!
Twoj wynik to: <span id="final"></span><br> Twoj wynik to: <span id="final"></span><br>
</span> </span>
<br> <br>
<button id="restart" href="#">Click to Contiune</button> <button id="restart" href="#">Wyśnij, aby kontynuować</button>
<button id="try_again" href="#">Try again</button> <button id="try_again" href="#">Spróbuj jeszcze raz</button>
</div> </div>
</div> </div>
<canvas id="myCanvas" width="600" height="450"> <canvas id="myCanvas" width="600" height="450">
Your browser does not support the canvas feature Your browser does not support the canvas feature
</canvas> </canvas>
<div id="score"> <div id="score">
<div>Session Score:<span id="session">0</span>&#47<span id="question_couter">0</span> <div>Punkty:&nbsp;<span id="session">0</span></div>
</div> <div>Życia:&nbsp;<span id="lifes">4</span></div>
</div> </div>
<button id="restart_game">Resetuj grę</button>
</div> </div>
<!-- Json <!-- Json
<script src="js/pytania.json" type="text/javascript"></script> --> <script src="js/pytania.json" type="text/javascript"></script> -->