123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" integrity="sha256-siyOpF/pBWUPgIcQi17TLBkjvNgNQArcmwJB8YvkAgg=" crossorigin="anonymous" />
- <link href="{{ static_url }}/tagsinput/tagsinput.css" rel="stylesheet" type="text/css">
- <title>{{ name|title }} form</title>
- </head>
- <body>
- <div class="container">
- <div class="card">
- <form>
- {# Schema modal #}
- <div class="card-header">
- <div class="row">
- <div class="col">
- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#schemaModal">
- YAML schema 🔗
- </button>
- </div>
- <div class="modal fade" id="schemaModal" tabindex="-1" role="dialog">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">YAML schema</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <pre class="prettyprint">
- {{ schema|e }}
- </pre>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- {# Main content #}
- <div class="card-body">
- {{ contents }}
- </div>
- <div class="card-footer">
- <button type="submit" class="btn btn-primary" onclick="return submitForm()">Get Code</button>
- <div class="modal fade" id="yaml-modal" tabindex="-1" role="dialog" aria-labelledby="modal-label" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="modal-label">Add Code</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- <form>
- <div class="form-group">
- <textarea class="form-control" id="add-game-yaml-body" style="font-family:monospace;" rows="10">...</textarea>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- <button type="button" class="btn btn-primary" onclick="copy()">Copy</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>
- <script
- src="https://code.jquery.com/jquery-3.4.1.min.js"
- integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
- crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.serializeJSON/2.9.0/jquery.serializejson.js" integrity="sha256-UzGjnR1p5Tnl9uHyGcbtthS4cULTf5z28PXVxHVElSQ=" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js" integrity="sha256-ry6nlLQ1JmRl5RUPQ4eSuaSp/rGNPvl144WHHs7BiNE=" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/1.0.5/jquery.csv.min.js" integrity="sha256-zGo0JbZ5Sn6wU76MyVL0TrUZUq5GLXaFnMQCe/hSwVI=" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js" integrity="sha256-bqVeqGdJ7h/lYPq6xrPv/YGzMEb6dNxlfiTUHSgRCp8=" crossorigin="anonymous"></script>
- <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
- <script src="{{ static_url }}/tagsinput/tagsinput.js"></script>
- <script src="{{ static_url }}/main.js"></script>
- <script>
- const getFormId = (keys) => (
- keys.map(key => `[${key}]`).join('')
- );
- const setFormValue = (keys, value) => {
- const formId = getFormId(keys);
- if (typeof value === 'object') {
- if (value.constructor === Array) {
- for (const childValue of value) {
- // Checkboxes
- $(document.getElementById(`${formId}.${childValue}`)).prop('checked', true);
- // Tagsinput
- $(document.getElementById(formId)).tagsinput('add', childValue);
- }
- } else {
- for (const [childKey, childValue] of Object.entries(value)) {
- setFormValue([...keys, childKey], childValue);
- }
- }
- } else {
- // Radio
- $(document.getElementById(`${formId}.${value}`)).prop('checked', true);
- // Fill normal inputs
- $(document.getElementById(formId)).val(value);
- }
- };
- $(document).ready(() => {
- $('[data-toggle="tooltip"]').tooltip()
- // Load data from params if provided
- const params = new URL(window.location.href).searchParams;
- const dataUrl = params.get('data');
- if (dataUrl) {
- $.get(dataUrl, (data) => {
- setFormValue([], data);
- document.title = `Edit ${data.name} form`;
- });
- }
- const original = params.get('original');
- if (original) {
- setFormValue([], {'originals': [original]});
- }
- // Set dark theme from setting in main site
- const THEME_KEY = 'theme';
- if (localStorage.getItem(THEME_KEY) === 'dark') {
- $("html").attr("data-bs-theme", "dark");
- } else if (localStorage.getItem(THEME_KEY) === 'light') {
- } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
- $("html").attr("data-bs-theme", "dark");
- }
- });
- </script>
- </body>
- </html>
|