Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #1115 from NyaaPantsu/pr/1114

Flag clickeable when generated by JS & multiple flagcode search
Cette révision appartient à :
akuma06 2017-07-07 13:01:17 +02:00 révisé par GitHub
révision bef7a2ed3d
2 fichiers modifiés avec 15 ajouts et 6 suppressions

Voir le fichier

@ -3,10 +3,13 @@
function Translations() {
var translations = {};
this.Add = function(tr, val) {
trans = {}
if (val != undefined) {
tr[tr] = val;
trans[tr] = val;
} else {
trans = tr
}
Object.assign(translations, tr);
Object.assign(translations, trans);
};
this.r = function(string, ...args) {
if ((string != undefined) && (translations[string] != undefined)) {

Voir le fichier

@ -55,7 +55,7 @@
{{end}}
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory) }}" title="{{ T(CategoryName(.Category, .SubCategory)) }}" class="category">
{{if .Languages[0] != "" }}
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory +"&lang=" + FlagCode(.Languages[0])) }}">
<a href="{{ URL.Parse("/search?c="+.Category+"_"+ .SubCategory +"&lang=") }}{{ range key, language := .Languages }}{{ language }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
<img src="/img/blank.gif" alt="{{ LanguageName(.Languages[0], T) }}" class="flag flag-{{ (len(.Languages) == 1) ? FlagCode(.Languages[0]) : "multiple" }}" title=" {{ range key, language := .Languages }}{{ LanguageName(language, T) }}{{ if len(.Languages) > 1 && (key+1) < len(.Languages) }},{{ end }}{{ end }}">
</a>
{{end}}
@ -161,8 +161,8 @@
<script type="text/javascript" src="{{ URL.Parse("/js/query.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/modal.js") }}"></script>
<script type="text/javascript" src="{{ URL.Parse("/js/torrents.js") }}"></script>
{{ if User.HasAdmin() }}
<script type="text/javascript" src="{{ URL.Parse("/js/translation.js") }}"></script>
{{ if User.HasAdmin() }}
<script type="text/javascript" src="{{ URL.Parse("/js/torrentsMod.js") }}"></script>
<script type="text/javascript">
// We add translations string
@ -228,6 +228,12 @@
{{end}}
<!-- JS Template for torrents ajax -->
<script type="text/javascript">
{{ range _, cat := GetCategories(false, true) }}
T.Add("{{ cat.ID }}", "{{ T(cat.Name) }}")
{{end}}
{{ range _, language := GetTorrentLanguages() }}
T.Add("{{ language }}", "{{ LanguageName(language, T) }}")
{{end}}
Templates.Add("torrents.item", function(torrent) {
return "<tr id=\"torrent_" + torrent.id + "\" class=\"torrent-info"+ ((torrent.status == 2) ? " remake" : ((torrent.status == 3) ? " trusted" : ((torrent.status == 3) ? " aplus" : "" )))+"\">"+
{{ if User.HasAdmin() }}
@ -241,8 +247,8 @@
{{else}}
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
{{end}}
"<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"\" title=\""+ torrent.CategoryName +"\">"+
((torrent.language != "") ? "<img src=\"img/blank.gif\" class=\"flag flag-"+flagCode(torrent.language)+"\">" : "") +
"<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"\" title=\""+ T.r(torrent.category+"_"+torrent.sub_category)+"\">"+
((torrent.languages[0] != "") ? "<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"&lang=" + torrent.languages.join(",") +"\"><img src=\"img/blank.gif\" class=\"flag flag-"+ ((torrent.languages.length == 1) ? flagCode(torrent.languages[0]) : "multiple") +"\" title=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\"></a>" : "") +
"</a>"+
"</div></td>"+
"<td class=\"tr-name home-td\"><a href=\"/view/"+torrent.id+"\">"+Templates.EncodeEntities(torrent.name) +"</a></td>"+