You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
const $ = sel => document . querySelector ( sel )
const $$ = sel => Array . from ( document . querySelectorAll ( sel ) )
const create _elm = str => {
const div = document . createElement ( 'div' )
div . innerHTML = str
return Array . from ( div . childNodes )
}
const flash _msg = ( message ) => {
const elm = create _elm ( '<div class="flash-msg flex"><span class="flex-grow">' + message + '</span> <span class="close-btn">× </span></div>' ) [ 0 ]
$ ( 'main .container' ) . prepend ( elm )
elm . querySelector ( '.close-btn' ) . addEventListener ( 'click' , e => elm . remove ( ) )
}
onload ( ( ) => {
// remove flash messages when close button is clicked
$$ ( '.flash-msg .close-btn' ) . forEach ( elm => elm . addEventListener ( 'click' , e => {
elm . parentElement . remove ( )
} ) )
} )