{{define "title"}}Torrent Edit{{end}}
{{define "content"}}
  <div class="box results">
  <h3 id="torrents">{{ call $.T "torrent_edit_panel" }}</h3>
  {{with .Form}}
  <form style="text-align:left;padding-left:10px;padding-right:10px;" enctype="multipart/form-data" role="upload" method="POST">
        {{ block "csrf_field" $ }}{{end}}
		{{ range (index $.FormInfos "infos")}}
			<p class="success-text">{{ . }}</p>
		{{end}}
		{{ range (index $.FormErrors "errors")}}
			<p class="error-text">{{ . }}</p>
		{{end}}
      <div class="form-group">
      <label class="input-label" for="name">{{call $.T "name"}}</label>
          <input type="text" name="name" class="form-input up-input" placeholder="{{call $.T "file_name"}}" value="{{.Name}}" required>
      </div>
      <div class="form-group">
          <label for="c">{{call $.T "category"}}</label>
          <select name="c" class="form-input up-input">
              <option value="">{{call $.T "select_a_torrent_category"}}</option>
              {{ range $name_cat, $id_cat := (GetCategories false) }}
              <option value="{{ $id_cat }}" {{if eq $.Form.Category $id_cat }}selected{{end}}>{{call $.T $name_cat }}</option>
              {{ end }}
          </select>
      </div>
      <div class="form-group">
          <input type="checkbox" name="remake" id="remake" {{ if .Remake }}checked{{end}}>
          <label for="remake">{{call $.T "mark_as_remake"}}</label>
      </div>
		{{ if $.User }}
		<p>
			<input type="checkbox" name="hidden" id="hidden" {{ if .Hidden }}checked{{end}}>
			<label for="hidden">{{call $.T "mark_as_hidden"}}</label>
		</p>
		{{ end }}
      <div class="form-group">
          <label class="input-label" for="website_link">{{call $.T "website_link"}}</label>
          <input name="website_link" id="website_link" class="form-input up-input" type="text" value="{{.WebsiteLink}}">
      </div>
      <div class="form-group">
          <label for="desc">{{call $.T "torrent_description"}}</label>
          <p class="help-block">{{call $.T "description_markdown_notice"}}</p>
          <textarea style="height: 10rem;" name="desc" class="form-input up-input" rows="10">{{.Description}}</textarea>
      </div>
      <button type="submit" class="form-input up-input">{{call $.T "save_changes"}}</button>
      <br>
      <br>
  </form>
{{end}}
</div>
{{end}}
{{define "js_footer"}}
  <script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/uploadPage.js"}}"></script>
  <script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/markdown.js/0.5.0/markdown.min.js"></script>
  <script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/to-markdown/3.0.4/to-markdown.js"></script>
  <script type="text/javascript" charset="utf-8" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-markdown/2.10.0/js/bootstrap-markdown.js"></script>
  <script>
    $(".torrent-desc").markdown({resize: "both"})
  </script>
{{end}}