2017-05-26 13:13:06 +02:00
var explosion = document . getElementById ( "explosion" ) ;
var nyanpassu = document . getElementById ( "nyanpassu" ) ;
2017-05-07 18:19:37 +02:00
function toggleNightMode ( ) {
2017-05-20 01:10:16 +02:00
var night = localStorage . getItem ( "night" ) ;
if ( night == "true" ) {
document . getElementsByTagName ( "head" ) [ 0 ] . removeChild ( darkStyleLink ) ;
} else {
document . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( darkStyleLink ) ;
}
localStorage . setItem ( "night" , ( night == "true" ) ? "false" : "true" ) ;
2017-05-07 18:19:37 +02:00
}
2017-05-27 19:08:47 +02:00
// 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 ) ;
}
function toggleMascot ( btn ) {
var state = btn . value ;
if ( state == "hide" ) {
btn . innerHTML = "Mascot" ;
document . getElementById ( "mascot" ) . className = "hide" ;
btn . value = "show" ;
} else {
btn . innerHTML = "Mascot" ;
document . getElementById ( "mascot" ) . className = "" ;
btn . value = "hide" ;
}
}
2017-05-05 12:59:56 +02:00
// Used by spoiler tags
function toggleLayer ( elem ) {
if ( elem . classList . contains ( "hide" ) )
elem . classList . remove ( "hide" ) ;
else
elem . classList . add ( "hide" ) ;
}
2017-05-05 15:55:25 +02:00
2017-05-17 16:05:42 +02:00
// Date formatting
Frontend rewrite (DONE) (#723)
* Remove Bootstrap and Jquery, and create basic nav
* More improvements to navbar, as well as work on _badgemenu
* Complete navbar HTML, obviously it still looks horrendous
* Change layout on torrent table, using grids.
* Remove Bootstrap and Jquery, and create basic nav
* More improvements to navbar, as well as work on _badgemenu
* Complete navbar HTML, obviously it still looks horrendous
* Change layout on torrent table, using grids.
* HOLY FUCK INDEX IS /DONE/
* DO UPLOAD PAGE, DELETE OLD SHITTY CSS
* Complete login page
* Remove Bootstrap and Jquery, and create basic nav
* More improvements to navbar, as well as work on _badgemenu
* Complete navbar HTML, obviously it still looks horrendous
* Change layout on torrent table, using grids.
* Remove Bootstrap and Jquery, and create basic nav
* More improvements to navbar, as well as work on _badgemenu
* Complete navbar HTML, obviously it still looks horrendous
* HOLY FUCK INDEX IS /DONE/
* DO UPLOAD PAGE, DELETE OLD SHITTY CSS
* Complete login page
* Begin work on profile page
* fucking git, man
* Damn, that looks sexy
* Complete login and register pages, include very minimal grid system, and delete all of view template
* Do view page!
* Finish view even more
* Fix dates and filesizes in torrent table
* Improve comment/captcha input
* Actually add magnet and torrent buttons
* Add open-iconic instead of fontawesome
* Improve user side-panel
* Rename Category_* to CategoryName
* Beginning to finish up
* Implement themes and add basic mobile support to front page
* Fix some slight color errors
* Fix captcha on dark
* magnet and torrent links on view
2017-05-24 06:20:51 +02:00
var lang = document . getElementsByTagName ( "html" ) [ 0 ] . getAttribute ( "lang" ) ;
2017-05-27 14:14:14 +02:00
var ymdOpt = { year : "numeric" , month : "short" , day : "numeric" } ;
2017-05-18 02:43:17 +02:00
var hmOpt = { hour : "numeric" , minute : "numeric" } ;
2017-05-05 15:55:25 +02:00
var list = document . getElementsByClassName ( "date-short" ) ;
for ( var i in list ) {
var e = list [ i ] ;
e . title = e . innerText ;
2017-05-18 02:44:36 +02:00
e . innerText = new Date ( e . innerText ) . toLocaleString ( lang , ymdOpt ) ;
2017-05-05 15:55:25 +02:00
}
var list = document . getElementsByClassName ( "date-full" ) ;
for ( var i in list ) {
var e = list [ i ] ;
e . title = e . innerText ;
2017-05-17 13:21:48 +02:00
e . innerText = new Date ( e . innerText ) . toLocaleString ( lang ) ;
2017-05-05 15:55:25 +02:00
}
2017-05-13 00:37:37 +02:00
/*Fixed-Navbar offset fix*/
2017-05-29 13:12:05 +02:00
document . addEventListener ( "DOMContentLoaded" , function ( event ) {
2017-05-20 01:10:16 +02:00
var shiftWindow = function ( ) { scrollBy ( 0 , - 70 ) } ;
if ( location . hash ) shiftWindow ( ) ;
window . addEventListener ( "hashchange" , shiftWindow ) ;
2017-05-28 02:23:47 +02:00
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" ;
} ) ;
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" ;
} ) ;
2017-05-29 13:12:05 +02:00
// Keep mascot hiding choice
var hideMascot = ( localStorage . getItem ( "hide_mascot" ) == "true" )
if ( hideMascot ) {
var btn = document . getElementById ( "mascotKeepHide" ) ;
btn . innerHTML = "Mascot" ;
document . getElementById ( "mascot" ) . className = "hide" ;
btn . value = "show" ;
}
} ) ;
2017-05-26 13:13:06 +02:00
function playVoice ( ) {
2017-05-27 23:33:52 +02:00
if ( explosion ) {
2017-05-26 13:13:06 +02:00
explosion . play ( ) ;
2017-05-27 23:33:52 +02:00
}
else {
2017-05-26 13:13:06 +02:00
nyanpassu . volume = 0.5 ;
nyanpassu . play ( ) ;
}
2017-05-29 13:12:05 +02:00
}
function toggleMascot ( btn ) {
var state = btn . value ;
if ( state == "hide" ) {
btn . innerHTML = "Mascot" ;
document . getElementById ( "mascot" ) . className = "hide" ;
btn . value = "show" ;
localStorage . setItem ( "hide_mascot" , "true" )
} else {
btn . innerHTML = "Mascot" ;
document . getElementById ( "mascot" ) . className = "" ;
btn . value = "hide" ;
localStorage . setItem ( "hide_mascot" , "false" )
}
2017-05-28 02:23:47 +02:00
}