this is my way for embed js code block in view file:
This tutorial presents a way of separating JS code from views and passing to it values from PHP.