-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwitness.html
62 lines (59 loc) · 1.53 KB
/
witness.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
<html>
<head>
<style>
body {
background-color: #FFF;
}
table {
border-spacing: 20px;
}
td {
line-height: 80px;
width: 80px;
}
.off {
background-color: #E6B000;
}
.on {
background-color: #FFF478;
}
</style>
</head>
<body>
<center><table id="grid"></table></center>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var rows = getUrlParameter('rows') || 4;
var cols = getUrlParameter('cols') || 4;
var grid = $('#grid');
for (var i = 0; i < rows; ++i) {
var row = $('<tr/>');
for (var j = 0; j < cols; ++j) {
var cell = $('<td class="off"> </td>');
cell.bind('touchstart', function() {
var cell = $(this);
if (cell.hasClass('off')) {
cell.removeClass('off').addClass('on');
} else {
cell.removeClass('on').addClass('off');
}
});
row.append(cell);
}
grid.append(row);
}
</script>
</body>
</html>