2024-06-05 06:41:43 +00:00
/ * * V a n i l l a J S d o e s n o t a l l o w d y n a m i c a l l y f e t c h i n g f i l e s i n a l o c a l d i r e c t o r y . W e h a v e t o h a r d c o d e t h e l i s t t o l o o p o v e r .
* Each entry is the name of a subfolder in /docs/ .
* /
2024-06-10 03:26:06 +00:00
const docs _post _names = [
2024-06-05 06:41:43 +00:00
"items_adv_help" ,
2024-06-10 03:26:06 +00:00
"damage_calc" ,
"powders"
2024-06-05 06:41:43 +00:00
]
2024-06-10 03:26:06 +00:00
/ * * M a p o f
* Key : post _name - the subdirectory name also present in docs _post _names
* Value : [ Title , Summary , Author ( s ) ]
* /
docs _post _thumbnails = new Map ( ) ;
docs _post _thumbnails . set ( "items_adv_help" , [ "Advanced Item Search Help" , "A practical guide on how to use WynnBuilder's advanced item search feature." , "Phanta" ] ) ;
docs _post _thumbnails . set ( "damage_calc" , [ "Damage Calculation" , "All the ins and outs of Wynncraft damage calculation. Includes spells, powder specials, abilities, and major IDs!" , "hppeng, ferricles" ] ) ;
docs _post _thumbnails . set ( "powders" , [ "Weapon Powder Application" , "Read this to learn the mechanics of powder application on weapons!" , "ferricles, hppeng" ] ) ;
2024-06-05 06:41:43 +00:00
/ * * P o p u l a t e s t h e H T M L e l e m e n t w i t h t h e i d ' p o s t - l i s t '
*
* /
function populate _post _previews ( ) {
post _list _parent = document . getElementById ( 'post-list' ) ;
2024-06-10 03:26:06 +00:00
docs _post _names . forEach ( ( post _name ) => {
2024-06-05 06:41:43 +00:00
post = document . createElement ( 'article' ) ;
2024-06-10 03:26:06 +00:00
post _info = docs _post _thumbnails . get ( post _name ) ;
console . log ( post _info ) ;
if ( post _info == undefined ) {
return ;
}
2024-06-05 06:41:43 +00:00
title = document . createElement ( 'h2' ) ;
2024-06-10 03:26:06 +00:00
title . innerHTML = post _info [ 0 ] ;
2024-06-05 06:41:43 +00:00
post . appendChild ( title ) ;
summary = document . createElement ( 'p' ) ;
2024-06-10 03:26:06 +00:00
summary . innerHTML = post _info [ 1 ] ;
2024-06-05 06:41:43 +00:00
post . appendChild ( summary ) ;
2024-06-10 03:26:06 +00:00
authors = document . createElement ( 'p' ) ;
authors . innerHTML = "Author(s): " + post _info [ 2 ] ;
post . appendChild ( authors ) ;
2024-06-05 06:41:43 +00:00
link = document . createElement ( "a" ) ;
2024-06-10 03:26:06 +00:00
link . setAttribute ( 'href' , ` /wynnfo/ ${ post _name } / ` ) ;
2024-06-05 06:41:43 +00:00
post . appendChild ( link ) ;
post _list _parent . appendChild ( post ) ;
} ) ;
2024-06-10 03:26:06 +00:00
}
function initDropdownSections ( ) {
dropdowns = document . querySelectorAll ( 'span.dropdown' ) ;
for ( const dropdown of dropdowns ) {
let inner _content = dropdown . children [ 0 ]
dropdown . classList . add ( "up" , "row" ) ;
let title = document . createElement ( "div" ) ;
title . classList . add ( "col-10" , "item-title" , "text-start" , "dropdown-title" )
title . style . margin = "0 0 0" ;
2024-06-10 05:09:52 +00:00
title . style . fontWeight = "bold" ;
title . style . fontSize = 18 ;
title . style . textDecoration = "underline" ;
2024-06-10 03:26:06 +00:00
title . textContent = dropdown . title ;
dropdown . textContent = "" ;
let indicator = document . createElement ( "div" ) ;
indicator . classList . add ( "col-auto" , "fw-bold" , "box-title" ) ;
indicator . textContent = "+" ;
dropdown . prepend ( indicator ) ;
dropdown . prepend ( title ) ;
dropdown . appendChild ( inner _content ) ;
inner _content . style . display = "none" ;
title . addEventListener ( "click" , function ( ) {
if ( dropdown . classList . contains ( "up" ) ) {
dropdown . classList . remove ( "up" ) ;
dropdown . classList . add ( "down" ) ;
indicator . textContent = "-" ;
inner _content . style . display = "" ;
} else {
dropdown . classList . remove ( "down" ) ;
dropdown . classList . add ( "up" ) ;
indicator . textContent = "+" ;
inner _content . style . display = "none" ;
}
} ) ;
title . addEventListener ( "mouseover" , function ( ) {
title . style . color = "#ddd" ;
2024-06-10 05:09:52 +00:00
// title.style.fontWeight = "bold";
2024-06-10 03:26:06 +00:00
indicator . style . color = "#ddd" ;
2024-06-10 05:09:52 +00:00
// indicator.style.fontWeight = "bold";
2024-06-10 03:26:06 +00:00
} ) ;
title . addEventListener ( "mouseleave" , function ( ) {
title . style . color = "" ;
2024-06-10 05:09:52 +00:00
// title.style.fontWeight = "normal";
2024-06-10 03:26:06 +00:00
indicator . style . color = "" ;
2024-06-10 05:09:52 +00:00
// indicator.style.fontWeight = "normal";
2024-06-10 03:26:06 +00:00
} ) ;
}
2024-06-05 06:41:43 +00:00
}