Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once(__DIR__."/../core.php"); |
| 3 | security::checkType(security::ADMIN, security::METHOD_NOTFOUND); |
| 4 | |
| 5 | if (!isset($_GET["id"])) { |
| 6 | security::notFound(); |
| 7 | } |
| 8 | |
| 9 | $id = (int)$_GET["id"]; |
| 10 | |
| 11 | $c = calendars::get($id); |
| 12 | |
| 13 | if ($c === false) { |
| 14 | security::notFound(); |
| 15 | } |
| 16 | |
| 17 | $details = json_decode($c["details"], true); |
| 18 | $export = array( |
| 19 | "begins" => $c["begins"], |
| 20 | "ends" => $c["ends"], |
| 21 | "calendar" => $details |
| 22 | ); |
| 23 | ?> |
| 24 | |
| 25 | <style> |
| 26 | textarea.code { |
| 27 | width: 100%; |
| 28 | height: 100px; |
| 29 | } |
| 30 | </style> |
| 31 | |
| 32 | <dynscript> |
| 33 | document.querySelector("textarea.code").select(); |
| 34 | |
| 35 | document.getElementById("copy").addEventListener("click", _ => { |
| 36 | navigator.clipboard.writeText(document.querySelector("textarea.code").value).then(_ => { |
| 37 | document.querySelector(".mdl-js-snackbar").MaterialSnackbar.showSnackbar({ |
| 38 | message: "Se ha copiado el texto correctamente.", |
| 39 | timeout: 5000 |
| 40 | }); |
| 41 | }).catch(error => { |
| 42 | document.querySelector(".mdl-js-snackbar").MaterialSnackbar.showSnackbar({ |
| 43 | message: "Ha ocurrido un error copiando el texto. Por favor, cópialo manualmente.", |
| 44 | timeout: 5000 |
| 45 | }); |
| 46 | console.error(error); |
| 47 | }); |
| 48 | }); |
| 49 | </dynscript> |
| 50 | |
| 51 | <h4 class="mdl-dialog__title">Exportar calendario</h4> |
| 52 | <div class="mdl-dialog__content"> |
| 53 | <p>Este es el código que contiene toda la información del calendario y que puedes usar de plantilla más tarde:</p> |
| 54 | <textarea class="code" readonly><?=security::htmlsafe(json_encode($export))?></textarea> |
| 55 | </div> |
| 56 | <div class="mdl-dialog__actions"> |
| 57 | <button data-dyndialog-close class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent cancel">Cerrar</button> |
| 58 | <button id="copy" class="mdl-button mdl-js-button mdl-js-ripple-effect">Copiar</button> |
| 59 | </div> |