498 lignes
22 Kio
HTML
498 lignes
22 Kio
HTML
{{ extends "layouts/index_site" }}
|
|
{{ import "layouts/partials/helpers/csrf" }}
|
|
{{ import "layouts/partials/helpers/captcha" }}
|
|
{{ import "layouts/partials/helpers/errors" }}
|
|
{{ import "layouts/partials/helpers/tags" }}
|
|
{{ import "layouts/partials/helpers/treeview" }}
|
|
{{ import "layouts/partials/helpers/tag_form" }}
|
|
{{block title()}}{{Torrent.Name}}{{end}}
|
|
{{block content_body()}}
|
|
<div style="text-align: left;" class="box {{if Torrent.Status == 2}}torrent-remake{{else if Torrent.Status == 3}}torrent-trusted{{else if Torrent.Status == 4}}torrent-aplus{{end}}">
|
|
<div id="torrent-name" class="{{if Torrent.Status == 2}}remake{{else if Torrent.Status == 3}}trusted{{else if Torrent.Status == 4}}aplus{{else if Torrent.Status == 5}}locked{{end}}">
|
|
<h1 style="text-align: center;" class="torrent-hr">{{Torrent.Name}}</h1>
|
|
</div>
|
|
<br/>
|
|
<div class="torrent-view-data">
|
|
<table>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("category") }}:</td>
|
|
<td class="torrent-view-td torrent-info-data">
|
|
<a href="{{URL.Parse("/search?c="+Torrent.Category+"_"+Torrent.SubCategory) }}">{{ CategoryName(Torrent.Category, Torrent.SubCategory) == "" ? T("unknown") : T(CategoryName(Torrent.Category, Torrent.SubCategory)) }}</a>
|
|
<br/>
|
|
</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("uploaded_by") }}:</td>
|
|
{{if Torrent.UploaderID == 0}}
|
|
<td class="torrent-view-td torrent-info-data uploader-anon">{{ genUploaderLink(Torrent.UploaderID, Torrent.UploaderName, Torrent.Hidden)|raw }}
|
|
{{else}}
|
|
<td class="torrent-view-td torrent-info-data uploader-link">
|
|
{{ genUploaderLink(Torrent.UploaderID, Torrent.UploaderName, Torrent.Hidden)|raw }}
|
|
{{if !Torrent.Hidden && Torrent.UploaderID != User.ID && Torrent.UploaderID != 0}}
|
|
{{if User.ID > 0}}
|
|
<a href="/user/{{Torrent.UploaderID}}/{{Torrent.UploaderName}}/follow?id={{Torrent.ID}}" id="subscribe-link">{{if User.IsFollower(Torrent.UploaderID)}}{{T("unfollow")}}{{else}}{{T("follow")}}{{end}}</a>
|
|
{{else}}
|
|
<a href="/login?redirectTo=/user/{{Torrent.UploaderID}}/{{Torrent.UploaderName}}/follow?id={{Torrent.ID}}" id="subscribe-link">{{T("follow")}}</a>
|
|
{{end}}
|
|
{{end}}
|
|
</td>
|
|
{{end}}
|
|
</tr>
|
|
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("website_link") }}:</td>
|
|
<td class="torrent-view-td torrent-info-data">
|
|
{{if Torrent.WebsiteLink != ""}}<a href="{{Torrent.WebsiteLink}}">{{Torrent.WebsiteLink}}</a>
|
|
{{else}}N/A{{end}}
|
|
</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("hash")}}:</td>
|
|
<td style="font-family: monospace;" class="torrent-view-td torrent-info-data">{{Torrent.Hash}}</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("size")}}:</td>
|
|
<td class="torrent-view-td torrent-info-data">{{ fileSize(Torrent.Filesize, T, true) }}</td>
|
|
</tr>
|
|
{{ if len(Torrent.Languages) > 0 && Torrent.Languages[0] != "" }}
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("torrent_language")}}:</td>
|
|
<td class="tr-flag torrent-view-td torrent-info-data">
|
|
{{ range _, language := Torrent.Languages}}
|
|
{{ if language != "" }}
|
|
<span {{ if len(Torrent.Languages) > 5 }}class="big"{{ end }}>
|
|
<img src="/img/blank.gif" alt="{{ LanguageNameFromCode(language, T) }}" class="flag flag-{{ FlagCode(language) }}" title="{{ LanguageNameFromCode(language, T) }}">
|
|
{{ LanguageNameFromCode(language, T) }}
|
|
</span>
|
|
{{end}}
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{{ if Torrent.AnidbID > 0 || Torrent.VndbID > 0 || Torrent.VgmdbID > 0 || Torrent.Dlsite != "" }}
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("related_to") }}</td>
|
|
<td class="tr-flag torrent-view-td torrent-info-data">
|
|
{{ if Torrent.AnidbID > 0 }}
|
|
<span class="tag accepted">
|
|
<span class="tag-text votable"><a href="http://anidb.net/perl-bin/animedb.pl?show=anime&aid={{Torrent.AnidbID}}">{{ T("tagtype_anidbid") }}: {{ Torrent.AnidbID }}</a></span>
|
|
<a href="/search?anidb={{ Torrent.AnidbID }}" title="{{ T("filter") }}"><i class="icon-search"></i></a>
|
|
</span>
|
|
{{end}}
|
|
{{ if Torrent.VndbID > 0 }}
|
|
<span class="tag accepted">
|
|
<span class="tag-text votable"><a href="https://vndb.org/v{{ Torrent.VndbID }}">{{ T("tagtype_vndbid") }}: {{ Torrent.VndbID }}</a></span>
|
|
<a href="/search?vndb={{ Torrent.VndbID }}" title="{{ T("filter") }}"><i class="icon-search"></i></a>
|
|
</span>
|
|
{{end}}
|
|
{{ if Torrent.VgmdbID > 0 }}
|
|
<span class="tag accepted">
|
|
<span class="tag-text votable"><a href="http://vgmdb.net/product/{{ Torrent.VgmdbID }}">{{ T("tagtype_vgmdbid") }}: {{ Torrent.VgmdbID }}</a></span>
|
|
<a href="/search?vgm={{ Torrent.VgmdbID }}" title="{{ T("filter") }}"><i class="icon-search"></i></a>
|
|
</span>
|
|
{{end}}
|
|
{{ if Torrent.Dlsite != "" }}
|
|
<span class="tag accepted">
|
|
<span class="tag-text votable"><a href="http://www.dlsite.com/home/work/=/product_id/{{ Torrent.Dlsite }}.html">{{ T("tagtype_dlsite") }}: {{ Torrent.Dlsite }}</a></span>
|
|
<a href="/search?dlsite={{ Torrent.Dlsite }}" title="{{ T("filter") }}"><i class="icon-search"></i></a>
|
|
</span>
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{ end }}
|
|
{{ if len(Torrent.AcceptedTags) > 0 }}
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("accepted_tags")}}:</td>
|
|
<td class="tr-flag torrent-view-td torrent-info-data" id="tags-torrent">
|
|
{{ range Torrent.AcceptedTags }}
|
|
{{ yield tag(tag=., accepted=true, torrentID=Torrent.ID) }}
|
|
{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
{* if tags are not accepted and user is not logged, we don't display them *}
|
|
{{ if User.ID > 0 }}
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("recommended_tags")}}:</td>
|
|
<td class="tr-flag torrent-view-td torrent-info-data" id="tags-torrent">
|
|
{{ range Torrent.Tags }}
|
|
{{ yield tag(tag=., accepted=false, torrentID=Torrent.ID) }}
|
|
{{end}}
|
|
<a id="tagPopup" href="/torrent/tag?id={{ Torrent.ID }}" class="add-tag">{{ T("complement") }}</a>
|
|
</td>
|
|
</tr>
|
|
{{ end }}
|
|
{{ if Torrent.VideoQuality != "" }}
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("tagtype_videoquality") }}:</td>
|
|
<td class="tr-flag torrent-view-td torrent-info-data">
|
|
{{ T("tagvalue_"+Torrent.VideoQuality) }}
|
|
</td>
|
|
</tr>
|
|
{{ end }}
|
|
</table>
|
|
<table>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("date") }}:</td>
|
|
<td class="torrent-info-td date-full">{{formatDate(Torrent.FullDate, false)}}</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("seeders")}}:</td>
|
|
<td class="tr-se torrent-info-td">{{if Torrent.StatsObsolete[0] }}{{ T("unknown")}}{{else}}{{Torrent.Seeders}}{{end}}</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("leechers")}}:</td>
|
|
<td class="tr-le torrent-info-td">{{if Torrent.StatsObsolete[0] }}{{ T("unknown")}}{{else}}{{Torrent.Leechers}}{{end}}</td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("completed")}}:</td>
|
|
<td class="torrent-info-td tr-dl">{{if Torrent.StatsObsolete[0] }}{{ T("unknown")}}{{else}}{{Torrent.Completed}}{{end}} </td>
|
|
</tr>
|
|
<tr class="torrent-info-row">
|
|
<td class="torrent-info-td torrent-info-label">{{ T("last_scraped")}}</td>
|
|
<td class="torrent-info-td scrape-date{{if !Torrent.LastScrape.IsZero() }} date-full">{{formatDate(Torrent.LastScrape, false)}}{{else}}">{{ T("unknown")}}{{end}}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="torrent-buttons">
|
|
<a href="{{Torrent.Magnet}}" class="form-input btn-green download" style="float:left;height: auto;margin-right: 0.5em;">
|
|
<div class="icon-magnet"></div>{{ T("magnet_link")}}
|
|
</a>
|
|
<a id="torrent-download-link" href="{{if Torrent.TorrentLink == ""}}/download/{{Torrent.Hash}}{{else}}{{Torrent.TorrentLink}}{{end}}" class="form-input download{{ if !torrentFileExists(Torrent.Hash, Torrent.TorrentLink)}} hidden{{end}}" style="float:left;height: auto;">
|
|
<div class="icon-floppy"></div>{{ T("torrent_file")}}
|
|
</a>
|
|
<a id="reportPopup" href="#" class="form-input">{{ T("report_btn") }}</a>
|
|
{{ if User.ID > 0}}
|
|
{{ if User.HasAdmin()}}
|
|
<form method="POST" action="/mod/torrent/delete" class="delete-form">
|
|
{{ yield csrf_field()}}
|
|
<input type="hidden" name="id" value="{{ Torrent.ID }}">
|
|
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T("are_you_sure") }}{{ T("delete") }}')) return false;"><i class="icon-trash"></i>{{ T("delete") }}</button>
|
|
</form>
|
|
<a href="/mod/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
|
|
{{ else if User.CurrentUserIdentical(Torrent.UploaderID) }}
|
|
<form method="POST" action="/torrent/delete" class="delete-form">
|
|
{{ yield csrf_field()}}
|
|
<input type="hidden" name="id" value="{{ Torrent.ID }}">
|
|
<button type="submit" class="form-input btn-red" onclick="if (!confirm('{{ T("are_you_sure") }}{{ T("delete") }}')) return false;"><i class="icon-trash"></i>{{ T("delete") }}</button>
|
|
</form>
|
|
<a href="/torrent?id={{ Torrent.ID }}" class="form-input btn-orange">{{ T("edit") }}</a>
|
|
{{end}}
|
|
{{end}}
|
|
<div style="clear:both;"></div>
|
|
</div>
|
|
<p class="torrent-hr" id="torrent-description-hr">{{ T("description")}}</p>
|
|
{{ if Torrent.Description != ""}}
|
|
<div id="description-box" class="torrent-info-box">{{Torrent.Description|raw}}</div>
|
|
{{else}}
|
|
<p>{{ T("no_description") }}</p>
|
|
{{end}}
|
|
<input type="checkbox" id="show-filelist" {{if len(Torrent.FileList) < 4 && len(Torrent.FileList) > 0}}checked{{end}}/>
|
|
<label class="torrent-hr filelist-control{{if len(Torrent.FileList) == 0}} hidden{{end}}" for="show-filelist">{{ T("files")}}</label>
|
|
<div class="torrent-info-box{{if len(Torrent.FileList) == 0}} hidden{{end}}" id="filelist">
|
|
{{ if len(Torrent.FileList) > 0 }}
|
|
{* how do i concat lol *}
|
|
<table class="table-filelist">
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 80%">{{ T("file_name")}}</th>
|
|
<th>{{ T("size")}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{ yield make_treeview(treeviewData=makeTreeViewData(RootFolder, 0, "root")) }}
|
|
</tbody>
|
|
</table>
|
|
{{ else }}
|
|
<p>{{ T("no_files") }}</p>
|
|
{{ end }}
|
|
</div>
|
|
|
|
<p class="torrent-hr" id="comments">{{ T("comments")}}</p>
|
|
{{idx := 1}}
|
|
{{previousComment := ""}}
|
|
{{previousUser := 0}}
|
|
{{range index, element := Torrent.Comments}}
|
|
{{if previousComment != element.Content || previousUser != element.UserID}}
|
|
<div class="torrent-info-box comment-box">
|
|
<span class="comment-index">
|
|
<a href="#comment_{{idx}}">{{idx}}</a>
|
|
<small style="padding-left: 4px;" class="date-full">{{formatDate(element.Date, false)}}</small>
|
|
</span>
|
|
<span class="comment-userinfo"><img src="{{ getAvatar(element.UserAvatar, 50) }}"/>
|
|
{{if element.UserID > 0}}<a href="/user/{{element.UserID}}/{{element.Username}}" class="comment-user">{{element.Username}}</a>{{if element.UserStatus != ""}}<span class="user-status">{{T(element.UserStatus)}}</span>{{end}}{{else}}
|
|
<span class="comment-user">れんちょん</span>{{end}}
|
|
</span>
|
|
<div class="comment-content">{{element.Content|raw}}</div>
|
|
</div>
|
|
{{idx = idx + 1}}
|
|
{{end}}
|
|
{{previousComment = element.Content}}
|
|
{{previousUser = element.UserID}}
|
|
{{end}}
|
|
{{ if len(Torrent.Comments) == 0 }}
|
|
<p id="no-comment-message">{{ T("torrent_no_comments") }}</p>
|
|
{{ end }}
|
|
<div style="margin-top: 10px" class="torrent-info-box comment-submit">
|
|
<form method="post">
|
|
{{ yield csrf_field()}}
|
|
<div class="comment-form">
|
|
<div class="comment-text">
|
|
<h3>{{ if User.ID > 0}} {{ T("submit_a_comment_as_username", User.Username) }} {{else}} {{ T("submit_a_comment_as_anonymous")|raw}} {{end}}</h3>
|
|
<textarea style="height: 10rem;" placeholder="サンキュー" name="comment" class="form-input up-input"></textarea>
|
|
<p class="not-important">{{T("comment_markdown_notice")}}</p>
|
|
</div>
|
|
<div class="comment-captcha">
|
|
{{ yield captcha(captchaid=CaptchaID)}}
|
|
</div>
|
|
<button type="submit" class="form-input up-btn">{{ T("submit") }}</button>
|
|
{{if User.ID > 0}}<input type="checkbox" name="anonymous" value="true" id="anonymous"><label for="anonymous">{{ T("submit_a_comment_as_anonymous")}}</label>{{end}}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- Modal to report a torrent -->
|
|
<div id="modal_mod_tools" class="modal">
|
|
<!-- Modal content -->
|
|
<div class="modal-content">
|
|
<form method="post" action="/report/{{Torrent.ID}}">
|
|
<div class="modal-header">
|
|
<span class="close">×</span>
|
|
<h2>{{ T("report_torrent_number", Torrent.ID) }}</h2>
|
|
</div>
|
|
<div class="modal-body">
|
|
<h4>{{ T("report_type") }}</h4>
|
|
{{ yield csrf_field() }}
|
|
<input type="radio" name="report_type" value="illegal_content" id="illegal" required/>
|
|
<label for="illegal">{{ T("illegal_content") }}</label><br />
|
|
<input type="radio" name="report_type" value="spam_garbage" id="spam" required/>
|
|
<label for="spam">{{ T("spam_garbage") }}</label><br />
|
|
<input type="radio" name="report_type" value="wrong_category" id="wrongcat" required/>
|
|
<label for="wrongcat">{{ T("wrong_category") }}</label><br />
|
|
<input type="radio" name="report_type" value="duplicate_deprecated" id="dup" required/>
|
|
<label for="dup">{{ T("duplicate_deprecated") }}</label><br />
|
|
<input type="radio" name="report_type" value="other" id="other"" required/>
|
|
<label for="other">{{ T("other") }}</label><br />
|
|
<h4>{{ T("report_message") }}</h4>
|
|
<input type="text" class="form-input" name="report_message" placeholder="(Optional, 60 characters max)" maxlength="60">
|
|
{{if User.ID == 0}}
|
|
<div class="comment-captcha" style="margin-top: 7px;">
|
|
{{yield captcha(captchaid=CaptchaID)}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
<div class="modal-footer">
|
|
<span>
|
|
<button id="confirm_changes" type="submit">{{ T("yes")}}</button>
|
|
<button class="close" type="button" onclick="Modal.CloseActive();">{{ T("no")}}</button>
|
|
</span>
|
|
<h3>{{ T("are_you_sure") }} </h3>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{{ if User.ID > 0 }}
|
|
<!-- Modal to add a tag -->
|
|
<div id="modal_tag_form" class="modal">
|
|
<!-- Modal content -->
|
|
<div class="modal-content">
|
|
<form method="post" action="/torrent/tag?id={{Torrent.ID}}">
|
|
<div class="modal-header">
|
|
<span class="close">×</span>
|
|
<h2>{{ T("add_tag") }}</h2>
|
|
</div>
|
|
<div class="modal-body upload-tag-form">
|
|
{{ yield csrf_field() }}
|
|
{{ range Config.Torrents.Tags.Types }}
|
|
{{ yield tagForm(tagType=.) }}
|
|
{{ end }}
|
|
<div class="form-group">
|
|
<label class="input-label" for="tag_{{Config.Torrents.Tags.Default}}">{{ T("tagtype_tags") }}</label>
|
|
<input type="text" class="form-input" name="tag_{{Config.Torrents.Tags.Default}}" id="tag_{{Config.Torrents.Tags.Default}}" value="" />
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<span>
|
|
<button id="confirm_changes" type="submit">{{ T("add")}}</button>
|
|
<button class="close" onclick="Modal.CloseActive();">{{ T("close")}}</button>
|
|
</span>
|
|
<h3>{{ T("are_you_sure") }} </h3>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|
|
{{ block footer_js()}}
|
|
<script type="text/javascript" src="{{ URL.Parse("/js/modal.js") }}"></script>
|
|
<script type="text/javascript">
|
|
// Modal initialization
|
|
Modal.Init({
|
|
elements: document.getElementsByClassName("modal"),
|
|
// order of apparition of the modals
|
|
button: ["#reportPopup", "#tagPopup"]
|
|
});
|
|
</script>
|
|
{{ if !torrentFileExists(Torrent.Hash, Torrent.TorrentLink)}}
|
|
<script type="text/javascript">
|
|
var torrentLink = document.getElementById("torrent-download-link"),
|
|
oldDownloadHtml = torrentLink.innerHTML,
|
|
downloadIconHtml = torrentLink.innerHTML.substring(0, torrentLink.innerHTML.indexOf("</div>") + 6),
|
|
disabledLink = true,
|
|
firstQueryDate = new Date()
|
|
|
|
torrentLink.addEventListener("click", function (e) {
|
|
if(disabledLink) {
|
|
Query.Get('/download/{{Torrent.Hash}}?js_query=true', function (data) {
|
|
if(typeof data.generating != "undefined" && data.generating == true) {
|
|
torrentLink.innerHTML = downloadIconHtml + "{{T("generating_torrent")}}"
|
|
setTimeout(fileCreated, 2000)
|
|
} else {
|
|
disabledLink = false
|
|
torrentLink.click();
|
|
}
|
|
})
|
|
e.preventDefault()
|
|
}
|
|
})
|
|
|
|
function fileCreated() {
|
|
Query.Get('/download/{{Torrent.Hash}}?js_query=true', function (data) {
|
|
if(typeof data.exists != "undefined" && data.exists == true) {
|
|
torrentLink.innerHTML = oldDownloadHtml
|
|
torrentLink.style = torrentLink.style + "opacity: 1!important;filter: grayscale(0);"
|
|
torrentLink.removeEventListener("click", function (e) {});
|
|
torrentLink.click();
|
|
} else {
|
|
if(new Date() - firstQueryDate < 20000)
|
|
setTimeout(fileCreated, 3000)
|
|
else {
|
|
torrentLink.innerHTML = downloadIconHtml + "Could not generate torrent file"
|
|
torrentLink.removeEventListener("click", function (e) {});
|
|
disabledLink = true
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
{{end}}
|
|
{{if Torrent.StatsObsolete[1] }}
|
|
<script type="text/javascript">
|
|
var seeders = document.querySelector(".tr-se"),
|
|
leechers = document.querySelector(".tr-le"),
|
|
downloads = document.querySelector(".tr-dl"),
|
|
scrapeDate= document.querySelector(".scrape-date")
|
|
|
|
var oldStats = [seeders.innerHTML, leechers.innerHTML, downloads.innerHTML]
|
|
|
|
seeders.innerHTML = "Loading..."
|
|
leechers.innerHTML = "Loading..."
|
|
downloads.innerHTML = "Loading..."
|
|
|
|
Query.Get('/stats/{{Torrent.ID}}', function (data) {
|
|
if(typeof data.seeders != "undefined")
|
|
scrapeDate.innerText = new Date().toLocaleString(document.getElementsByTagName("html")[0].getAttribute("lang"), "ymdOpt")
|
|
|
|
if(typeof data.seeders != "undefined" && data.seeders != -1) {
|
|
seeders.innerHTML = "<span>" + data.seeders + "</span>"
|
|
leechers.innerHTML = "<span>" + data.leechers + "</span>"
|
|
downloads.innerHTML = "<span>" + data.downloads + "</span>"
|
|
} else {
|
|
seeders.innerHTML = oldStats[0]
|
|
leechers.innerHTML = oldStats[1]
|
|
downloads.innerHTML = oldStats[2]
|
|
}
|
|
})
|
|
|
|
|
|
</script>
|
|
{{end}}
|
|
{{ if User.ID > 0 }}
|
|
<script type="text/javascript" src="{{ URL.Parse("/js/template.js") }}"></script>
|
|
<script type="text/javascript" src="{{ URL.Parse("/js/modal.js") }}"></script>
|
|
<script type="text/javascript" src="{{ URL.Parse("/js/translation.js") }}"></script>
|
|
<script type="text/javascript">
|
|
// {{ range Config.Torrents.Tags.Types }}
|
|
T.Add("tagtype_{{ .Name }}", '{{ T("tagtype_" + .Name) }}')
|
|
// {{ if len(.Defaults) > 0 }}
|
|
// {{ range key, value := .Defaults }}
|
|
T.Add("{{ .Name }}", '{{ T("tagvalue_" + .Name) }}')
|
|
// {{ end }}
|
|
// {{ end }}
|
|
// {{ end }}
|
|
|
|
Templates.Add("tag", function(tag) {
|
|
var tagClass = (tag.accepted) ? "tag" : "tag pending"
|
|
var tagTitle = (tag.accepted) ? 'Tag: ' + tag.type + '({{ T("accepted") }} )' : 'Tag: ' + tag.type + "(" + tag.weight + ")"
|
|
|
|
return `<span class="`+ tagClass +`" title="`+ tagTitle +`" data-weight="` + tag.weight + `">
|
|
<span class="tag-text votable">
|
|
` + T.r("tagtype_" + tag.type) + `: ` + T.R(tag.tag) + `
|
|
</span>
|
|
<a href="/torrent/tag/remove?id={{Torrent.ID}}&tag=` + tag.tag + `&type=` + tag.type + `" class="tag-form minus" onclick="handleVotes(event)"></a>
|
|
</span>`
|
|
})
|
|
|
|
// Modal initialization
|
|
Modal.Init({
|
|
elements: document.getElementsByClassName("modal"),
|
|
// order of apparition of the modals
|
|
button: ["#tagPopup"]
|
|
});
|
|
|
|
document.querySelector("#modal_tag_form form").addEventListener("submit", function(e) {
|
|
var form = e.target
|
|
var tags = form.querySelectorAll(".tagtype")
|
|
var csrf = form.querySelector("input[name='csrf_token']").value
|
|
// Build query
|
|
var len = tags.length
|
|
var query = "csrf_token="+encodeURIComponent(csrf)
|
|
for (var i=0; i < len; i++) {
|
|
query += "&"+tags[i].name+"="+tags[i].value
|
|
}
|
|
// Make query
|
|
Query.Post(form.action+"&json", query, function(data) {
|
|
if (data.ok) {
|
|
Modal.CloseActive()
|
|
if (data.data === null) return
|
|
var len = data.data.length
|
|
for (var i = 0; i < len; i++) {
|
|
var tagHTml = Templates.Render("tag", data.data[i])
|
|
document.getElementById("tags-torrent").innerHTML = tagHTml + document.getElementById("tags-torrent").innerHTML
|
|
}
|
|
} else {
|
|
alert("{{ T("tag_error") }}")
|
|
}
|
|
})
|
|
|
|
e.preventDefault()
|
|
})
|
|
function handleVotes(e) {
|
|
var el = e.target
|
|
var hasplus = el.classList.contains("plus")
|
|
console.log(el.parentElement.dataset.weight)
|
|
var weight = parseFloat(el.parentElement.dataset.weight)
|
|
Query.Get(el.href+"&json", function(data) {
|
|
if (data.ok) {
|
|
var tag = data.data
|
|
if (hasplus) {
|
|
el.classList.remove("plus")
|
|
el.classList.add("minus")
|
|
el.href = "/torrent/tag/remove?id={{Torrent.ID}}&tag="+tag.tag+"&type="+tag.type
|
|
el.parentElement.title = 'Tag: ' + tag.type + "(" + (tag.weight+weight) + ")"
|
|
} else {
|
|
el.classList.remove("minus")
|
|
el.classList.add("plus")
|
|
el.href = "/torrent/tag/add?id={{Torrent.ID}}&tag="+tag.tag+"&type="+tag.type
|
|
el.parentElement.title = 'Tag: ' + tag.type + "(" + (weight-tag.weight) + ")"
|
|
}
|
|
}
|
|
})
|
|
e.preventDefault()
|
|
}
|
|
document.querySelectorAll(".tag-form").forEach(function(el) {
|
|
el.addEventListener("click", handleVotes)
|
|
})
|
|
</script>
|
|
{{end}}
|
|
{{end}}
|