-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcategory_dev.html
69 lines (53 loc) · 1.47 KB
/
category_dev.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
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<title>Category</title>
</head>
<body onload='Body()'>
<h1>Category</h1>
<p id='status'>loading database ...</p>
<p id='results'></p>
<script type="text/javascript" src="database_dev.js">
// import the database
// var database=...
</script>
<script type="text/javascript" src="engine_dev.js">
// import the engine
</script>
<script>
// sort, stably folding upper/lower case
function Sort(array)
{
array.sort(function(a, b) {
var compare = a.toLowerCase().localeCompare(b.toLowerCase());
return compare ? compare : a.localeCompare(b);
});
}
function Body()
{
try {
// load the database
LoadDatabase(database);
document.getElementById("status").innerHTML = "database loaded";
output = [];
// for each unit...
for (var i = 0; i < units.length; i++) {
// for each name...
for (var j = 0; j < units[i].names.length; j++) {
// record the name and categories
Sort(units[i].categories);
output.push("<br>" + units[i].names[j] + " = " + units[i].categories.join(' ') + " ");
}
}
Sort(output);
// display results
document.getElementById("results").innerHTML = output.join(' ');
} catch (error) {
document.getElementById("status").innerHTML = error;
return;
}
}
</script>
</body>
</html>