Update script.js

Adding new methode which trigger transition,
Refactor the code