Improved a bit the placement of the function. Now FlagCode is in Templates js renderer (same place as the golang counterpart)
Cette révision appartient à :
Parent
5f0864f36a
révision
ce90f6fbce
5 fichiers modifiés avec 57 ajouts et 58 suppressions
|
@ -208,7 +208,7 @@ var Kilo = function (params) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var langCat = langValue !== 'other' ? (langValue > 1 ? 'multiple' : langValue) : 'other'
|
var langCat = langValue !== 'other' ? (langValue > 1 ? 'multiple' : langValue) : 'other'
|
||||||
document.getElementsByClassName('table-torrent-flag')[0].className = 'table-torrent-flag flag flag-' + flagCode(langCat)
|
document.getElementsByClassName('table-torrent-flag')[0].className = 'table-torrent-flag flag flag-' + Templates.FlagCode(langCat)
|
||||||
document.getElementsByClassName('table-torrent-flag')[0].title = langTitle
|
document.getElementsByClassName('table-torrent-flag')[0].title = langTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,103 +4,95 @@
|
||||||
// Switches between themes when a new one is selected
|
// Switches between themes when a new one is selected
|
||||||
function switchThemes(){
|
function switchThemes(){
|
||||||
themeName = document.getElementById("theme-selector").value
|
themeName = document.getElementById("theme-selector").value
|
||||||
var head = document.getElementsByTagName("head")[0];
|
var head = document.getElementsByTagName("head")[0]
|
||||||
// Remove the theme in place, it fails if one isn't set
|
// Remove the theme in place, it fails if one isn't set
|
||||||
try{
|
try{
|
||||||
head.removeChild(document.getElementById("theme"));
|
head.removeChild(document.getElementById("theme"))
|
||||||
} catch(err){}
|
} catch(err){}
|
||||||
// Don't add a node if we don't want extra styling
|
// Don't add a node if we don't want extra styling
|
||||||
if(themeName === ""){
|
if(themeName === ""){
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
// Create the new one and put it back
|
// Create the new one and put it back
|
||||||
var newTheme = document.createElement("link");
|
var newTheme = document.createElement("link")
|
||||||
newTheme.setAttribute("rel", "stylesheet");
|
newTheme.setAttribute("rel", "stylesheet")
|
||||||
newTheme.setAttribute("href", "/css/"+ themeName + ".css");
|
newTheme.setAttribute("href", "/css/"+ themeName + ".css")
|
||||||
newTheme.setAttribute("id", "theme");
|
newTheme.setAttribute("id", "theme")
|
||||||
head.appendChild(newTheme);
|
head.appendChild(newTheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by spoiler tags
|
// Used by spoiler tags
|
||||||
function toggleLayer(elem) {
|
function toggleLayer(elem) {
|
||||||
if (elem.classList.contains("hide")) {
|
if (elem.classList.contains("hide")) {
|
||||||
elem.classList.remove("hide");
|
elem.classList.remove("hide")
|
||||||
} else {
|
} else {
|
||||||
elem.classList.add("hide");
|
elem.classList.add("hide")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function parseAllDates() {
|
function parseAllDates() {
|
||||||
// Date formatting
|
// Date formatting
|
||||||
var lang = document.getElementsByTagName("html")[0].getAttribute("lang");
|
var lang = document.getElementsByTagName("html")[0].getAttribute("lang")
|
||||||
var ymdOpt = { year: "numeric", month: "short", day: "numeric" };
|
var ymdOpt = { year: "numeric", month: "short", day: "numeric" }
|
||||||
var hmOpt = { hour: "numeric", minute: "numeric" };
|
var hmOpt = { hour: "numeric", minute: "numeric" }
|
||||||
|
|
||||||
var list = document.getElementsByClassName("date-short");
|
var list = document.getElementsByClassName("date-short")
|
||||||
for(var i in list) {
|
for(var i in list) {
|
||||||
var e = list[i];
|
var e = list[i]
|
||||||
e.title = e.innerText;
|
e.title = e.innerText
|
||||||
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt);
|
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt)
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = document.getElementsByClassName("date-full");
|
var list = document.getElementsByClassName("date-full")
|
||||||
for(var i in list) {
|
for(var i in list) {
|
||||||
var e = list[i];
|
var e = list[i]
|
||||||
e.title = e.innerText;
|
e.title = e.innerText
|
||||||
e.innerText = new Date(e.innerText).toLocaleString(lang);
|
e.innerText = new Date(e.innerText).toLocaleString(lang)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parseAllDates();
|
parseAllDates()
|
||||||
|
|
||||||
/*Fixed-Navbar offset fix*/
|
/*Fixed-Navbar offset fix*/
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
var shiftWindow = function() { scrollBy(0, -70) };
|
var shiftWindow = function() { scrollBy(0, -70) }
|
||||||
if (location.hash) shiftWindow();
|
if (location.hash) shiftWindow()
|
||||||
window.addEventListener("hashchange", shiftWindow);
|
window.addEventListener("hashchange", shiftWindow)
|
||||||
|
|
||||||
document.getElementsByClassName("search-box")[0].addEventListener("focus", function (e) {
|
document.getElementsByClassName("search-box")[0].addEventListener("focus", function (e) {
|
||||||
var w = document.getElementsByClassName("h-user")[0].offsetWidth;
|
var w = document.getElementsByClassName("h-user")[0].offsetWidth
|
||||||
document.getElementsByClassName("h-user")[0].style.display = "none";
|
document.getElementsByClassName("h-user")[0].style.display = "none"
|
||||||
document.getElementsByClassName("search-box")[0].style.width = document.getElementsByClassName("search-box")[0].offsetWidth + w + "px";
|
document.getElementsByClassName("search-box")[0].style.width = document.getElementsByClassName("search-box")[0].offsetWidth + w + "px"
|
||||||
});
|
})
|
||||||
document.getElementsByClassName("search-box")[0].addEventListener("blur", function (e) {
|
document.getElementsByClassName("search-box")[0].addEventListener("blur", function (e) {
|
||||||
document.getElementsByClassName("search-box")[0].style.width = "";
|
document.getElementsByClassName("search-box")[0].style.width = ""
|
||||||
document.getElementsByClassName("h-user")[0].style.display = "inline-block";
|
document.getElementsByClassName("h-user")[0].style.display = "inline-block"
|
||||||
});
|
})
|
||||||
|
|
||||||
});
|
})
|
||||||
|
|
||||||
function playVoice() {
|
function playVoice() {
|
||||||
var mascotAudio = document.getElementById("explosion") || document.getElementById("nyanpassu")|| document.getElementById("nyanpassu2") || document.getElementById("kawaii");
|
var mascotAudio = document.getElementById("explosion") || document.getElementById("nyanpassu")|| document.getElementById("nyanpassu2") || document.getElementById("kawaii")
|
||||||
if (mascotAudio !== undefined) {
|
if (mascotAudio !== undefined) {
|
||||||
mascotAudio.volume = 0.2;
|
mascotAudio.volume = 0.2
|
||||||
mascotAudio.play();
|
mascotAudio.play()
|
||||||
} else {
|
} else {
|
||||||
console.log("Your mascot doesn't support yet audio files!")
|
console.log("Your mascot doesn't support yet audio files!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementsByClassName("form-input refine")[0].addEventListener("click", function (e) {
|
document.getElementsByClassName("form-input refine")[0].addEventListener("click", function (e) {
|
||||||
document.getElementsByClassName("box refine")[0].style.display = document.getElementsByClassName("box refine")[0].style.display == "none" ? "block" : "none";
|
document.getElementsByClassName("box refine")[0].style.display = document.getElementsByClassName("box refine")[0].style.display == "none" ? "block" : "none"
|
||||||
if(document.getElementsByClassName("form-input refine-searchbox")[0].value != document.getElementsByClassName("form-input search-box")[0].value)
|
if(document.getElementsByClassName("form-input refine-searchbox")[0].value != document.getElementsByClassName("form-input search-box")[0].value)
|
||||||
document.getElementsByClassName("form-input refine-searchbox")[0].value = document.getElementsByClassName("form-input search-box")[0].value;
|
document.getElementsByClassName("form-input refine-searchbox")[0].value = document.getElementsByClassName("form-input search-box")[0].value
|
||||||
if(document.getElementsByClassName("form-input refine-category")[0].selectedIndex != document.getElementsByClassName("form-input form-category")[0].selectedIndex)
|
if(document.getElementsByClassName("form-input refine-category")[0].selectedIndex != document.getElementsByClassName("form-input form-category")[0].selectedIndex)
|
||||||
document.getElementsByClassName("form-input refine-category")[0].selectedIndex = document.getElementsByClassName("form-input form-category")[0].selectedIndex;
|
document.getElementsByClassName("form-input refine-category")[0].selectedIndex = document.getElementsByClassName("form-input form-category")[0].selectedIndex
|
||||||
e.preventDefault();
|
e.preventDefault()
|
||||||
if(document.getElementsByClassName("box refine")[0].style.display == "block")
|
if(document.getElementsByClassName("box refine")[0].style.display == "block")
|
||||||
scrollTo(0, 0);
|
scrollTo(0, 0)
|
||||||
});
|
})
|
||||||
function humanFileSize(bytes, si) {
|
function humanFileSize(bytes, si) {
|
||||||
var k = si ? 1000 : 1024;
|
var k = si ? 1000 : 1024
|
||||||
var i = ~~(Math.log(bytes) / Math.log(k));
|
var i = ~~(Math.log(bytes) / Math.log(k))
|
||||||
return i == 0 ? bytes + " B" : (bytes / Math.pow(k, i)).toFixed(1) + " " + "KMGTPEZY"[i - 1] + (si ? "" : "i") + "B";
|
return i == 0 ? bytes + " B" : (bytes / Math.pow(k, i)).toFixed(1) + " " + "KMGTPEZY"[i - 1] + (si ? "" : "i") + "B"
|
||||||
}
|
}
|
||||||
|
|
||||||
function flagCode(language) {
|
|
||||||
split = language.split("-");
|
|
||||||
if (split.length > 1) {
|
|
||||||
return split[0];
|
|
||||||
}
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
@ -38,6 +38,13 @@ var Templates = {
|
||||||
}).
|
}).
|
||||||
replace(/</g, '<').
|
replace(/</g, '<').
|
||||||
replace(/>/g, '>');
|
replace(/>/g, '>');
|
||||||
|
},
|
||||||
|
FlagCode: function(language) {
|
||||||
|
var split = language.split("-")
|
||||||
|
if (split.length > 1) {
|
||||||
|
return split[1]
|
||||||
|
}
|
||||||
|
return language
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
@ -21,7 +21,7 @@ Templates.Add("torrents.item", function(torrent) {
|
||||||
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
||||||
{{end}}
|
{{end}}
|
||||||
"<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"\" title=\""+ T.r(torrent.category+"_"+torrent.sub_category)+"\" class=\"category\">"+
|
"<a href=\"{{URL.Parse("/search?c=") }}"+ torrent.category + "_" + torrent.sub_category +"\" title=\""+ T.r(torrent.category+"_"+torrent.sub_category)+"\" class=\"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(",")+"\" alt=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\"></a>" : "") +
|
((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) ? Templates.FlagCode(torrent.languages[0]) : "multiple") +"\" title=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\" alt=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\"></a>" : "") +
|
||||||
"</a>"+
|
"</a>"+
|
||||||
"</div></td>"+
|
"</div></td>"+
|
||||||
"<td class=\"tr-name home-td\""+ (torrent.comments.length == 0 ? "colspan=\"2\"" : "" ) +"><a href=\"/view/"+torrent.id+"\">"+Templates.EncodeEntities(torrent.name) +"</a></td>"+
|
"<td class=\"tr-name home-td\""+ (torrent.comments.length == 0 ? "colspan=\"2\"" : "" ) +"><a href=\"/view/"+torrent.id+"\">"+Templates.EncodeEntities(torrent.name) +"</a></td>"+
|
||||||
|
|
|
@ -16,7 +16,7 @@ Templates.Add("torrents.item", function(torrent) {
|
||||||
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
||||||
{{end}}
|
{{end}}
|
||||||
"<a class=\"category\">"+
|
"<a class=\"category\">"+
|
||||||
((torrent.languages[0] != "") ? "<a><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>" : "") +
|
((torrent.languages[0] != "") ? "<a><img src=\"img/blank.gif\" class=\"flag flag-"+ ((torrent.languages.length == 1) ? Templates.FlagCode(torrent.languages[0]) : "multiple") +"\" title=\""+torrent.languages.map(function (el, i) { return T.r(el)}).join(",")+"\"></a>" : "") +
|
||||||
"</a>"+
|
"</a>"+
|
||||||
"</div></td>"+
|
"</div></td>"+
|
||||||
"<td class=\"tr-name home-td\""+ (torrent.comments.length == 0 ? "colspan=\"2\"" : "" ) +"><a>"+Templates.EncodeEntities(torrent.name) +"</a></td>"+
|
"<td class=\"tr-name home-td\""+ (torrent.comments.length == 0 ? "colspan=\"2\"" : "" ) +"><a>"+Templates.EncodeEntities(torrent.name) +"</a></td>"+
|
||||||
|
|
Référencer dans un nouveau ticket