Fixes for JavaScript errors

Changed hard coded value to method parameter in Objective-C code (did not cause any problems as far as I know, but anyway).
Added check for null value in JavaScript code (this caused other plugins to be unresponsive in some cases).
Fixed a syntax error in a call from Objective-C to JavaScript.
(Sorry for the massive removal of trailing white spaces!)