<commit_before>// @source https://github.com/NyaaPantsu/nyaa/tree/dev/public/js
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat

// Switches between themes when a new one is selected

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{
    head.removeChild(document.getElementById("theme"))
  } catch(err){}
  // Don't add a node if we don't want extra styling
  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("id", "theme")
  head.appendChild(newTheme)
}

// Used by spoiler tags
function toggleLayer(elem) {
  if (elem.classList.contains("hide")) {
    elem.classList.remove("hide")
  } else {
    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 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 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)
  }
}

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) {
		//Remove all cookies
		var cookies = document.cookie.split(";");
		for (var i = 0; i < cookies.length; i++)
			document.cookie = cookies[i].split("=")[0] + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
		//set new version in cookie
		document.cookie = "version=" + Version;
  }
		

/*Fixed-Navbar offset fix*/
if(document.getElementsByClassName("search-box")[0] !== undefined) 
	startupCode() 
else 
	document.addEventListener("DOMContentLoaded", function(event) { startupCode() })


function startupCode() {
	  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"
	  })<commit_msg>Update main.js<commit_after>// @source https://github.com/NyaaPantsu/nyaa/tree/dev/public/js
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat

// Switches between themes when a new one is selected

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{
    head.removeChild(document.getElementById("theme"))
  } catch(err){}
  // Don't add a node if we don't want extra styling
  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("id", "theme")
  head.appendChild(newTheme)
}

// Used by spoiler tags
function toggleLayer(elem) {
  if (elem.classList.contains("hide")) {
    elem.classList.remove("hide")
  } else {
    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 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 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)
  }
}

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
	  	var 	lang 		= null,
		    	mascot		= null,
				theme		= null;
	  
	  	if(document.cookie.includes("lang"))
	  		lang = (document.cookie.substring(document.cookie.indexOf("lang") + 5).substring(0, document.cookie.substring(document.cookie.indexOf("lang") + 5).indexOf(";") == "-1" ? document.cookie.substring(document.cookie.indexOf("lang") + 5).length : document.cookie.substring(document.cookie.indexOf("lang") + 5).indexOf(";")));
	  	if(document.cookie.includes("mascot"))
			mascot = (document.cookie.substring(document.cookie.indexOf("mascot") + 7).substring(0, document.cookie.substring(document.cookie.indexOf("mascot") + 7).indexOf(";") == "-1" ? document.cookie.substring(document.cookie.indexOf("mascot") + 7).length : document.cookie.substring(document.cookie.indexOf("mascot") + 7).indexOf(";")));
	  	if(document.cookie.includes("theme"))
			theme = (document.cookie.substring(document.cookie.indexOf("theme") + 6).substring(0, document.cookie.substring(document.cookie.indexOf("theme") + 6).indexOf(";") == "-1" ? document.cookie.substring(document.cookie.indexOf("theme") + 6).length : document.cookie.substring(document.cookie.indexOf("theme") + 6).indexOf(";")));

	 	 //Remove all cookies
		var cookies = document.cookie.split(";");
		for (var i = 0; i < cookies.length; i++)
			document.cookie = cookies[i].split("=")[0] + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
	  
		//Set new version in cookie
		document.cookie = "version=" + Version;
	  
	  	//Apply back lang, mascot & theme cookie
	  	if(lang != null)	document.cookie = "lang="+ lang;
	  	if(mascot != null)	document.cookie = "mascot="+ mascot;
	  	if(theme != null)	document.cookie = "theme="+ theme;
  }
		

/*Fixed-Navbar offset fix*/
if(document.getElementsByClassName("search-box")[0] !== undefined) 
	startupCode() 
else 
	document.addEventListener("DOMContentLoaded", function(event) { startupCode() })


function startupCode() {
	  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"
	  })
{'fraction_non_alphanumeric': 0.16722236470889973, 'fraction_numerical': 0.017183893305975893, 'mean_word_length': 4.606757728253055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5585682', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2489, 'n_words': 496}