diff --git a/content.js b/content.js index b3de8140c9215e5874bd26fe96fb49186468d348..b1d98f5df402464a41eecdc96a0f2ca6a0c21c5f 100644 --- a/content.js +++ b/content.js @@ -495,10 +495,10 @@ let Content = {  <body>   <div id="piano-keyboard">    <button type="button" value="C" style="width: 50px; height: 120px; padding: 2px;">C</button> -    <button type="button" value="C#" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">C#</button> -    <button type="button" value="D♭" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">D♭</button> +    <button type="button" value="C#" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">C#</button> +    <button type="button" value="D♭" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">D♭</button>    <button type="button" value="D" style="width: 50px; height: 120px; padding: 2px;">D</button> -    <button type="button" value="D#" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">D#</button> +    <button type="button" value="D#" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">D#</button>    <button type="button" value="E" style="width: 50px; height: 120px; padding: 2px;">E</button>   </div>  </body> @@ -527,19 +527,34 @@ let Content = { }); document.body.appendChild(pianoDivInConf); - let returnedKeyboard = removePianoKey('D♭'); + let returnedKeyBoard = removePianoKey('D♭'); + let correctKeyRemoved = Object.values(returnedKeyBoard.childNodes).every(key => key.value !== 'D♭'); - if (typeof(returnedKeyboard) === 'object') { - let returnedKeys = Object.values(returnedKeyboard.childNodes).map(item => item.value) ; - display.res("Checking the keyboard keys...", returnedKeys); + const checkWithAllKeys = () => { + display.cmd("Testing with other keys..."); + keys.splice(keys.findIndex(item => item === 'D♭'), 1); + return keys.map(item => { + return Object.values(removePianoKey(item).childNodes).map(key => key.value) + }); + } + + if (correctKeyRemoved) { + display.cmd("Correct key removed"); + display.res("Checking the keyboard keys... Open the developer tools console to see the logs", checkWithAllKeys()); + display.cmd("Hups, did we remove a bit too many keys... No problem"); } else { - display.cmd("Did yuu return the keyboard div?") + display.cmd("Did yuu remove the key using the keyValue parameter and returned the keyboard div?"); }`, executeAtStart: true, points: function ($element, config, accessor) { let p = accessor.testResults(10, function(i , args, res) { let correctKeys = ['C', 'C#', 'D', 'D#', 'E']; - let points = args.some((key, i) => key !== correctKeys[i])? 0 : config.maxPoints; + console.log('Checking that the correct keys have been removed'); + let points = args.every((item, i) => item.every(key => key !== correctKeys[i]))? 10 : 0; + if(points === 0) { + let wrongKeyboards = args.filter((item, i) => item.some(key => key === correctKeys[i])); + console.log('Some of the keyboards returned the wrong keys', wrongKeyboards); + } return points; }); return { points: p };