class ActivityBarController { constructor () { this.div = document.getElementById('activityBarsDiv'); this.filteredCalls = {}; //this.update(); } earliestStart () { var earliestTime = parseInt(Date.now() / 1000); for (const groupName in this.filteredCalls) { for (const tgId in this.filteredCalls[groupName]) { for (const call of this.filteredCalls[groupName][tgId]) { if (call['start_time'] < earliestTime) { earliestTime = call['start_time']; } } } } return earliestTime; } latestEnd () { var latestEnd = 0; for (const groupName in this.filteredCalls) { for (const tgId in this.filteredCalls[groupName]) { for (const call of this.filteredCalls[groupName][tgId]) { //console.log(call['end_time']); if (call['end_time'] > latestEnd) { latestEnd = call['end_time']; } } } } return latestEnd; } update () { //console.log('abc.update called'); this.filterCalls(); this.updateHtml(); } updateHtml () { tgFieldWidth = parseInt(sizeFinder.getBoundingClientRect()['width']); let html = ''; html += ''; let earliest = undefined; let latest = undefined; if (!visibleRangeStart || !visibleRangeEnd) { earliest = this.earliestStart(); latest = this.latestEnd(); //console.log('Initialized viewport to earliest ' + viewportEarliest + ' latest ' + viewportLatest); } else { earliest = parseInt(visibleRangeStart / 1000); latest = parseInt(visibleRangeEnd / 1000); } for (const groupName of Object.keys(this.filteredCalls).sort()) { html += ''; html += ''; html += ''; //html += ''; for (const tgId of Object.keys(this.filteredCalls[groupName]).sort()) { let bgColor = '#010101'; if (currentPlayingTg == tgId) { bgColor = '#444444'; } html += '' let canvasWidth = parseInt((window.innerWidth / 2) - tgFieldWidth); if (wideMode) { canvasWidth = window.innerWidth - tgFieldWidth - 25; } if (window.innerWidth / window.innerHeight < 1.35) { canvasWidth = parseInt(window.innerWidth - tgFieldWidth - 50); } html += ''; html +=''; } } html += '
              TG Name             Activity
' + groupName + '
' + ptime(viewportEarliest) + '' + ptime(viewportLatest) + '
' + this.filteredCalls[groupName][tgId][0]['tg_name'] + '
'; this.div.innerHTML = html; for (const groupName in this.filteredCalls) { for (const tgId in this.filteredCalls[groupName]) { drawActivityBar(document.getElementById('activityBar-' + tgId), this.filteredCalls[groupName][tgId], earliest, latest, groupName, tgId); } } } filterCalls () { this.filteredCalls = {}; let matchCount = 0; //console.log('filterCalls: looking at ' + calls.length + ' calls') for (let i=0; i {return a['start_time'] - b['start_time']}); } } matchedCallCountSpan.innerHTML = matchCount; } shouldInclude (callData) { if (callData['start_time'] * 1000 < visibleRangeStart) { return false; } if (callData['start_time'] * 1000 > visibleRangeEnd) { return false; } let system = systemMatchMap[callData['system']]; if (system in systemsMap && !systemsMap[system]['enabled']) { return false;} let type = metaTagFromTags(callData['tg_tags']); if (!typesMap[type]['enabled']) { return false; } if (tgRegex !== '') { let re = new RegExp(tgRegex); if (!callData['tg_name'].match(re)) { return false; } } return true; } }