FHIR Chat · help needed (newbie) · javascript

Stream: javascript

Topic: help needed (newbie)


view this post on Zulip 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.

view this post on Zulip 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

view this post on Zulip 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".

view this post on Zulip Jose Costa Teixeira (Aug 04 2020 at 18:38):

the header has an id, and that I can obtain from
$(this).attr('id')

view this post on Zulip Jose Costa Teixeira (Aug 04 2020 at 18:38):

can someone point me in the good direction?

view this post on Zulip Jose Costa Teixeira (Aug 04 2020 at 21:07):

(I know, i forgot to say please)...

view this post on Zulip Paul Lynch (Aug 05 2020 at 13:28):

getElementById(id).textContext

view this post on Zulip 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)...

view this post on Zulip Jose Costa Teixeira (Aug 05 2020 at 18:38):

No, i'm adding something to the template

view this post on Zulip 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.

view this post on Zulip 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?

view this post on Zulip Jose Costa Teixeira (Aug 05 2020 at 18:51):

h3:before {
    color: silver;
    counter-increment: sub-section;
    content: var(--heading-prefix) "." counter(sub-section) " ";
}

view this post on Zulip David Hay (Aug 05 2020 at 21:43):

how about .innerHTML or .innerText?

view this post on Zulip Jose Costa Teixeira (Aug 06 2020 at 05:07):

gives the same, not section number

view this post on Zulip David Hay (Aug 06 2020 at 07:43):

Have you tried the 'inspect element' in the browser to see how it is rendered?

view this post on Zulip Jose Costa Teixeira (Aug 06 2020 at 09:39):

looks pretty opaque to me:
image.png

view this post on Zulip Jose Costa Teixeira (Aug 06 2020 at 09:39):

image.png

view this post on Zulip Jose Costa Teixeira (Aug 06 2020 at 09:40):

image.png

view this post on Zulip 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

view this post on Zulip Lieven Peeters (Aug 06 2020 at 11:58):

i think the only way to retrieve the number will be to recalculate it manually

view this post on Zulip Jose Costa Teixeira (Jan 15 2021 at 17:01):

Hi everyone. Can i use this lifeline again?

view this post on Zulip 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.

view this post on Zulip 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?

view this post on Zulip 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

view this post on Zulip Jose Costa Teixeira (Jan 15 2021 at 17:05):

This is for a possible new addition to the IG templates

view this post on Zulip 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?

view this post on Zulip 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