diff options
Diffstat (limited to 'includes/titlebar.inc')
-rw-r--r-- | includes/titlebar.inc | 476 |
1 files changed, 465 insertions, 11 deletions
diff --git a/includes/titlebar.inc b/includes/titlebar.inc index de58549..5166f08 100644 --- a/includes/titlebar.inc +++ b/includes/titlebar.inc @@ -1,7 +1,10 @@ -<?php global $toplevel; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); ?> +<?php global $toplevel; global $system; global $isLoggedIn; $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pages.json"), true); ?> <span> <?php +$membersNames = array_map(function ($i) { + return $i["name"]; +}, scoreOrderGlobal()); $parts = explode("/", $_GET['_']); $name = $toplevel === "" ? "home" : $toplevel; @@ -11,13 +14,15 @@ $part2 = null; $part3 = null; if (isset($pages[$name])) { - if (($name === "docs" || $name === "toys" || $name === "actions") && isset($parts[2])) { + if (($name === "docs" || $name === "toys" || $name === "actions" || $name === "computers") && isset($parts[2])) { $part3 = "<a class='title-bar-backlink' href='/-/dashboard'>Dashboard</a>"; $part2 = "<a class='title-bar-backlink' href='/-/$name'>" . $pages[$name]['name'] . "</a>"; if ($name === "docs") { $actionsProfile = "docs-item"; $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $parts[2] . ".json"), true)["name"]; + } elseif ($name === "computers") { + $part1 = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/computers/metadata/" . $parts[2] . ".json"), true)["host"]; } else { $actionsProfile = "$name-item"; $list = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . ($name === "toys" ? "toys/toys" : "actions/actions") . ".json"), true); @@ -104,6 +109,13 @@ if ($actionsProfile === "default") { $actionsProfile = "docs"; break; + case "edit": + case "edit-private": + if (count($parts) === 3) $actionsProfile = "editor-system"; + if (count($parts) > 3 && in_array($parts[3], $membersNames)) $actionsProfile = "editor-member"; + if (count($parts) > 3 && !in_array($parts[3], $membersNames)) $actionsProfile = "editor-subsystem"; + break; + case "debug": $actionsProfile = "debug"; break; @@ -112,13 +124,14 @@ if ($actionsProfile === "default") { $actionsProfile = "bitset"; break; - case "parser": - case "prefix": - $actionsProfile = "parser-prefix"; + case "computers": + if (count($parts) === 3) $actionsProfile = "computers"; + if (count($parts) === 4) $actionsProfile = "computers-remote"; break; } } +echo("<span id='title-bar-parts-desktop''>"); if (isset($part3)) { echo "$part3 > $part2 > <b>$part1</b>"; } elseif (isset($part2)) { @@ -126,6 +139,10 @@ if (isset($part3)) { } else { echo "<b>$part1</b>"; } +echo("</span>"); +echo("<span id='title-bar-parts-mobile' style='display:none;'>"); +echo "<b>$part1</b>"; +echo("</span>"); $links = [ "default" => [ @@ -138,18 +155,455 @@ $links = [ "icon" => "/assets/icons/up.svg", "invert" => true ] + ], + "computers" => [ + [ + "name" => "Remote control", + "link" => [ + "type" => "url", + "text" => "/-/computers/" . ($parts[2] ?? null) . "/control" + ], + "icon" => "/assets/icons/computers-remote.svg", + "invert" => true + ], + [ + "name" => "Screens", + "link" => [ + "type" => "url", + "text" => "#screens" + ], + "icon" => "/assets/icons/computers-screens.svg", + "invert" => true + ], + [ + "name" => "Windows", + "link" => [ + "type" => "url", + "text" => "#windows" + ], + "icon" => "/assets/icons/computers-windows.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "computers-remote" => [ + [ + "name" => "Enable controlling", + "link" => [ + "type" => "js", + "text" => "enableControl();" + ], + "icon" => "/assets/icons/computers-on.svg", + "invert" => true + ], + [ + "name" => "Disable controlling", + "link" => [ + "type" => "js", + "text" => "disableControl();" + ], + "icon" => "/assets/icons/computers-off.svg", + "invert" => true + ], + [ + "name" => "Back to computer info", + "link" => [ + "type" => "url", + "text" => "/-/computers/" . ($parts[2] ?? null) + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "editor-member" => [ + [ + "name" => "View page", + "link" => [ + "type" => "url", + "text" => "/" . ($parts[3] ?? null) + ], + "icon" => "/assets/icons/view.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "editor-system" => [ + [ + "name" => "View page", + "link" => [ + "type" => "url", + "text" => "/" . ($parts[2] ?? null) + ], + "icon" => "/assets/icons/view.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "editor-subsystem" => [ + [ + "name" => "View page", + "link" => [ + "type" => "url", + "text" => "/" . ($parts[2] ?? null) . "/-/subsystem" . ($parts[3] ?? null) + ], + "icon" => "/assets/icons/view.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "member" => [ + [ + "name" => "System", + "link" => [ + "type" => "url", + "text" => "/$system" + ], + "icon" => "/assets/icons/parent.svg", + "invert" => true + ], + [ + "name" => $pages["edit-private"]["name"], + "link" => [ + "type" => "url", + "text" => "/-/edit-private/$system/$name" + ], + "icon" => "/assets/icons/edit-private.svg", + "invert" => true, + "show" => $isLoggedIn + ], + [ + "name" => $pages["edit"]["name"], + "link" => [ + "type" => "url", + "text" => "/-/edit/$system/$name" + ], + "icon" => "/assets/icons/edit.svg", + "invert" => true, + "show" => $isLoggedIn + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "subsystem" => [ + [ + "name" => "Parent system", + "link" => [ + "type" => "url", + "text" => "/$parts[0]" + ], + "icon" => "/assets/icons/parent.svg", + "invert" => true + ], + [ + "name" => $pages["edit"]["name"], + "link" => [ + "type" => "url", + "text" => "/-/edit/$system/" . ($parts[3] ?? null) + ], + "icon" => "/assets/icons/edit.svg", + "invert" => true, + "show" => $isLoggedIn + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "home" => [ + [ + "name" => "Cloudburst System", + "link" => [ + "type" => "url", + "text" => "/cloudburst" + ], + "icon" => "/assets/avatars/ade46823206b4b0cad3ccaae934a5f3b.webp", + "invert" => false + ], + [ + "name" => "Raindrops System", + "link" => [ + "type" => "url", + "text" => "/raindrops" + ], + "icon" => "/assets/avatars/7d9f543ef74240f69d0786c3f2983124.webp", + "invert" => false + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "planner" => [ + [ + "name" => "Add in the Cloudburst System", + "link" => [ + "type" => "js", + "text" => "document.getElementById('planner-add-link-cloudburst-0').click()" + ], + "icon" => "https://static.equestria.horse/ponies/icons/add-cloudburst.svg", + "invert" => false + ], + [ + "name" => "Add in the Raindrops System", + "link" => [ + "type" => "js", + "text" => "document.getElementById('planner-add-link-raindrops-0').click()" + ], + "icon" => "https://static.equestria.horse/ponies/icons/add-raindrops.svg", + "invert" => false + ] + ], + "actions-or-toys" => [ + [ + "name" => "Search", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0; document.getElementById('search').focus();" + ], + "icon" => "/assets/icons/search.svg", + "invert" => true + ], + [ + "name" => "Add", + "link" => [ + "type" => "js", + "text" => "(new bootstrap.Modal(document.getElementById('creator'))).show(); setInterval(() => { document.getElementById('creator-title').focus(); }, 500);" + ], + "icon" => "/assets/icons/add.svg", + "invert" => true + ] + ], + "docs" => [ + [ + "name" => "Marked for deletion", + "link" => [ + "type" => "url", + "text" => "#deletable" + ], + "icon" => "/assets/icons/delete.svg", + "invert" => true + ], + [ + "name" => "Create new", + "link" => [ + "type" => "url", + "text" => "/-/docs/add" + ], + "icon" => "/assets/icons/add.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "docs-item" => [ + [ + "name" => "Save", + "link" => [ + "type" => "js", + "text" => "save();" + ], + "icon" => "/assets/icons/save.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "debug" => [ + [ + "name" => "Reported failures", + "link" => [ + "type" => "url", + "text" => "#failures" + ], + "icon" => "/assets/icons/failures.svg", + "invert" => true + ], + [ + "name" => "Processing times", + "link" => [ + "type" => "url", + "text" => "#times" + ], + "icon" => "/assets/icons/time.svg", + "invert" => true + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] + ], + "bitset" => [ + [ + "name" => "Copy bitset", + "link" => [ + "type" => "js", + "text" => "navigator.clipboard.writeText(document.getElementById('input').value);" + ], + "icon" => "/assets/icons/copy.svg", + "invert" => true + ], + [ + "name" => "Reset", + "link" => [ + "type" => "js", + "text" => "document.getElementById('input').value = '2048'; calculateInput();" + ], + "icon" => "/assets/icons/reset.svg", + "invert" => true + ] + ], + "alert" => [ + [ + "name" => "Turn alert on", + "link" => [ + "type" => "js", + "text" => "if (document.getElementById('btn-on').style.display === 'block') (new bootstrap.Modal(document.getElementById('turn-on'))).show();" + ], + "icon" => "/assets/icons/alert-on.svg", + "invert" => true + ], + [ + "name" => "Turn alert off", + "link" => [ + "type" => "js", + "text" => "if (document.getElementById('btn-off').style.display === 'block') (new bootstrap.Modal(document.getElementById('turn-off'))).show();" + ], + "icon" => "/assets/icons/alert-off.svg", + "invert" => true + ] + ], + "system" => [ + [ + "name" => $pages["s:history"]["name"], + "link" => [ + "type" => "url", + "text" => "/$name/-/history" + ], + "icon" => "/assets/icons/history.svg", + "invert" => true + ], + [ + "name" => $pages["s:compare"]["name"], + "link" => [ + "type" => "url", + "text" => "/$name/-/compare" + ], + "icon" => "/assets/icons/compare.svg", + "invert" => true + ], + [ + "name" => $pages["s:tree"]["name"], + "link" => [ + "type" => "url", + "text" => "/$name/-/tree" + ], + "icon" => "/assets/icons/tree.svg", + "invert" => true + ], + [ + "name" => $pages["s:species"]["name"], + "link" => [ + "type" => "url", + "text" => "/$name/-/species" + ], + "icon" => "/assets/icons/species.svg", + "invert" => true + ], + [ + "name" => $pages["edit"]["name"], + "link" => [ + "type" => "url", + "text" => "/-/edit/$name" + ], + "icon" => "/assets/icons/edit.svg", + "invert" => true, + "show" => $isLoggedIn + ], + [ + "name" => "Go back to top", + "link" => [ + "type" => "js", + "text" => "document.body.scrollTop = 0; document.documentElement.scrollTop = 0;" + ], + "icon" => "/assets/icons/up.svg", + "invert" => true + ] ] ]; $linksList = $links[isset($links[$actionsProfile]) ? $actionsProfile : "default"]; -?> (<code><?= $actionsProfile ?></code>)<!--<pre><?php var_dump($parts); ?></pre>--> +?><!-- (<code><?= $actionsProfile ?></code>)--><!--<pre><?php var_dump($parts); ?></pre>--> <span id="title-bar-actions"> - <?php foreach ($linksList as $index => $link): ?> - <a style="display: inline-block; padding: 4px;" id="title-bar-action-<?= $index ?>" <?php if ($link["link"]["type"] === "url"): ?>href<?php else: ?>onclick<?php endif; ?>="<?= $link["link"]["text"] ?>" title="<?= $link["name"] ?>" data-bs-toggle="tooltip" class="title-bar-action tooltip-nohelp"> - <img src="<?= $link["icon"] ?>" <?php if ($link["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"> - </a> - <?php endforeach; ?> + <?php foreach ($linksList as $index => $link): if (!(isset($link["show"]) && !$link["show"])): ?><a style="display: inline-block; padding: 4px;" id="title-bar-action-<?= $index ?>" <?php if ($link["link"]["type"] === "url"): ?>href<?php else: ?>onclick<?php endif; ?>="<?= $link["link"]["text"] ?>" title="<?= $link["name"] ?>" data-bs-toggle="tooltip" class="title-bar-action tooltip-nohelp"><img src="<?= $link["icon"] ?>" <?php if ($link["invert"]): ?>class="dropdown-icon"<?php endif; ?> alt="" style="width:24px;vertical-align: middle;"></a><?php endif; endforeach; ?> </span> </span> |