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'
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,103 +4,95 @@
|
|||
// Switches between themes when a new one is selected
|
||||
function switchThemes(){
|
||||
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
|
||||
try{
|
||||
head.removeChild(document.getElementById("theme"));
|
||||
head.removeChild(document.getElementById("theme"))
|
||||
} catch(err){}
|
||||
// Don't add a node if we don't want extra styling
|
||||
if(themeName === ""){
|
||||
return;
|
||||
return
|
||||
}
|
||||
// Create the new one and put it back
|
||||
var newTheme = document.createElement("link");
|
||||
newTheme.setAttribute("rel", "stylesheet");
|
||||
newTheme.setAttribute("href", "/css/"+ themeName + ".css");
|
||||
newTheme.setAttribute("id", "theme");
|
||||
head.appendChild(newTheme);
|
||||
var newTheme = document.createElement("link")
|
||||
newTheme.setAttribute("rel", "stylesheet")
|
||||
newTheme.setAttribute("href", "/css/"+ themeName + ".css")
|
||||
newTheme.setAttribute("id", "theme")
|
||||
head.appendChild(newTheme)
|
||||
}
|
||||
|
||||
// Used by spoiler tags
|
||||
function toggleLayer(elem) {
|
||||
if (elem.classList.contains("hide")) {
|
||||
elem.classList.remove("hide");
|
||||
elem.classList.remove("hide")
|
||||
} else {
|
||||
elem.classList.add("hide");
|
||||
elem.classList.add("hide")
|
||||
}
|
||||
}
|
||||
function parseAllDates() {
|
||||
// Date formatting
|
||||
var lang = document.getElementsByTagName("html")[0].getAttribute("lang");
|
||||
var ymdOpt = { year: "numeric", month: "short", day: "numeric" };
|
||||
var hmOpt = { hour: "numeric", minute: "numeric" };
|
||||
var lang = document.getElementsByTagName("html")[0].getAttribute("lang")
|
||||
var ymdOpt = { year: "numeric", month: "short", day: "numeric" }
|
||||
var hmOpt = { hour: "numeric", minute: "numeric" }
|
||||
|
||||
var list = document.getElementsByClassName("date-short");
|
||||
var list = document.getElementsByClassName("date-short")
|
||||
for(var i in list) {
|
||||
var e = list[i];
|
||||
e.title = e.innerText;
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt);
|
||||
var e = list[i]
|
||||
e.title = e.innerText
|
||||
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) {
|
||||
var e = list[i];
|
||||
e.title = e.innerText;
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang);
|
||||
var e = list[i]
|
||||
e.title = e.innerText
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang)
|
||||
}
|
||||
}
|
||||
|
||||
parseAllDates();
|
||||
parseAllDates()
|
||||
|
||||
/*Fixed-Navbar offset fix*/
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var shiftWindow = function() { scrollBy(0, -70) };
|
||||
if (location.hash) shiftWindow();
|
||||
window.addEventListener("hashchange", shiftWindow);
|
||||
var shiftWindow = function() { scrollBy(0, -70) }
|
||||
if (location.hash) shiftWindow()
|
||||
window.addEventListener("hashchange", shiftWindow)
|
||||
|
||||
document.getElementsByClassName("search-box")[0].addEventListener("focus", function (e) {
|
||||
var w = document.getElementsByClassName("h-user")[0].offsetWidth;
|
||||
document.getElementsByClassName("h-user")[0].style.display = "none";
|
||||
document.getElementsByClassName("search-box")[0].style.width = document.getElementsByClassName("search-box")[0].offsetWidth + w + "px";
|
||||
});
|
||||
var w = document.getElementsByClassName("h-user")[0].offsetWidth
|
||||
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].addEventListener("blur", function (e) {
|
||||
document.getElementsByClassName("search-box")[0].style.width = "";
|
||||
document.getElementsByClassName("h-user")[0].style.display = "inline-block";
|
||||
});
|
||||
document.getElementsByClassName("search-box")[0].style.width = ""
|
||||
document.getElementsByClassName("h-user")[0].style.display = "inline-block"
|
||||
})
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
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) {
|
||||
mascotAudio.volume = 0.2;
|
||||
mascotAudio.play();
|
||||
mascotAudio.volume = 0.2
|
||||
mascotAudio.play()
|
||||
} else {
|
||||
console.log("Your mascot doesn't support yet audio files!")
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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)
|
||||
document.getElementsByClassName("form-input refine-category")[0].selectedIndex = document.getElementsByClassName("form-input form-category")[0].selectedIndex;
|
||||
e.preventDefault();
|
||||
document.getElementsByClassName("form-input refine-category")[0].selectedIndex = document.getElementsByClassName("form-input form-category")[0].selectedIndex
|
||||
e.preventDefault()
|
||||
if(document.getElementsByClassName("box refine")[0].style.display == "block")
|
||||
scrollTo(0, 0);
|
||||
});
|
||||
function humanFileSize(bytes, si) {
|
||||
var k = si ? 1000 : 1024;
|
||||
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";
|
||||
}
|
||||
|
||||
function flagCode(language) {
|
||||
split = language.split("-");
|
||||
if (split.length > 1) {
|
||||
return split[0];
|
||||
}
|
||||
return language;
|
||||
}
|
||||
scrollTo(0, 0)
|
||||
})
|
||||
function humanFileSize(bytes, si) {
|
||||
var k = si ? 1000 : 1024
|
||||
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"
|
||||
}
|
||||
// @license-end
|
||||
|
|
|
@ -38,6 +38,13 @@ var Templates = {
|
|||
}).
|
||||
replace(/</g, '<').
|
||||
replace(/>/g, '>');
|
||||
},
|
||||
FlagCode: function(language) {
|
||||
var split = language.split("-")
|
||||
if (split.length > 1) {
|
||||
return split[1]
|
||||
}
|
||||
return language
|
||||
}
|
||||
};
|
||||
// @license-end
|
||||
|
|
|
@ -21,7 +21,7 @@ Templates.Add("torrents.item", function(torrent) {
|
|||
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
||||
{{end}}
|
||||
"<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>"+
|
||||
"</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>"+
|
||||
|
|
|
@ -16,7 +16,7 @@ Templates.Add("torrents.item", function(torrent) {
|
|||
"<div class=\"nyaa-cat nyaa-cat-"+ torrent.sub_category +"\">"+
|
||||
{{end}}
|
||||
"<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>"+
|
||||
"</div></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