2017-05-07 18:19:37 +02:00
function toggleNightMode ( ) {
2017-05-07 20:49:59 +02:00
var night = localStorage . getItem ( "night" ) ;
if ( night == "true" ) {
2017-05-13 23:07:49 +02:00
document . getElementsByTagName ( "head" ) [ 0 ] . removeChild ( darkStyleLink ) ;
2017-05-07 20:49:59 +02:00
} else {
2017-05-13 23:07:49 +02:00
document . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( darkStyleLink ) ;
2017-05-07 18:19:37 +02:00
}
2017-05-07 20:49:59 +02:00
localStorage . setItem ( "night" , ( night == "true" ) ? "false" : "true" ) ;
2017-05-07 18:19:37 +02:00
}
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
2017-05-17 13:21:48 +02:00
var lang = $ ( "html" ) . attr ( "lang" ) ;
2017-05-18 02:43:17 +02:00
var ymdOpt = { year : "numeric" , month : "short" , day : "numeric" } ;
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-17 13:21:48 +02:00
e . innerText = new Date ( e . innerText ) . toLocaleString ( lang , shortOpt ) ;
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
2017-05-18 01:21:57 +02:00
var list = document . getElementsByClassName ( "date-comments" ) ;
for ( var i in list ) {
var e = list [ i ] ;
e . title = e . innerText ;
2017-05-18 02:43:17 +02:00
e . innerText = new Date ( e . title ) . toLocaleDateString ( lang , ymdOpt ) + " " ;
$ ( e ) . append ( $ ( '<span class="hidden-xs"></span>' ) . text ( new Date ( e . title ) . toLocaleTimeString ( lang , hmOpt ) ) )
2017-05-18 01:21:57 +02:00
}
2017-05-13 00:37:37 +02:00
/*Fixed-Navbar offset fix*/
window . onload = function ( ) {
var shiftWindow = function ( ) { scrollBy ( 0 , - 70 ) } ;
if ( location . hash ) shiftWindow ( ) ;
window . addEventListener ( "hashchange" , shiftWindow ) ;
2017-05-18 02:43:17 +02:00
} ;