From 6e8cdd5880263d4ec5c5756c97ea4dc36818700e Mon Sep 17 00:00:00 2001 From: luca0N! Date: Sun, 30 May 2021 15:52:40 -0300 Subject: [PATCH] Map indexes to IDs --- privacy-quiz.en.json | 99 ++++++++++++++++++++++++++++++++++++++++++++ res/js/main.js | 10 +++-- 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 privacy-quiz.en.json diff --git a/privacy-quiz.en.json b/privacy-quiz.en.json new file mode 100644 index 0000000..a26e3a6 --- /dev/null +++ b/privacy-quiz.en.json @@ -0,0 +1,99 @@ +{ + "title": "Privacy Test Quiz", + "originalTimestamp": 1622399164, + "timestamp": -1, + + "author": "luca0N!", + "contributors": [ + "luca0N!" + ], + "publisher": "luca0N!", + + "license": "CC-BY-SA-4.0", + "version": "v0.0-dev", + "revision": 1, + "format": "qrstd-1.0", + + "globalSettings": { + "section.multiple.points.max": 10, + "section.multiple.points.min": -10 + }, + + "contents":[ + { + "title": "Which of the following operating systems do you use on your main host computer?", + "type": "multiple", + "choices": [ + "Linux", + "BSD", + "Windows", + "macOS" + ], + "ids": [ + "0", "1", "2", "3" + ] + }, + { + "title": "What operating system is installed on your daily driver phone?", + "type": "single", + "choices": [ + "Stock Android", + "AOSP", + "iOS", + "Linux" + ], + "ids": [ + "4", "5", "6", "7" + ] + }, + { + "title": "What is your main instant messaging (IM) service?", + "type": "multiple", + "choices": [ + "Matrix", + "XMPP/Jabber", + "WhatsApp", + "iMessage", + "Discord" + ], + "ids":[ + "8", "9", "10", "11", "12" + ] + } + ], + "reports":{ + "0":{ + "title": "You are using Linux", + "type": "good", + "points": 5, + "description": "The Linux operating system family is loved by many privacy enthusiasts due to its open nature: Linux is open source, meaning that anyone can audit the source code and know what it's exactly doing in the background.\nKeep in mind that although Linux is open source, some Linux distributions may contain bad privacy practices and can spy on you. You should check if yours has good privacy practices." + }, + "1":{ + "title": "BSD", + "type": "", + "points": 0, + "description": "" + }, + "2":{ + "title": "You are using Windows", + "type": "critical", + "points": -8, + "description": "The source code for Windows is not available to the general public, so people can't know what exactly it's doing in the background.\nWindows 10 also sends telemetry data to Microsoft by default, which cannot be disabled: users can only pick whether they want to give Microsoft more data or less data.", + "advisory": "Please consider switching to Linux." + }, + "3":{ + "title": "You are using macOS", + "type": "bad", + "points": -5, + "description": "macOS is an operating system made by Apple which uses the permissive BSD kernel. It is closed source, meaning that people cannot know what it's doing in the background for sure.", + "advisory": "Please consider switching to Linux." + }, + "4":{ + "title": "You are using stock Android", + "type": "critical", + "points": -8, + "description": "Most stock Android phones contain various proprietary software made by Google (like Google Play services), which is known for its nefarious tracking technologies.\nBe aware that your phone can and will be used to spy on you. Sensitive and personal data such as your location and interests can be easily hoarded by Google.", + "advisory": "Please consider switching to AOSP (Android Open Source Project)." + } + } +} diff --git a/res/js/main.js b/res/js/main.js index 2e5c7b8..2f3683a 100644 --- a/res/js/main.js +++ b/res/js/main.js @@ -25,7 +25,7 @@ * by luca0N! */ -let quizEl; +let quizEl, mappedIds = []; // Attach setUpStrings() to onReady() in order to execute the main code as soon as possible. This overwrites onReady(). onReady = setUpStrings; @@ -64,12 +64,14 @@ function setUpStrings(){ itemDiv.appendChild(itemTitle); + mappedIds[x] = []; + if (contents[x].type === 'multiple' || contents[x].type === 'single'){ // Generate a checkbox for each choice. for (let y = 0; y < contents[x].choices.length; y++){ - if (contents[x].choices.length != contents[x].values.length){ + if (contents[x].choices.length != contents[x].ids.length){ console.error('Unable to add choice #' + (y + 1) + ' for question #' + (x + 1) + ': ' + - contents[x].choices.length > contents[x].values.length ? 'missing values' : 'extra values found'); + contents[x].choices.length > contents[x].ids.length ? 'missing ID(s)' : 'extra ID(s) found'); continue; } @@ -83,6 +85,8 @@ function setUpStrings(){ questionLabel.htmlFor = currentId; questionLabel.innerText = contents[x].choices[y]; + mappedIds[x][y] = contents[x].ids[y]; + itemDiv.append(questionInput); itemDiv.append(questionLabel); if (y < contents[x].choices.length)