Yes, this is the best option IMO. Most of the routines in WeightedBatchPreprocessing-helper.js should be transformed into independent routines, or even better, methods of a new object. For example, instead of:
if ( !String.prototype.cleanFilterName )
String.prototype.cleanFilterName = function()
{
return this.replace( /[^a-zA-Z0-9\+\-_]/g, '_' ).replace( /_+/g, '_' );
};
we could have a static method:
function WBPPUtils()
{
...
}
WBPPUtils.prototype = new Object;
WBPPUtils.cleanFilterName = function( filterName )
{
return filterName.replace( /[^a-zA-Z0-9\+\-_]/g, '_' ).replace( /_+/g, '_' );
};
Less convenient to use, and requires a lot of refactoring, but much safer and more productive in the long term.