From 3384c5337a41fa106ddc6ead9ee735add84daca0 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Wed, 4 Jan 2023 23:33:01 +1100 Subject: [PATCH] created toast.js with a StatusMsg() func that dynamically adds toasts that can stack as we need more, and changed over the move_files to use it --- internal/js/toast.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 internal/js/toast.js diff --git a/internal/js/toast.js b/internal/js/toast.js new file mode 100644 index 0000000..b1ec308 --- /dev/null +++ b/internal/js/toast.js @@ -0,0 +1,40 @@ +// create a bs toast in the status_container +function StatusMsg(st) +{ + // look for first '.hide' in #status_container (there may be more than 1) + if( $('.toast.hide').length !== 0 ) + { + tid=$('.toast.hide').first().attr('id') + $('#'+tid ).find( '.toast-body').html(st.message) + $('#'+tid ).removeClass( function( index, className ) { return (className.match( /(^|\s)bg-\S+/g) || []).join(' ') } ) + $('#'+tid ).addClass( 'bg-' + st.alert ) + $('#'+tid ).toast("show") + } + else + { + tmp=$('.toast').last().attr('id') + if( tmp== '' ) + tid=1 + else + { + // skip 'st' + tid=tmp.substr(2) + tid++ + } + div=' + ` + // can be appended straight after st1 as the .toast("show") deals with display ordering + $('#st1').append(div) + $('#st' + tid ).toast("show") + } +}