html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html>
<head>
<title>the knight challenge</title>
</head>
<body>
<h1>Hello!</h1>
<h2>I'm <span id="alb">Alberto</span> and this is the <span id="knight">Knight</span> Challenge!</h2>
<p>Click the cells and if you like it, pls rate it!!!</p>
<table id="board">
<tr>
<td id="a1" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a2" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a3" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a4" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a5" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a6" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a7" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="a8" onClick="Javascript: horse(this.getAttribute('id'))"></td>
</tr>
<tr>
<td id="b1" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="b2" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="b3" onClick="Javascript: horse(this.getAttribute('id'))"></td>
<td id="b4" onClick="Javascript: horse(this.getAttribute('id'))"></td>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
@import url('https://fonts.googleapis.com/css?family=Gamja+Flower');
h1,h2,p{ color: white; margin:0;}
p{
color: white;
font-size:20px;
font-weight:normal;
}
h1{
color: white;
font-size:40px;
font-weight:normal;
}
h2{
color: white;
font-size:30px;
font-weight:normal;
}
#alb{color: #FFFAEB ;}
#knight{color: #F0F0D8;}
label, input, #result {
width: 250px;
clear: both;
float: none;
display: block;
margin: 30px auto;
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var letters = ["a","b","c","d","e","f","g","h"];
function horse(val){
var reds = document.getElementsByClassName("red");
while (reds.length) reds[0].className = reds[0].className.replace(/\bred\b/g, "");
var blues = document.getElementsByClassName("blue");
while (blues.length) blues[0].className = blues[0].className.replace(/\bblue\b/g, "");
var letter = val.substr(0,1);
var number = parseInt(val.substr(1,1));
var result = document.getElementById("result");
display(letter+number,1);
//nord
var n = number+2;
var l = nextChar(letter, -1);
if( condition(l,n)){ display(l+n); } l = nextChar(letter, 1);
if( condition(l,n)){ display(l+n); }
//sud
n = number-2;
l = nextChar(letter, -1);
if( condition(l,n)){ display(l+n); } l = nextChar(letter, 1);
if( condition(l,n)){ display(l+n); }
//ovest
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run