More clean up of the JS code.

This commit is contained in:
Scott Idem
2020-02-19 16:35:21 -05:00
parent 46f0762511
commit 41afab59dd
9 changed files with 167 additions and 109 deletions

View File

@@ -2,6 +2,15 @@
async function render_event_session_records() {
console.log('Rendering event session records...');
if (looping_tbl_event_session) {
console.log('Already looping through the tbl_event_session table. Not starting until finished.');
return false;
} else {
}
looping_tbl_event_session = true;
// First: update or add sessions
tbl_event_session.iterate(function(value, key, iteration) {
if (value.event_id == event_id && value.event_location_id == event_location_id) {
@@ -21,7 +30,7 @@ async function render_event_session_records() {
// Add the new session to the session menu
let node = document.createElement('LI');
node.id = 'menu_event_session_'+value.id;
node.className = 'list-group-item btn btn-info d-flex justify-content-between align-items-center btn_view_session';
node.className = 'list-group-item btn btn-success d-flex justify-content-between align-items-center btn_view_session';
node.setAttribute('data-session_id', value.id);
node.title = 'id='+value.id+' session_id='+value.id;
@@ -128,7 +137,7 @@ async function render_event_session_records() {
}
}).then(function() {
console.log('idb_to_ui: Iterate tbl_event_session complete');
tbl_event_session_complete = true;
//tbl_event_session_complete = true;
}).then(function() {
// Second: remove sessions from the launcher sessions menu and sessions list
// This is basing the removal of sessions only on the menu list of sessions.
@@ -143,6 +152,9 @@ async function render_event_session_records() {
if (session_list_items.length) {
for (let i=0, len=session_list_items.length; i < len; i++) {
console.log('Checking session_id='+session_list_items[i].getAttribute('data-session_id'));
looping_tbl_event_session = true;
let session_id = session_list_items[i].getAttribute('data-session_id');
let session_valid = false;
@@ -164,9 +176,13 @@ async function render_event_session_records() {
document.getElementById('menu_event_session_'+session_id).remove(); // Remove the node from the launcher sessions menu list
document.getElementById('detail_session_'+session_id).remove(); // Remove the node from the launcher sessions list
}
looping_tbl_event_session = false;
});
}
}
looping_tbl_event_session = false;
});
// Third: re-index view session buttons