const COLOR = { gray : "gray" , brown : "brown" , orange : "orange" , yellow : "yellow" , green : "green" , teal : "teal" , blue : "blue" , purple : "purple" , pink : "pink" , red : "red" , grayBg : "gray_background" , brownBg : "brown_background" , orangeBg : "orange_background" , yellowBg : "yellow_background" , tealBg : "teal_background" , blueBg : "blue_background" , purpleBg : "purple_background" , pinkBg : "pink_background" , redBg : "red_background" } ; param color returns export function convertColor ( color ? ) { const colorPrefix = `Color` ; const bgPrefix = `Bg` ; switch ( color ) { case COLOR . gray : return colorPrefix + "Gray" ; case COLOR . brown : return colorPrefix + "Brown" ; case COLOR . orange : return colorPrefix + "Orange" ; case COLOR . yellow : return colorPrefix + "Yellow" ; case COLOR . green : case COLOR . teal : return colorPrefix + "Green" ; case COLOR . blue : return colorPrefix + "Blue" ; case COLOR . purple : return colorPrefix + "Purple" ; case COLOR . pink : return colorPrefix + "Pink" ; case COLOR . red : return colorPrefix + "Red" ; case COLOR . grayBg : return bgPrefix + "Gray" ; case COLOR . brownBg : return bgPrefix + "Brown" ; case COLOR . orangeBg : return bgPrefix + "Orange" ; case COLOR . yellowBg : return bgPrefix + "Yellow" ; case COLOR . tealBg : return bgPrefix + "Green" ; case COLOR . blueBg : return bgPrefix + "Blue" ; case COLOR . purpleBg : return bgPrefix + "Purple" ; case COLOR . pinkBg : return bgPrefix + "Pink" ; case COLOR . redBg : return bgPrefix + "Red" ; default : return colorPrefix + "Default" ; } } param color returns export function colorfulBlock ( color ? ) { const blockName = "ColorfulBlock" ; return `${ blockName } ${ blockName }--${ convertColor ( color ) }` ; } see https see https param str returns export function escapeString ( str ? ) { if ( ! str ) return "" ; let character , escapedString = "" ; for ( let i = 0 ; i < str . length ; ++ i ) { character = str . charAt ( i ) ; switch ( character ) { case "<" : escapedString += "&lt;" ; break ; case ">" : escapedString += "&gt;" ; break ; case "&" : escapedString += "&amp;" ; break ; case "'" : escapedString += "&#x27;" ; break ; case "\"" : escapedString += "&quot;" ; break ; default : escapedString += character ; } } return escapedString ; } export function prettyTime ( jsHour , jsMinute ) { const ampm = jsHour >= 12 ? "PM" : "AM" ; const hour = ( jsHour % 12 ) ? ( jsHour % 12 ) : 12 ; return `${ hour }:${ jsMinute . toString ( ) . padStart ( 2 , "0" ) } ${ ampm }` ; } export function prettyDate ( timestamp ) { const d = new Date ( timestamp ) ; const monthAbbrs = [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ] ; const month = monthAbbrs [ d . getMonth ( ) ] ; const date = d . getDate ( ) ; const year = d . getFullYear ( ) ; const hour = d . getHours ( ) ; const minute = d . getMinutes ( ) ; return `${ month } ${ date }, ${ year } ${ prettyTime ( hour , minute ) }` ; }