/
create.html
58 lines (52 loc) · 1.21 KB
/
create.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
<!DOCTYPE html public>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
$(document).ready(function() {
var width = 160;
var height = 40;
//var width = 10; var height=10;
var table = $("table");
for(var y = 0; y < height; y++) {
var row = $("<tr></tr>").appendTo(table);
for(var x = 0; x < width; x++) {
row.append('<td></td>');
}
}
$("td").click(function() {
$(this).toggleClass('live');
});
$("#export").click(function() {
var content = "";
table.find("tr").each(function() {
$(this).find('td').each(function() {
content += $(this).is('.live') ? 1 : 0;
});
content += "\n";
});
$("textarea").val(content);
});
});
</script>
<style>
table {
border-collapse: collapse;
}
td {
height: 15px;
width: 15px;
border: 1px solid black;
}
td.live {
background: green;
}
</style>
</head>
<body>
<table></table>
<textarea></textarea>
<button id="export">EXPORT</button>
</body>
</html>