Add custom grade message

Remove hardcoded grade message and add support for custom grade messages.
This commit is contained in:
luca0N! 2021-06-02 19:10:25 -03:00
parent 4cf98ca23d
commit d61a0fdce8
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
2 changed files with 21 additions and 2 deletions

View File

@ -201,6 +201,25 @@ function setUpStrings(){
reports.appendChild(reportEl);
}
// Set the grade message (if it exists.
let gme = document.getElementById('grade-message'); // Grade Message Element
// Check if this quiz contains custom grade messages.
if (quiz.gradeMessages != undefined && quiz.gradeMessages != null){
let gmt, gmto = quiz.gradeMessages['grade-' + grade];
// Check if there is a grade message for the current grade.
if (gmto !== undefined && gmto !== null){
gmt = gmto.split('\n');
for (let i = 0; i < gmt.length; i++){
let line = gmt[i];
let p = document.createElement('p');
p.innerText = line;
gme.appendChild(p);
}
}
}
// Hide quiz and then show the results.
quizEl.style['display'] = 'none';
document.getElementById('results').style['display'] = 'unset';

View File

@ -54,8 +54,8 @@
<span id="badge-f" class="badge grade-f">Grade F</span>
</center><br/>
<p>Oh no, looks like you got a bad grade! Unfortunately, many popular services do not respect your privacy, and you're likely using some of them.</p>
<p>But you can increase your privacy grade. Do not be discouraged from performing good privacy practices because you can increase it drastically with little to no effort.</p>
<div id="grade-message"></div>
<h2>Your Privacy Report</h2>
<i>The good, bad and ugly</i>
<div id="reports">