-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
76 lines (70 loc) · 3.44 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!--
Copyright 2016 Javier Junquera Sánchez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
-->
<html lang="es">
<head>
<link rel="stylesheet" type="text/css" href="resources/css/default.css">
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="resources/js/sudoku.js"></script>
<script type="text/javascript">
var init = function(){
document.addEventListener('keydown', function(event) {
$('#kp').text(event.keyCode);
});
var juego = $('#juego');
for(var i = 0; i < 3; i++){
for(var j = 0; j < 3; j++){
var bloque = $('<span class="bloque square">');
for(var k = 0; k < 3; k++){
for(var l = 0; l < 3; l++){
// casilla + 3 * bloque + 9 * linea + 27 * fila
var numero = l + 3 * j + 9 * k + 27 * i;
var casilla = $('<input class="cell little-square" id="' + numero + '" type="number" min="0" max="9" value="0">');
bloque.append(casilla);
}
}
juego.append(bloque);
}
}
}
function resolver(){
var tiempo = new Date().getTime();
main();
$('#t').text(imprimeTiempo(new Date().getTime() - tiempo));
}
function limpiar(){
limpia();
$('#t').text('');
}
function imprimeTiempo(tiempo){
// Hours part from the timestamp
var hours = parseInt(tiempo / (1000 * 60 * 60));
// Minutes part from the timestamp
var minutes = "0" + parseInt(tiempo/ (1000 * 60) - hours*60);
// Seconds part from the timestamp
var seconds = "0" + parseInt(tiempo/ (1000) - minutes*60);
// Will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
return formattedTime;
}
$(document).ready(init);
</script>
</head>
<body>
<h1>Sudoku solver</h1>
<div id="juego"></div>
<div id="menu">
<button id="solve" onclick="resolver()">Resolver</button>
<button id="clear" onclick="limpiar()">Limpiar</button>
</div>
</body>
</html>