Its clear that you want to put the page you linked to inside Moodle. But Its not clear what you are doing to make that happen. And its not clear what errors or issues you are running into.
Are you hacking an existing PHP moodle file? Which one?
Are you just copying and pasting a bunch of code into an HTML editor field? Where? ... Probably not going to work because Moodle works hard to remove scripts from user generated content.
Why not show us some of the errors you get?
Without a more step by step explanation of the problem, all you are going to get as responses are links to documentation pages. Like this one for how to use javascript in Moodle.
https://docs.moodle.org/dev/Javascript_Modules
If you really want to prototype a javascript solution in Moodle without making a whole plugin, you might use Generico. I always say that. But it also has a bit of a learning curve. See this post:
https://moodle.org/mod/forum/discuss.php?d=384512#p1551706