-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store exercise notes and proof as HTML #7
Comments
I like this suggestion. I managed to quickly write up some code for this and ported the first exercise HTML data over this way. Already it revealed that there were some typos etc. in the HTML. Porting the remaining 132 exercises will be a bit tedious but should be done before too long. |
Great! A few suggestions on this approach:
You can also use JS selectors to more elegantly find the data within an HTML element (e.g. "find the first child with class attribute 'notes'," etc). So you would have code for each exercise attribute you want to set, instead of looping over every child with a switch statement on the class name. (This is more of a style judgement.) |
PS - If you’re not already doing this, it could also help to maintain in the JavaScript a dictionary of the exercises mapping the short name or ID to the corresponding Exercise object. This will be useful for e.g. storing the “unlocks” info as data. The unlocks info could then be stored as e.g. a space-delimited attribute value of the div for that exercise. |
OK, I'm done for now; I've prefixed the id's and formatted some of the HTML (not the proofs though, as this would be rather tedious and I would expect them to be rarely edited by hand). I have an exerciseList array that could be used for mapping ids to exercises if need be, but at present there isn't a need for it, so I haven't bothered to code a lookup routine yet. Using a selector would indeed be more elegant, but it ain't broken right now, so I'm not fixing it. |
FYI, I added initial support for also storing the "unlockedBy" info in the HTML, and did this for the first couple exercises as an example. |
One easier thing that I think would improve the structure and maintainability of the code would be to store the HTML "notes" and "proof" for each exercise as HTML.
Currently, these HTML strings are stored as JS string literals (in
docs/js/main.js
), which isn't great for storing "data" and makes it a bit harder to edit and view the HTML. For example:QED/docs/js/main.js
Lines 29 to 30 in 2978fc5
One idea is to store this information in the form of hidden (i.e. not seen when browsing) "data" divs in the main html file. The structure for each exercise could be something like--
Then a
load_exercise_data(exercise, id)
JS function could be defined that populates anExercise
object from the HTML document, and this called from withinmain.js
for each exercise. Over time, more of the exercise "data" could be transferred to a more structured form (e.g. the "unlocks" and "unlockedBy" information), until perhaps all of each exercise can be populated from data.The text was updated successfully, but these errors were encountered: