Add support for scoping callback functions in barcodescanner.js