{{define "title"}}{{.PageTitle}}{{end}}
{{define "content"}}
<div class="container">
    <section class="hero is-info is-bold">
        <div class="hero-body">
            <div class="container">
                <h1 class="title">
                    {{.PageTitle}}
                </h1>
            </div>
        </div>
    </section>

    <div class="block p-4">
        <div class="columns is-centered">
            <div class="column is-half">

                <div class="card" style="width: 100%; max-width: 640px">
                    <header class="card-header has-background-link">
                        <p class="card-header-title has-text-light">
                            <span class="icon"><i class="fa fa-message"></i></span>
                            <span>{{.PageTitle}}</span>
                        </p>
                    </header>
                    <div class="card-content">

                        <!-- No form anymore for logged-out users: too much unsolicited spam. -->
                        {{if not .LoggedIn}}
                            <p class="block">
                                The open "contact us" form is now disabled for logged-out users -
                                we were getting way too much unsolicited spam from drive-by robots
                                that abuse any such open contact form they can find.
                            </p>

                            <p class="block">
                                If you have a {{PrettyTitle}} account, please <a href="/login">log in</a>
                                to it and then you can send a nice message to the website administrators
                                here on this page -- to give us feedback, ideas, criticism, or to report
                                a problem with the website or one of its members.
                            </p>

                            <p class="block">
                                For all outside inquiries, you can contact the website administrators
                                via e-mail. For general questions, send to <strong>support</strong> "at"
                                <strong>nonshy.com</strong> and for more serious stuff we also have a
                                standard <strong>abuse@</strong> inbox on this domain.
                            </p>
                        {{else}}

                        <form action="/contact" method="POST">
                            {{InputCSRF}}
                            <input type="hidden" name="intent" value="{{.Intent}}">
                            <input type="hidden" name="id" value="{{.TableID}}">

                            <p class="block">
                                You may use this form to contact the site administrators to provide
                                feedback, criticism, or to report a problem you have found on the
                                site such as inappropriate content posted by one of our members.
                            </p>

                            <div class="field block">
                                <label for="subject" class="label">Subject</label>
                                <div class="select is-fullwidth">
                                    {{$Subject := .Subject}}
                                    <select name="subject" id="subject"{{if ne $Subject ""}} disabled{{end}}>
                                        {{range .Subjects}}
                                        <optgroup label="{{.Header}}">
                                            {{range .Options}}
                                            <option value="{{.Value}}"{{if eq $Subject .Value}} selected{{end}}>{{.Label}}</option>
                                            {{end}}
                                        </optgroup>
                                        {{end}}
                                    </select>
                                </div>

                                <!-- In case the selectbox is disabled -->
                                {{if ne .Subject ""}}<input type="hidden" name="subject" value="{{.Subject}}">{{end}}
                            </div>

                            <!-- If they are reporting on a TableID and we have a label, show it -->
                            {{if ne .TableLabel ""}}
                            <div class="field block">
                                <label class="label">About</label>
                                <p>{{.TableLabel}}</p>
                            </div>
                            {{end}}

                            <div class="field block">
                                <label for="message" class="label">Message{{if not .MessageRequired}} (optional){{else}} (required){{end}}</label>
                                <textarea class="textarea" cols="80" rows="4"
                                    name="message"
                                    id="message"
                                    placeholder="Message"
                                    {{if .MessageRequired}}required{{end}}>{{.Message}}</textarea>
                                {{if not .MessageRequired}}
                                <p class="help">
                                    Write a description of the problem (optional).
                                </p>
                                {{end}}
                            </div>

                            {{if not .LoggedIn}}
                            <div class="field block">
                                <label for="email" class="label">Reply To (optional)</label>
                                <input type="email" class="input"
                                    name="email" id="email"
                                    placeholder="name@domain.com">
                                <p class="help">
                                    Optional; you are not logged in to an account so you <em>MAY</em> leave us
                                    a reply-to email address if you would like a response to your feedback.
                                </p>
                            </div>
                            {{end}}

                            <!-- "Trap" fields for dumb automated spammer bots -->
                            <div class="field block nonshy-hidden">
                                <label class="label" for="url">Website URL</label>
                                <input type="text" class="input"
                                    name="url" id="url"
                                    value="https://">
                                <p class="help">
                                    Do not touch this field.
                                </p>
                            </div>
                            <div class="field block nonshy-hidden">
                                <label class="label" for="url">Comment</label>
                                <input type="text" class="input"
                                    name="comment" id="comment"
                                    value="">
                                <p class="help">
                                    Do not touch this field.
                                </p>
                            </div>

                            <div class="field has-text-centered">
                                <button type="submit" class="button is-success">
                                    Send Message
                                </button>
                            </div>
                        </form>

                        {{end}}<!-- /if logged in -->

                    </div>
                </div>

            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    window.addEventListener("DOMContentLoaded", (event) => {
        let $file = document.querySelector("#file"),
            $fileName = document.querySelector("#fileName");

        $file.addEventListener("change", function() {
            let file = this.files[0];
            $fileName.innerHTML = file.name;
        });
    });
</script>
{{end}}