Allow some adjustments to the public view using URL arguments for embedding

This commit is contained in:
Skylar Ittner 2020-04-07 15:11:54 -06:00
parent 3c15438925
commit d418681d49

View File

@ -19,6 +19,19 @@ require_once __DIR__ . "/../lib/required_public.php";
<link href="../static/css/material-color/material-color.min.css" rel="stylesheet"> <link href="../static/css/material-color/material-color.min.css" rel="stylesheet">
<link href="../static/css/fontawesome-all.min.css" rel="stylesheet"> <link href="../static/css/fontawesome-all.min.css" rel="stylesheet">
<?php
// Allow setting the page background to match the style of a parent frame
if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_match("/^[a-z0-9#\-]+$/i", $_GET["backgroundcolor"])) {
?>
<style>
html,body {
background-color: <?php echo $_GET["backgroundcolor"]; ?>
}
</style>
<?php
}
?>
<div class="container mt-4"> <div class="container mt-4">
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-12 col-md-8"> <div class="col-12 col-md-8">
@ -51,7 +64,7 @@ require_once __DIR__ . "/../lib/required_public.php";
<?php <?php
} else { } else {
if (Machine::exists($_GET["id"])) { if (Machine::exists($_GET["id"])) {
$machine = new Machine($_GET['id']); $machine = new Machine($_GET['id']);
} else { } else {
$machine = new Machine(Machine::getIDFromSerial($_GET['id'])); $machine = new Machine(Machine::getIDFromSerial($_GET['id']));
} }
@ -224,16 +237,17 @@ require_once __DIR__ . "/../lib/required_public.php";
?> ?>
</div> </div>
</div> </div>
<?php /* Hide this box if we're embedded in another page */ if (!defined($_GET["embed"])) { ?>
<div class="card-body"> <div class="card-body">
<p> <p>
Look up another machine: Look up another machine:
</p> </p>
<form method="GET"> <form method="GET">
<input type="text" name="id" class="form-control" placeholder="Machine ID Number" required /> <input type="text" name="id" class="form-control" placeholder="Machine ID Number" required />
<button type="submit" class="btn btn-primary btn-block mt-2">Get Info</button> <button type="submit" class="btn btn-primary btn-block mt-2">Get Info</button>
</form> </form>
</div> </div>
<?php } ?>
</div> </div>
<?php <?php
} }