fix some issues in script.js

no more bug when you choose a director with two films