2023-07-04 17:00:23 +02:00
"using strict" ;
2023-07-15 21:45:04 +02:00
const menus = [ { "name" : "Fruit" , "items" : [ "Banana" , "Orange" , "Pineapple" , "Apple" ] , "description" : "What it says on the tin." } , { "name" : "Genre" , "items" : [ "FFP" , "Jiminy Cockthroat" , "しひろ Cockthroat" , "Spunk Gargle Weewee" ] , "description" : "Overal genre of the thinky thing" } ] ;
2023-07-04 22:27:06 +02:00
const menuContainer = document . getElementById ( 'menu-container' ) ;
menus . forEach ( menu => {
const dropdownMenu = document . createElement ( 'menu' ) ;
const menuTitle = Object . assign ( document . createElement ( 'h2' ) , { innerHTML : menu . name } ) ;
2023-07-15 21:45:04 +02:00
const description = Object . assign ( document . createElement ( 'p' ) , { innerHTML : menu . description } ) ;
2023-07-04 22:27:06 +02:00
const dropdownSelect = document . createElement ( 'select' ) ;
dropdownMenu . id = menu . name . toLowerCase ( ) ;
2023-07-05 13:47:16 +02:00
dropdownMenu . className = "dropdown-menu" ;
dropdownMenu . appendChild ( menuTitle )
2023-07-15 21:45:04 +02:00
dropdownMenu . appendChild ( description )
2023-07-04 22:27:06 +02:00
menuContainer . appendChild ( dropdownMenu )
dropdownMenu . appendChild ( dropdownSelect )
menu . items . forEach ( item => {
dropdownSelect . append ( Object . assign ( document . createElement ( 'option' ) , { id : item . toLowerCase ( ) , innerHTML : item } ) )
} )
2023-11-01 17:13:20 +01:00
} )
document . getElementById ( 'import' ) . onclick = function ( ) {
const files = document . getElementById ( 'selectFiles' ) . files ;
if ( files . length <= 0 ) {
return false ;
}
var fr = new FileReader ( ) ;
fr . onload = function ( e ) {
console . log ( e ) ;
var result = JSON . parse ( e . target . result ) ;
var formatted = JSON . stringify ( result , null , 2 ) ;
document . getElementById ( 'result' ) . value = formatted ;
}
fr . readAsText ( files . item ( 0 ) ) ;
} ;