-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
86 lines (77 loc) · 2.75 KB
/
index.php
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
<!DOCTYPE html>
<head>
<title>Glyph Viewer</title>
<script src="https://cdn.jsdelivr.net/npm/svg-path-commander/dist/svg-path-commander.min.js"></script>
<script src="assets/index.js"></script>
<link rel="stylesheet" href="assets/index.css">
</head>
<body>
<?php
error_reporting(0);
function stdDir($dir) { return trim($dir, '/')."/"; }
function initializeTable(array $iconList, $rootPath, &$table) {
foreach($iconList as $index => $file) {
$isfile = $file[0] != ".";
if($isfile) {
$row = substr($file,0,3); // 3 letter icon row "xxx".
$col = hexdec($file[3]); // Icon column a number from 0 to 16.
$table[$row] ??= array_fill(0,16,"");
$table[$row][$col] = $rootPath.$file;
}
}
}
$config = json_decode(file_get_contents("../manager.conf") ?? "{}", true);
if(!$config) die("{success: 0, error: 1}");
$defaultPath = stdDir($config["default-svg"] ?? "./");
$userPath = stdDir($config["svg-path"] ?? "./");
$iconTable = [];
if($defaultPath && is_dir($defaultPath)) {
initializeTable(scandir($defaultPath), $defaultPath, $iconTable);
}
if($userPath && is_dir($userPath)) {
initializeTable(scandir($userPath), $userPath, $iconTable);
}
ksort($iconTable);
?>
<div id="unicode-table">
<div class="head">
<div class="col"><h1 style="display:inline;margin:0;">Glyph Viewer</h1></div>
<div class="col"><input id="file-dialog" type="file" accept=".svg"></div>
<div class="col">
<label class="button">
<input id="generator" type="button" value="generate"></input>
</label>
</div>
</div>
<div class="grid">
<?php
foreach($iconTable as $rkey => $cols) {
echo "<div class='row'>";
foreach($cols as $ckey => $icon) {
if($icon) {
$isDef = strpos($icon, "default-svg") !== false ? " def" : "";
$base = pathinfo($icon, PATHINFO_FILENAME);
echo "<div class='col$isDef'><img src='$icon' alt='$base'><b class='fix'>F</b><i>$base</i></div>";
} else {
$hex = dechex($ckey);
echo "<div class='col'><b class='add'>$rkey$hex</b></div>";
}
}
echo "</div>";
}
?>
</div>
</div>
<div id="logger"></div>
<div id="cover"></div>
<div id="modal">
<div class="grid">
<div class="row">
<div id="container" class="col"></div>
<div class="vguide">0px</div>
<div class="hguide">0px</div>
</div>
</div>
</div>
</body>
</html>