Skip to content

Commit

Permalink
Fixed #23 - Clicking on icon column header toggles display of blocked…
Browse files Browse the repository at this point in the history
… callers.
  • Loading branch information
cosinekitty committed Jun 8, 2016
1 parent 26439b5 commit 472c54c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
34 changes: 33 additions & 1 deletion public/jcclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@
var ModalDivList = ['RecentCallsDiv', 'TargetCallDiv', 'LostContactDiv'];
var LostContactCount = 0;

// For toggling display of various types of call history rows.
var DisplayRowsOfType = {
neutral: true,
blocked: true,
safe: true
};

function UpdateRowDisplay(callHistoryRows) { // call to reflect current DisplayRowsOfType settings
for (var i=0; i < callHistoryRows.length; ++i) {
var row = callHistoryRows[i];
var status = row.getAttribute('data-caller-status');
row.style.display = DisplayRowsOfType[status] ? '' : 'none';
}
}

var PollTimer = null;
var PrevPoll = {
callerid: {
Expand Down Expand Up @@ -249,6 +264,7 @@
}

function PopulateCallHistory() {
var rowlist = [];
var recent = PrevPoll.callerid.data.calls;
var table = document.createElement('table');
table.setAttribute('class', 'RecentCallTable');
Expand All @@ -258,6 +274,18 @@

var hcell_icon = document.createElement('th');
hcell_icon.className = 'IconColumn';
var toggleIconImage = document.createElement('img');
toggleIconImage.setAttribute('src', 'safe.png');
toggleIconImage.setAttribute('width', '24');
toggleIconImage.setAttribute('height', '24');
toggleIconImage.style.display = DisplayRowsOfType.blocked ? 'none' : '';
hcell_icon.appendChild(toggleIconImage);
hcell_icon.onclick = function() {
// Toggle display of blocked callers.
DisplayRowsOfType.blocked = !DisplayRowsOfType.blocked;
toggleIconImage.style.display = DisplayRowsOfType.blocked ? 'none' : '';
UpdateRowDisplay(rowlist);
}
hrow.appendChild(hcell_icon);

var hcell_when = document.createElement('th');
Expand All @@ -274,11 +302,13 @@
var now = new Date();

var tbody = document.createElement('tbody');
for (var call of recent) {
for (var i=0; i < recent.length; ++i) {
var call = recent[i];
call.count = PrevPoll.callerid.data.count[call.number] || '?';
var callStatusClassName = BlockStatusClassName(call.status);

var row = document.createElement('tr');
row.setAttribute('data-caller-status', CallerStatus(call));

var iconCell = document.createElement('td');
if (call.status === 'blocked' || call.status === 'safe') {
Expand All @@ -299,6 +329,7 @@
row.appendChild(CreateCallerCell(call));

tbody.appendChild(row);
rowlist.push(row);
}

table.appendChild(thead);
Expand All @@ -312,6 +343,7 @@

// Fill in newly-generted content for the RecentCallsDiv...
rcdiv.appendChild(table);
UpdateRowDisplay(rowlist);
}

function UpdateUserInterface() {
Expand Down
6 changes: 6 additions & 0 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ td, th {

.IconColumn {
width: 24px;
height: 38px;
background: black;
border: 0;
padding: 0;
text-align: center;
vertical-align: middle;
}

.WhenCell {
Expand Down

0 comments on commit 472c54c

Please sign in to comment.