<!DOCTYPE html>
<html>
{{template "header"}}

<body onbeforeunload="return leavePage()">
    <div class="ui container">
        {{template "navbar"}}
        <h2 class="ui center aligned header">Update Page</h2>

        <!-- <div class="content-delete-link"> -->
        <!-- Button trigger modal -->
        <!-- <div class="ui segments">
            <div class="ui segment"> -->
        <div class="ui message">
            <button onclick="deletePage();" class="ui red button">
                Delete this content
            </button>
        </div>
        <!-- </div>
        </div> -->
        <!-- </div> -->
        <div class="ui grid">
            <!-- <div class="ui horizontal segments"> -->
            <div class="eleven wide column">
                <div class="ui segment">
                    <h3 class="ui center aligned header">Page</h3>
                    <div class="ui segment">
                        <form class="ui form" method="post" action="/admin/updateContent">
                            <input name="name" type="hidden" value="{{.Cont.Name}}">
                            <textarea id="content-area" name="content">{{.Cont.Text}}</textarea>
                            <br>
                            <div class="field">
                                <label>Name</label>
                                <input name="namedis" type="text" disabled placeholder="Title" value="{{.Cont.Name}}">
                            </div>
                            <br>
                            <div class="field">
                                <label>Published</label>
                                <input name="visible" type="checkbox" {{if .Cont.Visible}} checked {{end}}>
                                </span>
                            </div>
                            <br>
                            <div class="field">
                                <label>Title</label>
                                <input name="title" type="text" placeholder="Title" value="{{.Cont.Title}}" required>
                            </div>
                            <br>
                            <div class="field">
                                <label>Subject</label>
                                <input name="subject" type="text" placeholder="Subject" value="{{.Cont.Subject}}" required>
                            </div>
                            <br>
                            <div class="field">
                                <label>Author</label>
                                <input name="author" type="text" placeholder="Author" value="{{.Cont.Author}}">
                            </div>
                            <br>
                            <div class="field">
                                <label>Key Words</label>
                                <input name="metaKeyWords" type="text"
                                    placeholder="Meta Key Words. Example: books, music" value="{{.Cont.MetaKeyWords}}">
                            </div>
                            <br>
                            <div class="field">
                                <label>Description</label>
                                <textarea name="desc" rows="3" placeholder="Description">{{.Cont.MetaDesc}}</textarea>
                            </div>
                            <br>
                            <div class="field">
                                <label>Blog Post</label>
                                <input name="blogpost" type="checkbox" {{if .Cont.BlogPost}} checked {{end}}>
                                </span>
                            </div>
                            <br>
                            <div class="field">
                                <label>Archived</label>
                                <input name="archived" type="checkbox" {{if .Cont.Archived}} checked {{end}}>
                                </span>
                            </div>
                            <br>
                            <!-- <div class="form-submit"> -->
                            <button onclick="savePage();" class="ui primary button" type="submit">Submit</button>
                            <!-- </div> -->
                            <br>
                        </form>
                    </div>
                </div>
            </div>
            <div class="five wide column">
                <div class="ui segment">
                    <h3 class="ui center aligned header">Images</h3>
                    <!-- <div class="ui segment"> -->
                    <!-- <div class="image-wrapper"> -->
                    {{range .Img}}
                    <div class="ui segment">
                        <!-- <div class="card"> -->
                        <h5 class="ui header">Name: {{.Name}}</h5>
                        <h5 class="ui header">Link: {{.ImageURL}}</h5>
                        <!-- <div class="ui segment">Name: {{.Name}}</div>
                            <div class="ui segment">Link: {{.ImageURL}}</div> -->
                        <img class="ui small image" src="{{.ImageURL}}">
                        <!-- <div class="ui segment">
                                    <div class="image-view">
                                        <img id="img1" src="{{.ImageURL}}" />
                                    </div>
                                </div> -->
                        <!-- </div> -->
                    </div>
                    {{end}}
                    <!-- </div> -->
                    <!-- </div> -->
                </div>
            </div>
            <!-- </div> -->
        </div>
    </div>
    <br>

    <!-- Modal -->
    <div class="ui basic modal">
        <div class="ui icon header">
            <i class="delete icon"></i>
            Delete This Page?
        </div>
        <div class="content">
            <p>Do you want to delete this page completely?</p>
        </div>
        <div class="actions">
            <div class="ui basic cancel inverted button">
                <i class="remove icon"></i>
                No
            </div>
            <div onclick="location.href='/admin/deleteContent/{{.Cont.Name}}'" class="ui red ok inverted button">
                <i class="checkmark icon"></i>
                Yes
            </div>
        </div>
    </div>   
</body>
<br>
{{template "footer"}}

</html>