Hello,
I am sorry to hear about your condition. But, be positive - you will feel better.
I am a veteran Delphi developer (20+ years) - started in the later 90s with Delphi 1.0 and am continuing using Delphi Tokyo. I am presuming that the Delphi version does not matter too much since you want only a Pascal unit, correct? But just so, I do not introduce incompatibility, please let me know the version you use.
I reviewed the js code and this is doable.
I communicate near-natively in English. Considered a no-gas, no-tall-talk person.
I look forward to hearing more from you.
Best Regards
Kashi