Skip to content

Commit

Permalink
DDT: remove Habit History Details subsection from Habit History Table
Browse files Browse the repository at this point in the history
The "Habit History Details" subsection was the original "Habit History" section.
It has been split off into the "Habit History List" section
so that people can jump straight to that data instead of
scrolling down past the "Habit History Table"
(important for people who have a lot of Habits and
would therefore need to scroll a lot).
  • Loading branch information
Alys committed Dec 29, 2022
1 parent 58a95c3 commit 60d5458
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions habitrpg_user_data_display.html
Expand Up @@ -2149,63 +2149,14 @@
'</ul>' +
' The \'Days Since Active\' field shows the number of days since any plus/minus button was clicked for that habit. (Or a hyphen if the habit has never been active.)<br/>' +
'Vertical black bars indicate the start of each week. (Week start is Monday.)' +
'<br/><br/>' +
'If you scoll down past the table area, you can view the \'Habit Details\' section.<br/>The Habit Details section contains additional information that is not in the table.<br/> Including: The absolute number of Plus and Minus button clicks, and older history beyond 31 days.' +
'</p>' +
'<div class="showHideToggle closer" data-target="habitsHistoryExplanation" data-resettoggletext="habitsHistoryExplanationToggle">hide explanation</div>' +
'</div>' +
'<table>' + headerRow +
'<tbody>' + tableBody + '</tbody>' +
'</table>';

// ### Habit History Details ###

var detailOutput =
'<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>'+
'<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>'+
'<H2>Habit Details</H2>' +
'<p class="narrowContent">This shows your Habits, the dates you clicked on them, and the total number of plus and minus clicks on each of those dates.</p>';
detailOutput += '<p class="narrowContent">Habits with no history are highlighted in bold, in case you would like to consider them for greater focus.</p>';
detailOutput += '<ul>';
$.each(habits, function(index, obj){
detailOutput += collateHistoryForOneHabit(obj);
});
detailOutput += '</ul>';

function collateHistoryForOneHabit(obj) {
// ASSUMPTION: The history array is in chronological order (cross fingers).
var historyList = [];
$.each(obj.history, function(index, histObj){
if (typeof histObj.scoredUp !== 'undefined' && typeof histObj.scoredDown !== 'undefined') {
var valueRounded = Math.round(histObj.value * 100) / 100;
var string = moment(histObj.date).format('YYYY-MM-DD') + ' : ';
if (obj.up) {
string += ' up: ' + histObj.scoredUp;
if (obj.down) string += '; ';
}
if (obj.down) {
string += ' down: ' + histObj.scoredDown;
}
string += ' <span class="historyValue">(value: ' + valueRounded + ')</span>';
historyList.push('<li>' + string + '</li>');
}
});

var habitText = obj.text;
var noHistoryClass = '';
if (historyList.length == 0) {
noHistoryClass = 'noHistory';
habitText += ' <span>(no history)</span>';
}
else {
historyList.reverse(); // put most recent at top
habitText += '<ul class="padded">' +
historyList.join('') + '</ul>';
}
return '<li class="' + noHistoryClass + '">' + habitText + '</li>';
}

var html = tableOutput + detailOutput;
var html = tableOutput;
TOC[orderId] = {'target': id, 'title': title};
MAIN[orderId] = {'id': id, 'title': title, 'longContent': true,
'html': html};
Expand Down

0 comments on commit 60d5458

Please sign in to comment.