Merge branch 'dev' of https://github.com/NyaaPantsu/nyaa into dev
Cette révision appartient à :
révision
18813627be
3 fichiers modifiés avec 71 ajouts et 43 suppressions
|
@ -125,6 +125,10 @@ body {
|
|||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.header .h-search {
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.header .h-search .form-input {
|
||||
font-size: 80%;
|
||||
line-height: 18px;
|
||||
|
|
|
@ -3,21 +3,21 @@
|
|||
|
||||
// Switches between themes when a new one is selected
|
||||
|
||||
function switchThemes(){
|
||||
function switchThemes() {
|
||||
themeName = document.getElementById("theme-selector").value
|
||||
var head = document.getElementsByTagName("head")[0]
|
||||
// Remove the theme in place, it fails if one isn't set
|
||||
try{
|
||||
try {
|
||||
head.removeChild(document.getElementById("theme"))
|
||||
} catch(err){}
|
||||
} catch (err) {}
|
||||
// Don't add a node if we don't want extra styling
|
||||
if(themeName === ""){
|
||||
if (themeName === "") {
|
||||
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("href", "/css/" + themeName + ".css")
|
||||
newTheme.setAttribute("id", "theme")
|
||||
head.appendChild(newTheme)
|
||||
}
|
||||
|
@ -30,21 +30,29 @@ function toggleLayer(elem) {
|
|||
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 ymdOpt = {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric"
|
||||
}
|
||||
var hmOpt = {
|
||||
hour: "numeric",
|
||||
minute: "numeric"
|
||||
}
|
||||
|
||||
var list = document.getElementsByClassName("date-short")
|
||||
for(var i in list) {
|
||||
for (var i in list) {
|
||||
var e = list[i]
|
||||
e.title = e.innerText
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang, ymdOpt)
|
||||
}
|
||||
|
||||
var list = document.getElementsByClassName("date-full")
|
||||
for(var i in list) {
|
||||
for (var i in list) {
|
||||
var e = list[i]
|
||||
e.title = e.innerText
|
||||
e.innerText = new Date(e.innerText).toLocaleString(lang)
|
||||
|
@ -54,46 +62,61 @@ function parseAllDates() {
|
|||
parseAllDates()
|
||||
|
||||
|
||||
//if no version cookie set or non-equal version
|
||||
if(!document.cookie.includes("version") || (document.cookie.substring(document.cookie.indexOf("version") + 8).substring(0, document.cookie.substring(document.cookie.indexOf("version") + 8).indexOf(";") == "-1" ? document.cookie.substring(document.cookie.indexOf("version") + 8).length : document.cookie.substring(document.cookie.indexOf("version") + 8).indexOf(";"))) != Version)
|
||||
{
|
||||
//Get current lang, mascot & theme cookies
|
||||
//TODO
|
||||
//called if no Commit cookie is set or if the website has a newer commit than the one in cookie
|
||||
function resetCookies() {
|
||||
var cookies = document.cookie.split(";");
|
||||
var excludedCookies = ["mascot", "theme", "mascot_url", "lang"];
|
||||
|
||||
//Remove all cookies:
|
||||
var cookies = document.cookie.split(";");
|
||||
var excludedCookies = ["mascot", "theme", "mascot_url", "lang"];
|
||||
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookieName = (cookies[i].split("=")[0]).trim();
|
||||
//Remove spaces because some cookie names have it
|
||||
if(excludedCookies.includes(cookieName)) continue;
|
||||
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
||||
}
|
||||
|
||||
//Set new version in cookie
|
||||
document.cookie = "version=" + Version;
|
||||
|
||||
//Apply back lang, mascot & theme cookie
|
||||
//TODO
|
||||
|
||||
//Add fancy "new" text at bottom of page
|
||||
document.getElementById("commit").className = "new";
|
||||
//Remove all cookies but exclude those in the above array
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookieName = (cookies[i].split("=")[0]).trim();
|
||||
//Remove spaces because some cookie names have it
|
||||
if (excludedCookies.includes(cookieName)) continue;
|
||||
document.cookie = cookieName + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
||||
}
|
||||
|
||||
//Set new version in cookie
|
||||
document.cookie = "commit=" + commitVersion;
|
||||
|
||||
//add fancy "new" text at bottom of page which will expire in one hour and a half
|
||||
var now = new Date();
|
||||
now.setTime(now.getTime() + 1 * 3600 * 1500);
|
||||
document.cookie = "newVersion=true; expires=" + now.toUTCString();
|
||||
}
|
||||
|
||||
|
||||
/*Fixed-Navbar offset fix*/
|
||||
if(document.getElementsByClassName("search-box")[0] !== undefined)
|
||||
if (document.getElementsByClassName("search-box")[0] !== undefined)
|
||||
startupCode()
|
||||
else
|
||||
document.addEventListener("DOMContentLoaded", function(event) { startupCode() })
|
||||
document.addEventListener("DOMContentLoaded", function (event) {
|
||||
startupCode()
|
||||
})
|
||||
|
||||
|
||||
function startupCode() {
|
||||
var shiftWindow = function() { scrollBy(0, -70) }
|
||||
var shiftWindow = function () {
|
||||
scrollBy(0, -70)
|
||||
}
|
||||
if (location.hash) shiftWindow()
|
||||
window.addEventListener("hashchange", shiftWindow)
|
||||
|
||||
if (!document.cookie.includes("commit"))
|
||||
resetCookies()
|
||||
else {
|
||||
var startPos = document.cookie.indexOf("commit") + 7,
|
||||
endPos = document.cookie.substring(startPos).indexOf(";"),
|
||||
userCommitVersion = endPos == "-1" ? document.cookie.substring(startPos) : document.cookie.substring(startPos, endPos + startPos);
|
||||
//Get start and end position of Commit string, need to start searching endPos from version cookie in case it's not the first cookie in the string
|
||||
//If endPos is equal to -1, aka if the version cookie is at the very end of the string and doesn't have an ";", the endPos is not used
|
||||
|
||||
if (userCommitVersion != commitVersion)
|
||||
resetCookies()
|
||||
}
|
||||
|
||||
if (document.cookie.includes("newVersion"))
|
||||
document.getElementById("commit").className = "new";
|
||||
|
||||
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"
|
||||
|
@ -106,7 +129,7 @@ function startupCode() {
|
|||
}
|
||||
|
||||
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()
|
||||
|
@ -117,17 +140,18 @@ function playVoice() {
|
|||
|
||||
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"
|
||||
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
|
||||
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
|
||||
e.preventDefault()
|
||||
if(document.getElementsByClassName("box refine")[0].style.display == "block")
|
||||
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"
|
||||
return i == 0 ? bytes + " B" : (bytes / Math.pow(k, i)).toFixed(1) + " " + "KMGTPEZY" [i - 1] + (si ? "" : "i") + "B"
|
||||
}
|
||||
// @license-end
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
},
|
||||
{
|
||||
"id": "torrents_uploaded",
|
||||
"translation": "Torrent はアップロードされました"
|
||||
"translation": "Torrent アップロード数"
|
||||
},
|
||||
{
|
||||
"id": "category",
|
||||
|
@ -1645,7 +1645,7 @@
|
|||
},
|
||||
{
|
||||
"id": "search_for",
|
||||
"translation": "以下を検索:"
|
||||
"translation": "以下を検索"
|
||||
},
|
||||
{
|
||||
"id": "show",
|
||||
|
|
Référencer dans un nouveau ticket