I'm sorry, but it is not something on which I can help you further. The MathJax portion seems to be working, but the rest of the javascript programming is not my responsibility.
You should note, however, that you are using a rather old version of MathJax. The
mathjax.org site was decommissioned in 2017, and only while it forwards to another CDN, it only gets you version 2.7.1. Since you are developing a new site, I would recommend using MathJax v3, the current version of MathJax. Note, however, that it has a different method of configuration, so you will have to update that a bit. Check out the documentation, particularly
for more.
Good luck with the project.