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 d = "RIGHT";
var gameloop;
var id_question;
function start(gameloop){
@ -27,7 +28,7 @@ $(document).ready(function () {
}
function reset() {
window.location.reload();
if(!localStorage.getItem("life_couter") === null ){
if(localStorage.getItem("life_couter") === null ){
setLifeCouter(3);
}
}
@ -90,7 +91,18 @@ $(document).ready(function () {
var form = $(this).serializeArray();
e.preventDefault();
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("");
});
@ -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(){
var isHidden = localStorage.getItem('isHidden');
if(isHidden === null){
@ -125,9 +149,12 @@ $(document).ready(function () {
$('#try_again').click(function(){
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() {
if (d == "RIGHT")
snake.x = snake.x + 1;
@ -145,108 +172,58 @@ $(document).ready(function () {
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() {
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":{
"question": "Choose the TRUE characteristics of HT market",
"answerY": "Prices drop rapidly",
"answerNone": "The competition among manufactures is not challenging",
"answerNtwo": "Customers easily adapt themselves to new solutions",
"answerNthree": "Market is secur for long period of time"
},
"test3":{
"question": "The uniqueness of HT products is NOT achieved by:",
"answerY": "Existence of R&D department",
"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];
function pickRandomQuestion(){
var questionKey = 'new_question';
var id = localStorage.getItem('id_question');
var randomKey = Math.floor(Math.random() * id);
if(randomKey === 0){
var randomQuestion = localStorage.getItem(questionKey);
randomQuestion = JSON.parse(randomQuestion);
}else{
questionKey = `new_question-${randomKey}`;
var randomQuestion = localStorage.getItem(questionKey);
randomQuestion = JSON.parse(randomQuestion);
}
return randomQuestion;
}
var randomQuestion = pickRandomQuestion(pytania);
var randomQuestion = pickRandomQuestion();
console.log(randomQuestion);
var current = $('#current').text();
$('#final').text(current);
$('h3').text(randomQuestion["question"]);
console.log(randomQuestion["answerY"]);
$('#yes').text(randomQuestion["answerY"]);
$('#no_one').text(randomQuestion["answerNone"]);
$('#no_two').text(randomQuestion["answerNtwo"]);
$('#no_three').text(randomQuestion["answerNthree"]);
if(randomQuestion === null){
alert('Pytania nie zostaly dodane. Wciśnij Ok, następnie F5 i dodaj pytania');
}
$('h3').text(randomQuestion[0].value);
$('#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();
randomYes();
// $(".popup-item").each(function(index){
// var newId = "yes";
// });
$('.yes').click(function () {
if ($('.yes').is(':checked')) {
$('#correct').fadeIn('slow');
@ -259,6 +236,7 @@ $(document).ready(function () {
//fixuj ten projekt
$('#question_couter').text(questionCouter);
$('#session').text(sessionScore);
$('lifes').text(localStorage.getItem('life_couter'))
setSessionScore(sessionScore);
setQuestionCouter(questionCouter);
$('#restart').fadeIn('slow');
@ -270,7 +248,7 @@ $(document).ready(function () {
$('#incorrect').fadeIn('slow');
$('.yes').attr('disabled','disabled').delay(1000);;
$('.no').prop('checked', true);
$('#try_again').fadeIn('slow');
$('#try_again').fadeIn('slow');
}
})
}
@ -362,8 +340,6 @@ $(document).ready(function () {
} else if (key == "40") {
snake.y += 1;
d = "DOWN";
} else if(key == "32"){
reset();
}
check_food();

View File

@ -20,7 +20,7 @@ body {
#add_question {
position : absolute;
top: 100px;
left: 2000px;
left: 1750px;
}
#popup {
background-color: rgba(0,0,0,.25);
@ -34,6 +34,33 @@ body {
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 {
position: absolute;
@ -53,7 +80,7 @@ body {
#popup_question {
position : absolute;
top: 150px;
left: 2000px;
left: 1750px;
font-size: 20px;
text-align: center;
color: rgb(100, 219, 223);
@ -97,7 +124,35 @@ body {
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:-moz-linear-gradient(top, #408c99 5%, #599bb3 100%);
background:-webkit-linear-gradient(top, #408c99 5%, #599bb3 100%);
@ -108,7 +163,7 @@ body {
background-color:#408c99;
}
#restart:active{
#restart:active, #restart_game:active, #clear_local_storage:active, #send_question:active{
position:relative;
top:1px;
}
@ -118,9 +173,10 @@ body {
height: 100px;
margin: auto;
background-color: grey;
font-size: 25px;
}
#current, #highest, #session, #question_couter {
#current, #highest, #session, #question_couter, #lifes {
font-size : 25px;
color: black;
text-align: center;

View File

@ -8,42 +8,46 @@
<body>
<div id="container">
<button id="add_question">AddQuestion</button>
<button id="add_question">Dodaj pytanie!</button>
<form id='popup_question'>
<input type="text" name="question" placeholder="Podaj pytanie"><br>
<input type="text" name="answer1" placeholder="Podaj odpowiedz 1"><br>
<input type="text" name="answer2" placeholder="Podaj odpowiedz 2"><br>
<input type="text" name="answer3" placeholder="Podaj odpowiedz 3"><br>
<input type="text" name="answer4" placeholder="Podaj odpowiedz 4"><br>
<input type="text" name="answer" placeholder="Podaj odpowiedz 1 (poprawną)"><br>
<input type="text" name="answer" placeholder="Podaj odpowiedz 2"><br>
<input type="text" name="answer" placeholder="Podaj odpowiedz 3"><br>
<input type="text" name="answer" placeholder="Podaj odpowiedz 4"><br>
<button id="send_question" type="submit">Wyslij</button>
<br>
<a id="clear_local_storage">Wyczyść bazę pytań</a>
</form>
<div id="popup">
<div id="form-popup">
<h2>Odpowiedz na pytanie!</h2>
<br>
<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="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>
<!-- <button id="accept" type="submit">DALEJ!</button> -->
<br><span id="correct">To jest dobra odpowiedz, mozesz grac dalej!</span><br>
<!-- <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>
</span>
<br>
<button id="restart" href="#">Click to Contiune</button>
<button id="try_again" href="#">Try again</button>
<button id="restart" href="#">Wyśnij, aby kontynuować</button>
<button id="try_again" href="#">Spróbuj jeszcze raz</button>
</div>
</div>
<canvas id="myCanvas" width="600" height="450">
Your browser does not support the canvas feature
</canvas>
<div id="score">
<div>Session Score:<span id="session">0</span>&#47<span id="question_couter">0</span>
</div>
<div>Punkty:&nbsp;<span id="session">0</span></div>
<div>Życia:&nbsp;<span id="lifes">4</span></div>
</div>
<button id="restart_game">Resetuj grę</button>
</div>
<!-- Json
<script src="js/pytania.json" type="text/javascript"></script> -->