JS funkar inte som jag vill i Wordpress!
Hej! Jag vill få min glostestare att fungera som den alltid gjort i vanlig HTML men när jag lägger in den i wordpress vill den inte fungera!?!
Wordpress
HTML
KOD 1
<!DOCTYPE html>
<html style="overflow: -moz-scrollbars-vertical;
overflow: scroll;">
<head>
<style>p{
font-family:Segoe UI
}</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel='stylesheet' media='screen and (min-width: 200px) and (max-width: 480px)' href='mobil.css' />
<link rel='stylesheet' media='screen and (min-width: 481px) and (max-width: 1050px)' href='liten.css' />
<link rel='stylesheet' media='screen and (min-width: 1051px)' href='stor.css' />
<link rel="stylesheet" href="main.css" />
<link rel="shortcut icon" href="favicon.ico">
<title>Glosor | Startsida</title>
<link rel="apple-touch-icon-precomposed" href="http://tommielag.se/itmedia/liten.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://tommielag.se/itmedia/mellan.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://tommielag.se/itmedia/stor.png">
<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<style type="text/css">
#main {
max-width: 700px;
margin: 100px auto 0;
padding: 20px;
text-align: center;
font-family: sans-serif;
margin-top:-3%;
}
#word {
font-size: 36px;
padding: 10px;
}
#correctAnswer {
padding: 10px;
}
#answer {
padding: 5px;
margin: 5px;
font-size: 16px;
text-align: center;
width: 230px;
}
#game {
display: none;
}
#result .span {
margin: 3px;
}
#score {
font-size: 22px;
margin: 10px;
}
.correct:after {
content: "Rätt";
color: green;
}
.incorrect:after {
content: "Fel";
color: red;
}
#statusbarContainer{
height: 20px; /* Can be anything */
position: relative;
margin: 60px 0 20px 0; /* Just for demo spacing */
background: #555;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
padding: 10px;
-webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
-moz-box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
}
#statusbar {
display: block;
height: 80%;
width:80%;
margin-top:4px;
margin-left:4px;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-bottomleft: 20px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
background-color: orange;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(43,194,83)),
color-stop(1, rgb(84,240,84))
);
content: "";
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background-image:
-webkit-gradient(linear, 0 0, 100% 100%,
color-stop(.25, rgba(255, 255, 255, .2)),
color-stop(.25, transparent), color-stop(.5, transparent),
color-stop(.5, rgba(255, 255, 255, .2)),
color-stop(.75, rgba(255, 255, 255, .2)),
color-stop(.75, transparent), to(transparent)
);
background-image:
-moz-linear-gradient(
-45deg,
rgba(255, 255, 255, .2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, .2) 50%,
rgba(255, 255, 255, .2) 75%,
transparent 75%,
transparent
);
z-index: 1;
-webkit-background-size: 50px 50px;
-moz-background-size: 50px 50px;
-webkit-animation: move 2s linear infinite;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-bottomleft: 20px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
overflow: hidden;
}
background-image: -moz-linear-gradient(
center bottom,
rgb(43,194,83) 37%,
rgb(84,240,84) 69%
);
-webkit-box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
-moz-box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
position: relative;
overflow: hidden;
}
#statusbarText {
text-align: center;
font-size: 24px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div id="wrapper">
<a href="index.html" style="text-decoration:none"><p id="rubrik3" style="font-family:glosors; color:green; text-align:center;">Engelskaglosor</p></a>
<div id="main">
<div id="startContainer">
<button id="start" style="padding:3%; border-radius: 15px; background-color:green; border:0px; color:white; width:200px; font-size:16px;">Starta</button>
</div>
<div id="game">
<div id="word"></div>
<div id="form">
<div>
<form action="javascript:void(null);">
<input type="text" id="answer"/>
</form>
</div>
<div>
<button id="submit" style="padding:3%; border-radius: 15px; background-color:orange; border:0px; color:white; width:200px; font-size:16px;">Rätta!</button>
</div>
</div>
<div id="correctAnswer"></div>
<div id="statusbarText"></div>
<div id="statusbarContainer">
<div id="statusbar">
</div>
</div>
</div>
<div id="result"></div>
</div>
<script>
(function () {
"use strict";
if (!Array.prototype.forEach) {
Array.prototype.forEach = function forEach(callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError("this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0; // Hack to convert O.length to a UInt32
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if ({}.toString.call(callback) !== "[object Function="Function"]") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (Object.prototype.hasOwnProperty.call(O, k)) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 1) {
n = Number(arguments[1]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
}
}
var wordContainer = document.getElementById('word'),
submit = document.getElementById('submit'),
answer = document.getElementById('answer'),
correctAnswer = document.getElementById('correctAnswer'),
startButton = document.getElementById('start'),
game = document.getElementById('game'),
result = document.getElementById('result'),
statusbar = document.getElementById('statusbar'),
statusbarText = document.getElementById('statusbarText'),
currentWord,
rand,
dictionary,
corrected = [],
getRand,
getWord,
correctWord,
startGame,
endGame,
updateStatusbar,
ev;
dictionary = [{
word: 'Leda',
translations: ['Guide']
}, {
word: 'Lobby, entré',
translations: ['Lobby']
}, {
word: 'Ha på sig',
translations: ['Wear']
}, {
word: 'Reception',
translations: ['Desk']
}, {
word: 'Hotell/receptionist',
translations: ['Clerk']
}, {
word: 'Tillåta',
translations: ['Allow']
}, {
word: 'Lova',
translations: ['Promise']
}, {
word: 'Förvånad',
translations: ['Surprised']
}, {
word: 'Fruktansvärd, förfärlig',
translations: ['Terrible']
}, {
word: 'Främling',
translations: ['Stranger']
}, {
word: 'Galna i',
translations: ['Addicted to']
}, {
word: 'Ta hand om',
translations: ['Take care of']
}, {
word: 'Djurskötare',
translations: ['Zoo keeper']
}, {
word: 'Tog allt mindre och mindre hand om',
translations: ['Took less and less care of']
}, {
word: 'Ännu värre',
translations: ['Even worse']
}, {
word: 'Skrika',
translations: ['Scream']
}, {
word: 'Mask',
translations: ['Worm']
}, {
word: 'En god sak',
translations: ['A good cause']
}, {
word: 'Ovanlig',
translations: ['Unusual']
}, {
word: 'Måltid',
translations: ['Meal']
}, {
word: 'Samla, samla in',
translations: ['Collect']
}, {
word: 'Sjukhus',
translations: ['Hospital']
}, {
word: 'Trädgård',
translations: ['Garden']
}, {
word: 'Hälsa',
translations: ['Health']
}, {
word: 'Stam',
translations: ['Tribe']
}, {
word: 'Läcker, utsökt',
translations: ['Delicious']
}, {
word: 'Soldat',
translations: ['Soldier']
}];
getRand = function () {
var len = (dictionary.length - 1);
return Math.floor(Math.random() * len);
};
getWord = function () {
rand = getRand();
answer.value = '';
currentWord = dictionary[rand];
wordContainer.innerHTML = currentWord.word;
updateStatusbar();
};
correctWord = function () {
var input;
if (answer.value === '') {
input = '(tomt)';
} else {
input = answer.value;
}
if (currentWord.translations.indexOf(input.toLowerCase()) !== -1) {
correctAnswer.innerHTML = 'Rätt!';
} else {
correctAnswer.innerHTML = 'Fel! Rätt svar: ' + currentWord.translations.toString();
dictionary[rand].guess = input;
}
corrected.push(dictionary[rand]);
dictionary.splice(rand, 1);
if (dictionary.length !== 0) {
getWord();
} else {
endGame();
}
};
updateStatusbar = (function () {
var total = dictionary.length;
return function () {
statusbarText.innerHTML = corrected.length + ' / ' + total;
statusbar.style.width = (corrected.length * 100 / total) + '%';
}
}());
startGame = function () {
startButton.style.display = 'none';
game.style.display = 'block';
dictionary.forEach(function (obj) {
obj.translations = obj.translations.join("|").toLowerCase().split("|");
});
getWord();
};
endGame = function () {
var correctAmount,
div;
correctAmount = (function () {
var amount = 0;
corrected.forEach(function (obj) {
if (!obj.guess) {
amount += 1;
}
});
return amount;
}());
game.style.display = 'none';
result.style.display = 'block';
div = document.createElement('div');
div.innerHTML = 'Resultat: ' + correctAmount + ' rätt av ' + corrected.length + ' möjliga';
div.id = 'score';
result.appendChild(div);
corrected.forEach(function (obj) {
var div = document.createElement('div'),
markup =
'<div>' +
'<span>' + obj.word + ' - </span>' +
'<span>' + obj.translations.toString() + ' - </span>' +
'<span class="' + (obj.guess ? 'incorrect' : 'correct') + '"></span>' + (obj.guess ? '<span> - Du svarade: ' + obj.guess + '</span>' : '') +
'</div>';
div.innerHTML = markup;
result.appendChild(div);
});
};
ev = function (obj, type, fn) {
if (obj.addEventListener) {
obj.addEventListener(type, fn)
} else {
obj.attachEvent('on' + type, fn)
}
}
ev(submit, 'click', function () {
correctWord();
});
ev(answer, 'keyup', function (e) {
if (e.keyCode === 13) {
correctWord();
return false;
}
});
ev(startButton, 'click', function () {
startGame();
});
}());
</script>
<center><a href="glostestse.html"><button style="padding:2%; border-radius: 15px; background-color:orange; border:0px; color:white; width:200px; font-size:16px; text-align:center; margin-bottom:3%;">Starta om</button></a></center>
</div>
</body>
</html>
Kod 2
<style type="text/css">
#secondary{display:none}
#comments{display:none}
#primary{width:100%}
.entry-meta{display:none}
#glostest {
max-width: 700px;
margin: 100px auto 0;
padding: 20px;
text-align: center;
font-family: sans-serif;
margin-top:-3%;
}
#word {
font-size: 36px;
padding: 10px;
}
#correctAnswer {
padding: 10px;
}
#answer {
padding: 5px;
margin: 5px;
font-size: 16px;
text-align: center;
width: 230px;
}
#game {
display: none;
}
#result .span {
margin: 3px;
}
#score {
font-size: 22px;
margin: 10px;
}
.correct:after {
content: "Rätt";
color: green;
}
.incorrect:after {
content: "Fel";
color: red;
}
#statusbarContainer{
height: 20px; /* Can be anything */
position: relative;
margin: 60px 0 20px 0; /* Just for demo spacing */
background: #555;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
padding: 10px;
-webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
-moz-box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
box-shadow : inset 0 -1px 1px rgba(255,255,255,0.3);
}
#statusbar {
display: block;
height: 80%;
width:80%;
margin-top:4px;
margin-left:4px;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-bottomleft: 20px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
background-color: orange;
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(43,194,83)),
color-stop(1, rgb(84,240,84))
);
content: "";
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background-image:
-webkit-gradient(linear, 0 0, 100% 100%,
color-stop(.25, rgba(255, 255, 255, .2)),
color-stop(.25, transparent), color-stop(.5, transparent),
color-stop(.5, rgba(255, 255, 255, .2)),
color-stop(.75, rgba(255, 255, 255, .2)),
color-stop(.75, transparent), to(transparent)
);
background-image:
-moz-linear-gradient(
-45deg,
rgba(255, 255, 255, .2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, .2) 50%,
rgba(255, 255, 255, .2) 75%,
transparent 75%,
transparent
);
z-index: 1;
-webkit-background-size: 50px 50px;
-moz-background-size: 50px 50px;
-webkit-animation: move 2s linear infinite;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 20px;
-webkit-border-bottom-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-moz-border-radius-bottomleft: 20px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
overflow: hidden;
}
background-image: -moz-linear-gradient(
center bottom,
rgb(43,194,83) 37%,
rgb(84,240,84) 69%
);
-webkit-box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
-moz-box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
position: relative;
overflow: hidden;
}
#statusbarText {
text-align: center;
font-size: 24px;
margin-bottom: 5px;
}
</style>
<div id="glostest">
<div id="startContainer">
<button id="start" style="padding:3%; border-radius: 15px; background-color:green; border:0px; color:white; width:200px; font-size:16px;">Starta</button>
</div>
<div id="game">
<div id="word"></div>
<div id="form">
<div>
<form action="javascript:void(null);">
<input type="text" id="answer"/>
</form>
</div>
<div>
<button id="ratta" style="padding:3%; border-radius: 15px; background-color:orange; border:0px; color:white; width:200px; font-size:16px;">Rätta!</button>
</div>
</div>
<div id="correctAnswer"></div>
<div id="statusbarText"></div>
<div id="statusbarContainer">
<div id="statusbar">
</div>
</div>
</div>
<div id="result"></div>
</div>
<script>
(function () {
"use strict";
if (!Array.prototype.forEach) {
Array.prototype.forEach = function forEach(callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError("this is null or not defined");
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0; // Hack to convert O.length to a UInt32
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if ({}.toString.call(callback) !== "[object Function="Function"]") {
throw new TypeError(callback + " is not a function");
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (thisArg) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (Object.prototype.hasOwnProperty.call(O, k)) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 1) {
n = Number(arguments[1]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
}
}
var wordContainer = document.getElementById('word'),
submit = document.getElementById('ratta'),
answer = document.getElementById('answer'),
correctAnswer = document.getElementById('correctAnswer'),
startButton = document.getElementById('start'),
game = document.getElementById('game'),
result = document.getElementById('result'),
statusbar = document.getElementById('statusbar'),
statusbarText = document.getElementById('statusbarText'),
currentWord,
rand,
dictionary,
corrected = [],
getRand,
getWord,
correctWord,
startGame,
endGame,
updateStatusbar,
ev;
dictionary = [{
word: 'Leda',
translations: ['Guide']
}, {
word: 'Lobby, entré',
translations: ['Lobby']
}, {
word: 'Ha på sig',
translations: ['Wear']
}, {
word: 'Reception',
translations: ['Desk']
}, {
word: 'Hotell/receptionist',
translations: ['Clerk']
}, {
word: 'Tillåta',
translations: ['Allow']
}, {
word: 'Lova',
translations: ['Promise']
}, {
word: 'Förvånad',
translations: ['Surprised']
}, {
word: 'Fruktansvärd, förfärlig',
translations: ['Terrible']
}, {
word: 'Främling',
translations: ['Stranger']
}, {
word: 'Galna i',
translations: ['Addicted to']
}, {
word: 'Ta hand om',
translations: ['Take care of']
}, {
word: 'Djurskötare',
translations: ['Zoo keeper']
}, {
word: 'Tog allt mindre och mindre hand om',
translations: ['Took less and less care of']
}, {
word: 'Ännu värre',
translations: ['Even worse']
}, {
word: 'Skrika',
translations: ['Scream']
}, {
word: 'Mask',
translations: ['Worm']
}, {
word: 'En god sak',
translations: ['A good cause']
}, {
word: 'Ovanlig',
translations: ['Unusual']
}, {
word: 'Måltid',
translations: ['Meal']
}, {
word: 'Samla, samla in',
translations: ['Collect']
}, {
word: 'Sjukhus',
translations: ['Hospital']
}, {
word: 'Trädgård',
translations: ['Garden']
}, {
word: 'Hälsa',
translations: ['Health']
}, {
word: 'Stam',
translations: ['Tribe']
}, {
word: 'Läcker, utsökt',
translations: ['Delicious']
}, {
word: 'Soldat',
translations: ['Soldier']
}];
getRand = function () {
var len = (dictionary.length - 1);
return Math.floor(Math.random() * len);
};
getWord = function () {
rand = getRand();
answer.value = '';
currentWord = dictionary[rand];
wordContainer.innerHTML = currentWord.word;
updateStatusbar();
};
correctWord = function () {
var input;
if (answer.value === '') {
input = '(tomt)';
} else {
input = answer.value;
}
if (currentWord.translations.indexOf(input.toLowerCase()) !== -1) {
correctAnswer.innerHTML = 'Rätt!';
} else {
correctAnswer.innerHTML = 'Fel! Rätt svar: ' + currentWord.translations.toString();
dictionary[rand].guess = input;
}
corrected.push(dictionary[rand]);
dictionary.splice(rand, 1);
if (dictionary.length !== 0) {
getWord();
} else {
endGame();
}
};
updateStatusbar = (function () {
var total = dictionary.length;
return function () {
statusbarText.innerHTML = corrected.length + ' / ' + total;
statusbar.style.width = (corrected.length * 100 / total) + '%';
}
}());
startGame = function () {
startButton.style.display = 'none';
game.style.display = 'block';
dictionary.forEach(function (obj) {
obj.translations = obj.translations.join("|").toLowerCase().split("|");
});
getWord();
};
endGame = function () {
var correctAmount,
div;
correctAmount = (function () {
var amount = 0;
corrected.forEach(function (obj) {
if (!obj.guess) {
amount += 1;
}
});
return amount;
}());
game.style.display = 'none';
result.style.display = 'block';
div = document.createElement('div');
div.innerHTML = 'Resultat: ' + correctAmount + ' rätt av ' + corrected.length + ' möjliga';
div.id = 'score';
result.appendChild(div);
corrected.forEach(function (obj) {
var div = document.createElement('div'),
markup =
'<div>' +
'<span>' + obj.word + ' - </span>' +
'<span>' + obj.translations.toString() + ' - </span>' +
'<span class="' + (obj.guess ? 'incorrect' : 'correct') + '"></span>' + (obj.guess ? '<span> - Du svarade: ' + obj.guess + '</span>' : '') +
'</div>';
div.innerHTML = markup;
result.appendChild(div);
});
};
ev = function (obj, type, fn) {
if (obj.addEventListener) {
obj.addEventListener(type, fn)
} else {
obj.attachEvent('on' + type, fn)
}
}
ev(submit, 'click', function () {
correctWord();
});
ev(answer, 'keyup', function (e) {
if (e.keyCode === 13) {
correctWord();
return false;
}
});
ev(startButton, 'click', function () {
startGame();
});
}());
</script>
<center><a href="glostestse.html"><button style="padding:2%; border-radius: 15px; background-color:orange; border:0px; color:white; width:200px; font-size:16px; text-align:center; margin-bottom:3%;">Starta om</button></a></center>
</div>
Varför använda en dålig attityd? Det är en så onödig sak!
Min hemsida hittar du på tommielag.se