P5 JavaScript was integrated with HTML and posted on GitHub. Normally, two parameters could be passed into the code by adding them to the HTML URL. This works when the code is tested locally. This fails when attempting to do this with the HTML page on github using syntax designed to preview the HTML page. Note that a straight up URL, by default, will display the source code rather than a working HTML page on a GitHub project. This is by design. The plan was to use this URL as the target of hyperlinks on the readme.md file. This would demonstrate the working code for visitors of the project.
The following things were tried after reviewing this StackOverflow post. These attempts did now work:
- https://rawgit.com/ ... (this downloads the file on clicking the link)
- Preview Syntax tried w/ parameters on the URL:
- http://htmlpreview.github.com/?https://github.com/TheMitchWorksPro/FlatIronLearningCode/blob/master/index.html?runModeToggle=1&runModeToggle2=1
- http://htmlpreview.github.com/?https://github.com/TheMitchWorksPro/FlatIronLearningCode/blob/master/index.html&runModeToggle=1&runModeToggle2=1
- Escape second
?
in option 1 as in...\?runModeToggle=1&run...
- Put whole URL after first
?
in quotes as inhttp://htmlpreview.github.com/?"https://github.com/ ... "
My code is presented for learning purposes showing how it evolved. Earlier iterations that did simpler things without the parameters display fine. For example:
But for the one flavor of the code that needs parameters to work, this is where the trouble is. This post also suggests other things to try but none of them solves the problem. If this URL worked properly, then both parameters would show up as their corresponding numbers in the second line of text on the page, and they would cause certain behaviors when a user clicks (mousepressed
) on the page: