Please note that since v2021, all the Javascript either that written from Client Script or Startup Script will be placed/generated into .js file. Therefore, we cannot mix the code with PHP code anymore. You need to find out the related PHP code in Javascript.
For your case, you may use ew.PAGE_ID Javascript variable to identify the current page id in client side.