Fix javascript issues

Hey @nuetrino,

Thanks very much for making this awesome plugin. I'm currently doing some client work that uses this plugin and I found a few JavaScript issues so I've fixed these for you.

I realised the plugin in the .org repo was ahead of this repo so I updated the plugin from the .org repo then did work from there.

If I find any other issues I'll open Pull Requests for them :smile: