Stream: javascript
Topic: help needed (newbie)
Jose Costa Teixeira (Aug 04 2020 at 18:35):
Hi. Can I ask for help for a small question I have?
Perhaps this is simple for anyone that knows the basics, but I don't.
Jose Costa Teixeira (Aug 04 2020 at 18:36):
I want to obtain the full text that is associated with a heading - the number and the text
Jose Costa Teixeira (Aug 04 2020 at 18:37):
e.g. for this
https://build.fhir.org/ig/FHIR/sample-ig/artifacts.html#structures-resource-profiles
I'd like to get "6.0.1 Structures: Resource Profiles".
Jose Costa Teixeira (Aug 04 2020 at 18:38):
the header has an id, and that I can obtain from
$(this).attr('id')
Jose Costa Teixeira (Aug 04 2020 at 18:38):
can someone point me in the good direction?
Jose Costa Teixeira (Aug 04 2020 at 21:07):
(I know, i forgot to say please)...
Paul Lynch (Aug 05 2020 at 13:28):
getElementById(id).textContext
David Hay (Aug 05 2020 at 18:36):
Just out of interest, is this for a script running in an IG? (Didn't think you could do that)...
Jose Costa Teixeira (Aug 05 2020 at 18:38):
No, i'm adding something to the template
Jose Costa Teixeira (Aug 05 2020 at 18:49):
thanks @Paul Lynch
textContext does not seem to exist (i assume getElementById(id) is a method of document
textContent does give me the Structures: Resource Profiles.
Jose Costa Teixeira (Aug 05 2020 at 18:50):
Is there a way I could get the "6.0.1" which is determined by CSS?
Jose Costa Teixeira (Aug 05 2020 at 18:51):
h3:before {
color: silver;
counter-increment: sub-section;
content: var(--heading-prefix) "." counter(sub-section) " ";
}
David Hay (Aug 05 2020 at 21:43):
how about .innerHTML or .innerText?
Jose Costa Teixeira (Aug 06 2020 at 05:07):
gives the same, not section number
David Hay (Aug 06 2020 at 07:43):
Have you tried the 'inspect element' in the browser to see how it is rendered?
Jose Costa Teixeira (Aug 06 2020 at 09:39):
looks pretty opaque to me:
image.png
Jose Costa Teixeira (Aug 06 2020 at 09:39):
Jose Costa Teixeira (Aug 06 2020 at 09:40):
Lieven Peeters (Aug 06 2020 at 11:56):
it's a css counter, and unfortunately, that value seems not to be stored in the DOM: https://stackoverflow.com/questions/2651739/how-to-access-css-generated-content-with-javascript
Lieven Peeters (Aug 06 2020 at 11:58):
i think the only way to retrieve the number will be to recalculate it manually
Jose Costa Teixeira (Jan 15 2021 at 17:01):
Hi everyone. Can i use this lifeline again?
Jose Costa Teixeira (Jan 15 2021 at 17:03):
I have a small (a few dozen lines) python script that takes one json object and creates another one from a few simple rules.
I would like to try to put this in javascript.
Jose Costa Teixeira (Jan 15 2021 at 17:04):
but i am really unable to start that. Can I ask someone if they have a free 1-hour slot to code a part of it, and then I can understand how it's done and maintain it?
Jose Costa Teixeira (Jan 15 2021 at 17:04):
at this moment I'm hardcoding the transformation with a few if()s, and that should be enough for a PoC
Jose Costa Teixeira (Jan 15 2021 at 17:05):
This is for a possible new addition to the IG templates
Carl Anderson (Jan 19 2021 at 15:10):
I'm no JS expert, but I would be willing to help. Can you share your python?
Jose Costa Teixeira (Jan 19 2021 at 21:02):
Thanks @Carl Anderson
this: https://raw.githubusercontent.com/costateixeira/QuestionnaireForm/main/CreateForm.py
Last updated: Apr 12 2022 at 19:14 UTC