-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
142 lines (115 loc) · 4.85 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"></meta>
<meta content="utf-8" http-equiv="encoding"></meta>
<link rel="stylesheet" type="text/css" href="Files/LogikGrid.css"></link>
<script src="Files/jquery-1.11.3.js"></script>
<script src="Files/LogikGrid.js"></script>
<script>
var dimensions = {
total_categories: 4,
category_size: 4
};
var gridobjects = {
grid: null,
controller: null,
view: null
};
$(document).ready(function() {
$("#next").click(function() {
dimensions.total_categories = $("#total_categories").val();
dimensions.category_size = $("#category_size").val();
var data_input_table = $("<table>");
for ( var i = 0 ; i < dimensions.total_categories ; i++ )
{
var row = $("<tr>");
var category_input =
$("<input>")
.attr("type", "text")
.attr("data-category", true)
.attr("data-category-index", i)
.attr("data-entity-index", 0)
.attr("style", "background: yellow; font-weight: bold; width: 150px;");
row.append(category_input);
for ( var j = 0 ; j < dimensions.category_size ; j++ )
{
var entity_input =
$("<input>")
.attr("type", "text")
.attr("data-entity", true)
.attr("data-category-index", i)
.attr("data-entity-index", j)
.attr("style", "width: 150px;");
row.append(entity_input);
}
data_input_table.append(row);
}
$("#data_input_values").html(data_input_table);
$("#data_input").attr("style", "");
});
$("#make_grid").click(function() {
var categories = [];
var category_index = 0;
var entity_index = 0;
var category_name = null;
var entity_name = null;
$("input[data-category='true']").each(function(index, element) {
category_index = $(element).attr("data-category-index");
category_name = $(element).val();
categories[category_index] = {name: category_name, entities: []};
});
$("input[data-entity='true']").each(function(index, element) {
category_index = $(element).attr("data-category-index");
entity_index = $(element).attr("data-entity-index");
entity_name = $(element).val();
categories[category_index].entities[entity_index] = entity_name;
});
gridobjects.grid = new LogikGrid.Grid(categories);
gridobjects.controller = new LogikGrid.GridController(gridobjects.grid);
gridobjects.view = new LogikGrid.GridView(gridobjects.controller);
$("#grid_table_container").html(gridobjects.view.table);
$("#grid").attr("style", "");
});
$("#undo").click(function() { gridobjects.controller.undo(); });
$("#redo").click(function() { gridobjects.controller.redo(); });
});
</script>
</head>
<body>
<div id="dimensions_input">
<table>
<tr>
<td>
Categories:
</td>
<td>
<input id="total_categories" type="number" value="4" />
</td>
</tr>
<tr>
<td>
Category Size
</td>
<td>
<input id="category_size" type="number" value="4" />
</td>
</tr>
</table>
<button id="next">Next</button>
</div>
<div id="data_input" style="display: none">
<div id="data_input_values">
</div>
<button id="make_grid">Make Grid</button>
</div>
<br />
<div id="grid" style="display: none">
<div id="grid_table_container">
</div>
<br />
<button id="undo">Undo</button>
<button id="redo">Redo</button>
</div>
</body>
</html>