-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_monster_table_html.py
100 lines (80 loc) · 2.37 KB
/
generate_monster_table_html.py
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
import json
indexHtml = '''
<!DOCTYPE html>
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<title>MapleStory Monster Table</title>
</head>
<body>
<table id="monsters" width="90%%" align="center">
<thead>
<tr>
<th>Name</th>
<th>Level</th>
<th>HP</th>
<th>MP</th>
<th>PDR (%)</th>
<th>MDR (%)</th>
<th>Note</th>
</tr>
</thead>
<tbody>
%s
</tbody>
</table>
<script src="js/jquery-lazyload/jquery.lazyload.js"></script>
<script type="text/javascript" charset="utf-8">
$(window).ready(function() {
$("img.lazy").lazyload({
effect : "fadeIn"
});
});
</script>
<script src="js/tablefilter/tablefilter.js"></script>
<script data-config>
var filtersConfig = {
base_path: 'js/tablefilter/',
paging: {
results_per_page: ['Records: ', [10, 25, 50, 100]]
},
alternate_rows: true,
rows_counter: {
text: 'Monsters: '
},
col_types: [
'string', 'number', 'number',
'number', 'number', 'number',
'string'
],
btn_reset: true,
auto_filter: true,
auto_filter_delay: 1000, //milliseconds
loader: true,
status_bar: true,
mark_active_columns: true,
highlight_keywords: true,
extensions:[{ name: 'sort' }]
};
var tf = new TableFilter('monsters', filtersConfig);
tf.init();
</script>
</body>
</html>
'''
if __name__ == '__main__':
# generate
with open('monster.json', 'r') as fin, open('index.html','w') as fout:
tableLines = []
for line in fin:
data = json.loads(line)
tableLines.append('<tr><td>%s<br/><img class="lazy" data-original="https:%s" width="100"></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>'%(
data['monName'],data['monImg'],
data['monLvl'],data['monHP'],
data['monMP'],data['monPDR'],
data['monMDR'],data['monEXP'],
))
fout.write(indexHtml%('\n'.join(tableLines)).encode('utf-8'))