It is too complicated to get a part of the project. I tried but this Dialog uses global objects and code from other files
So I changed encoding of JS file to cp1251 and now it works as it should be.
I guess the script engine uses system encoding