Changes to cope with separating HTML players and covers

Yes you are, for instructions change depending on the code being used.

On that code at https://jsfiddle.net/kcr3n01e/, the minor cleaning up starts by noticing that createCallback and playerAdder both return the same identical callback function. In the playerAdder function instead of returning the callback function, we should return the createCallback function, invoking it of course with the required function arguments. This is a good time to also rename the callback function to be addPlayerCallback instead.

In the returned object at the end of the managePlayer code, there’s no need for createCallback to be there because nothing outside of managePlayer calls createCallback, so remove createCallback from that object too.

The querySelector line shouldn’t be in the playerAdder function. We can move that out of there and in to the addPlayer function, which is found in coverUIPlayerFacade function. After that move, update the managePlayer.adder function call to replace parent with wrapper. We get an error that wrapper is not defined in the playerAdder function, so rename parent to be wrapper instead.

Everything goes back to working, and we now have code in the addPlayer function that uses a cover to get the wrapper. We want manageUI to do that job instead, because we have plans for manageUI to scan the code for all covers and players, letting us easily go from one to another.

Once you’ve achieved the above, we’ll move on putting some of the code into manageUI, after which all of our work should then be in manageUI where we’ll build up what’s needed for it to scan for the players and covers, letting us then use them to give the correct one that’s wanted.

1 Like