-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatelist.php
More file actions
170 lines (143 loc) · 4.8 KB
/
createlist.php
File metadata and controls
170 lines (143 loc) · 4.8 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
$filename = glob('m5stack-*/boards.txt');
$file = file_get_contents($filename[0]);
$lines = explode("\n", $file);
$list = array();
foreach ($lines as $line) {
$line = trim($line);
if ($line == "") {
continue;
}
$temp = explode("=", $line);
if (count($temp) == 2) {
// =
$temp2 = explode(".", $temp[0]);
$item = &$list;
for ($i = 0; $i < (count($temp2) - 1); $i++) {
$item = &$item[$temp2[$i]];
if (!is_array($item)) {
$item = array();
}
}
$name = $temp2[count($temp2) - 1];
$item[$name]['value'] = $temp[1];
}
}
$titleList = array();
$dataList = array();
foreach ($list as $name => $item) {
if ($name == 'menu') {
continue;
}
foreach ($item as $name2 => $item2) {
if ($name2 != 'menu') {
if (isset($item2['value'])) {
$titleList[$name2] = $name2;
$dataList[$name][$name2] = $item2['value'];
}
foreach ($item2 as $name3 => $item3) {
if (isset($item3['value'])) {
$titleList[$name2 . '/' . $name3] = $name2 . '/' . $name3;
$dataList[$name][$name2 . '/' . $name3] = $item3['value'];
}
}
} else {
// menu
foreach ($item2 as $name3 => $item3) {
$titleList[$name2 . '/' . $name3] = $name2 . '/' . $name3;
$dataList[$name][$name2 . '/' . $name3] = current($item3)['value'];
}
}
}
}
ksort($titleList);
$titlelist2 = array();
$titlelist2['name'] = 'name';
$titlelist2['vid/0'] = 'vid/0';
$titlelist2['pid/0'] = 'pid/0';
$titleList = array_merge($titlelist2, $titleList);
$html = <<<END
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>M5Stack Board List</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.0/js/jquery.tablesorter.combined.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.0/css/theme.default.min.css">
<script>
$(document).ready(function() {
$('table').tablesorter({
widthFixed: true,
widgets: ['zebra', 'columns', 'filter', 'pager', 'resizable', 'stickyHeaders']
});
});
</script>
</head>
<body>
<h1>M5Stack Board List</h1>
<table>
END;
$html .= " <thead><tr>";
$html .= '<th>config</th>';
foreach ($dataList as $data) {
$html .= '<th>' . $data['name'] . '</th>';
}
$html .= "</tr></thead>\n";
foreach ($titleList as $name => $item) {
$html .= " <tr>";
$html .= '<th>' . $name . "</th>";
foreach ($dataList as $data) {
$html .= '<td>' . @$data[$name] . "</td>";
}
$html .= "</tr>\n";
}
$html .= <<<END
</table>
</body>
</html>
END;
file_put_contents('board.html', $html);
// 縦横違い
$html = <<<END
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>M5Stack Board List2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.0/js/jquery.tablesorter.combined.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.0/css/theme.default.min.css">
<script>
$(document).ready(function() {
$('table').tablesorter({
widthFixed: true,
widgets: ['zebra', 'columns', 'filter', 'pager', 'resizable', 'stickyHeaders']
});
});
</script>
</head>
<body>
<h1>EM5Stack Board List2</h1>
<table>
END;
$html .= " <thead><tr>";
foreach ($titleList as $data) {
$html .= '<th>' . $data . '</th>';
}
$html .= "</tr></thead>\n";
foreach ($dataList as $name => $data) {
$html .= " <tr>";
foreach ($titleList as $title) {
$html .= '<td>' . @$data[$title] . "</td>";
}
$html .= "</tr>\n";
}
$html .= <<<END
</table>
</body>
</html>
END;
file_put_contents('board2.html', $html);