Working on rewrite version 3. Focus on caching for now.
This commit is contained in:
@@ -3,178 +3,178 @@ const { ipcRenderer } = require('electron');
|
||||
|
||||
//exports.render_event_records = function () {
|
||||
async function render_event_records() {
|
||||
console.log('****************** Events ******************');
|
||||
console.log('Rendering 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.');
|
||||
document.getElementById('event_name').innerHTML = '@'+value.name;
|
||||
document.getElementById('event_files_menu').getElementsByTagName('ul')[0].id = 'event_files_list_'+value.id;
|
||||
console.log('****************** Events ******************');
|
||||
console.log('Rendering 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 {
|
||||
console.log('Event not it.');
|
||||
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
//tbl_event_complete = true;
|
||||
looping_tbl_event = false;
|
||||
});
|
||||
|
||||
|
||||
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.');
|
||||
document.getElementById('event_name').innerHTML = '@'+value.name;
|
||||
document.getElementById('event_files_menu').getElementsByTagName('ul')[0].id = 'event_files_list_'+value.id;
|
||||
} else {
|
||||
console.log('Event not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
//tbl_event_complete = true;
|
||||
looping_tbl_event = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
//exports.render_event_location_records = async function () {
|
||||
async function render_event_location_records() {
|
||||
console.log('****************** Locations ******************');
|
||||
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.');
|
||||
document.getElementById('location_name').innerHTML = '<span class="fas fa-map-marker"></span> '+value.name;
|
||||
|
||||
document.getElementById('location_files_menu').getElementsByTagName('ul')[0].id = 'location_files_list_'+value.id;
|
||||
/*
|
||||
let location_files_ul_node = document.createElement('UL');
|
||||
location_files_ul_node.id = 'event_presentation_files_list_'+value.id;
|
||||
location_files_ul_node.className = 'list-group list-group-flush location_files location_files_list event_files_list';
|
||||
|
||||
document.getElementById('location_files_menu').appendChild(location_files_ul_node);
|
||||
*/
|
||||
console.log('****************** Locations ******************');
|
||||
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 {
|
||||
console.log('Event location not it.');
|
||||
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
//tbl_event_location_complete = true;
|
||||
looping_tbl_event_location = false;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
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.');
|
||||
document.getElementById('location_name').innerHTML = '<span class="fas fa-map-marker"></span> '+value.name;
|
||||
|
||||
document.getElementById('location_files_menu').getElementsByTagName('ul')[0].id = 'location_files_list_'+value.id;
|
||||
/*
|
||||
let location_files_ul_node = document.createElement('UL');
|
||||
location_files_ul_node.id = 'event_presentation_files_list_'+value.id;
|
||||
location_files_ul_node.className = 'list-group list-group-flush location_files location_files_list event_files_list';
|
||||
|
||||
document.getElementById('location_files_menu').appendChild(location_files_ul_node);
|
||||
*/
|
||||
} else {
|
||||
console.log('Event location not it.');
|
||||
}
|
||||
}).then(function() {
|
||||
console.log('idb_to_ui: Iterate tbl_event_file complete')
|
||||
//tbl_event_location_complete = true;
|
||||
looping_tbl_event_location = false;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2020-01-31 */
|
||||
function index_launcher_sessions(class_name) {
|
||||
console.log('Indexing launcher sessions with class name: '+class_name);
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
console.log(class_elements);
|
||||
return true;
|
||||
console.log('Indexing launcher sessions with class name: '+class_name);
|
||||
var class_elements = document.getElementsByClassName(class_name);
|
||||
|
||||
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
class_elements[i].addEventListener( 'click', function() {view_session( this.getAttribute('data-session_id')) } );
|
||||
}
|
||||
console.log(class_elements);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2020-01-31 */
|
||||
function view_session(session_id) {
|
||||
var class_elements = document.getElementsByClassName('session_detail'); // This class name should be the class names for each div container
|
||||
console.log('View session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
//console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
//console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
var class_elements = document.getElementsByClassName('session_detail'); // This class name should be the class names for each div container
|
||||
console.log('View session ID: '+session_id);
|
||||
for (var i = 0; i < class_elements.length; i++) {
|
||||
//console.log('*** checking: '+class_elements[i].getAttribute('data-session_id'));
|
||||
if (class_elements[i].getAttribute('data-session_id') == session_id) {
|
||||
//console.log('show');
|
||||
class_elements[i].classList.remove('d-none');
|
||||
class_elements[i].classList.add('d-block');
|
||||
} else {
|
||||
//console.log('hide');
|
||||
class_elements[i].classList.remove('d-block');
|
||||
class_elements[i].classList.add('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* Updated 2020-02-13 */
|
||||
function index_open_file_buttons(class_name) {
|
||||
console.log('****************** Indexing ******************');
|
||||
console.log('Indexing open file buttons...');
|
||||
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;
|
||||
console.log('****************** Indexing ******************');
|
||||
console.log('Indexing open file buttons...');
|
||||
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() {
|
||||
//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);
|
||||
|
||||
ipcRenderer.send('open_local_file', file_path, filename);
|
||||
//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);
|
||||
|
||||
ipcRenderer.send('open_local_file', file_path, filename);
|
||||
}
|
||||
|
||||
|
||||
function format_bytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
function shorten_filename(filename) {
|
||||
let length = filename.length;
|
||||
let char_over = filename.length-45;
|
||||
let new_filename = null;
|
||||
let wildcards = char_over;
|
||||
if (char_over > 0) {
|
||||
let part1 = filename.slice(0, 20);
|
||||
if (char_over > 5) {
|
||||
wildcards = 5;
|
||||
let length = filename.length;
|
||||
let char_over = filename.length-45;
|
||||
let new_filename = null;
|
||||
let wildcards = char_over;
|
||||
if (char_over > 0) {
|
||||
let part1 = filename.slice(0, 20);
|
||||
if (char_over > 5) {
|
||||
wildcards = 5;
|
||||
} else {
|
||||
}
|
||||
let part2 = '.'.repeat(wildcards);
|
||||
let part3 = filename.slice(-20);
|
||||
|
||||
new_filename = part1+part2+part3;
|
||||
} else {
|
||||
new_filename = filename;
|
||||
}
|
||||
let part2 = '.'.repeat(wildcards);
|
||||
let part3 = filename.slice(-20);
|
||||
|
||||
new_filename = part1+part2+part3;
|
||||
} else {
|
||||
new_filename = filename;
|
||||
}
|
||||
return new_filename;
|
||||
return new_filename;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user