Fucking JS.
I do not remember what I spend 2 days, but this works...