-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
140 lines (120 loc) · 4.79 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" type="text/css" href="css/styles.css"/>
<link href="css/c3.min.css" rel="stylesheet" type="text/css">
<script src="js/tabs.js"></script>
<script src="js/grid.js"></script>
<script src="js/theme.js"></script>
<script src="js/clues.js"></script>
<script src="js/entries.js"></script>
<script src="js/helper_functions.js"></script>
<!--<script src="js/puz.js"></script>-->
<script src="js/jscrossword/jscrossword_combined.js"></script>
<!-- Load d3.js and c3.js -->
<script src="js/d3.v3.min.js" charset="utf-8"></script>
<script src="js/c3.min.js"></script>
<title>Mechapuzzle</title>
</head>
<body onload="init()">
<p>Select a puzzle file to analyze. If the solution is restricted or locked the puzzle must be solved.</p>
<input type="file" id="files" name="files" accept=".puz,.xml,.jpz,.xpz,.ipuz,.cfp"/>
<br/><br/>
<div id="metadata"></div>
<ul id="tabs">
<li><a href="#grid">Grid</a></li>
<li><a href="#theme">Theme</a></li>
<li><a href="#clues">Clues</a></li>
<li><a href="#entries">Entries</a></li>
<li><a href="#rawdata">Rawdata</a></li>
</ul>
<div class="tabContent" id="grid">
<h2>Grid</h2>
<div id="grid_js"></div>
<div id="grid0"></div>
<div id="grid1"></div>
<div id="grid2"></div>
</div>
<div class="tabContent" id="theme">
<h2>Theme</h2>
<div id="theme_js"></div>
<div id="theme0"></div>
<div id="theme1"></div>
<div id="theme2"></div>
</div>
<div class="tabContent" id="clues">
<h2>Clues</h2>
<div id="clues_js"></div>
<div id="clues0"></div>
<div id="clues1"></div>
<div id="clues2"></div>
</div>
<div class="tabContent" id="entries">
<h2>Entries</h2>
<div id="entries_js"></div>
<div id="entries0"></div>
<div id="entries1"></div>
<div id="entries2"></div>
</div>
<div class="tabContent" id="rawdata">
<h2>Rawdata</h2>
<div id="rawdata_js"></div>
<div id="rawdata0"></div>
<div id="rawdata1"></div>
<div id="rawdata2"></div>
</div>
<script type="text/javascript">
function handleFileSelect(evt) {
const files = evt.target.files; // FileList object
// files is a FileList of File objects.
for (let i = 0, f; f = files[i]; i++) {
// Only process small files.
if (f.size >= 75000) {
alert('This file is too big.');
continue;
}
if (f) {
const r = new FileReader();
r.onload = (function (theFile) {
return function (e) {
let contents = e.target.result;
//var elt = document.getElementById('puzjs_output');
//const puzdata = PUZAPP.parsepuz(contents);
var xw_constructor = new JSCrossword();
window.puzdata = xw_constructor.fromData(contents);
// add "theme" to this
window.puzdata.theme = [d3.set(), d3.set()];
// Because it may be a "solved" crossword, replace "solution" with "letter" if applicable
window.puzdata.cells.forEach(function (cell) {
cell.solution = cell.letter || cell.solution;
});
// add the useful "all_entries" with Number / Direction / Clue / Entry
var all_entries = [];
const wordid_to_word = window.puzdata.get_entry_mapping();
window.puzdata.clues.forEach(function(clue_list) {
var direction = clue_list.title;
clue_list.clue.forEach(function(my_clue) {
var num = my_clue['number'];
var clue = my_clue['text'];
var entry = wordid_to_word[my_clue['word']];
all_entries.push({'Number': num, 'Direction': direction, 'Clue': clue, 'Entry': entry});
});
});
window.puzdata.all_entries = all_entries;
console.log(window.puzdata);
render_all();
};
})(f);
r.readAsBinaryString(f);
} else {
alert("Failed to load file");
}
}
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>
</body>
</html>