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

@@ -7,6 +7,15 @@ function render_event_records() {
//console.log(tbl_event);
//console.log(event_id);
if (looping_tbl_event) {
console.log('Already looping through the tbl_event table. Not starting until finished.');
return false;
} else {
}
looping_tbl_event = true;
tbl_event.iterate(function(value, key, iteration) {
if (value.id == event_id) {
console.log('*** Event id ('+event_id+') found in table.');
@@ -17,7 +26,8 @@ function render_event_records() {
}
}).then(function() {
console.log('idb_to_ui: Iterate tbl_event_file complete')
tbl_event_complete = true;
//tbl_event_complete = true;
looping_tbl_event = false;
});
}
@@ -27,6 +37,15 @@ function render_event_records() {
async function render_event_location_records() {
console.log('Rendering event location records...');
if (looping_tbl_event_location) {
console.log('Already looping through the tbl_event_location table. Not starting until finished.');
return false;
} else {
}
looping_tbl_event_location = true;
await tbl_event_location.iterate(function(value, key, iteration) {
if (value.id == event_location_id) {
console.log('*** Event location id ('+event_location_id+') found in table.');
@@ -45,7 +64,8 @@ async function render_event_location_records() {
}
}).then(function() {
console.log('idb_to_ui: Iterate tbl_event_file complete')
tbl_event_location_complete = true;
//tbl_event_location_complete = true;
looping_tbl_event_location = false;
});
return true;
@@ -89,23 +109,34 @@ function view_session(session_id) {
/* Updated 2020-02-13 */
function index_open_file_buttons(class_name) {
console.log('Indexing open file buttons...');
console.log('****************** Indexing ******************');
var class_elements = document.getElementsByClassName(class_name);
console.log(class_elements);
for (var i = 0; i < class_elements.length; i++) {
// Do not use an anonymous function. If you do then it will keep adding event listeners.
// Adding the exact same event listeners over and over doesn't hurt anything.
// No need to use removeEventListener()
class_elements[i].addEventListener( 'click', open_local_file );
/*
let hash = class_elements[i].getAttribute('data-hash_sha256');
let file_path = path.join(host_file_cache_path, hash);
let filename = class_elements[i].getAttribute('data-filename');
class_elements[i].addEventListener( 'click', function() { ipcRenderer.send('open_local_file', file_path, filename) } );
*/
}
return true;
}
/* Updated 2020-02-13 */
function open_local_file(element) {
console.log(element);
let file_path = path.join(host_file_cache_path, element.getAttribute('data-hash_sha256'));
let filename = element.getAttribute('data-filename');
function open_local_file() {
//console.log(this);
let hash = this.getAttribute('data-hash_sha256');
let file_path = path.join(host_file_cache_path, hash);
let filename = this.getAttribute('data-filename');
console.log(file_path);
console.log(filename);