Finding out how many users are watching or tracking?

How can I define a function in plugin.rb for using this code?
I want to use a function in my JavaScript code to get the tracking but I don’t know how to configure the plugin.rb file to create a function like that?
Can any body tell me what should I add to plugin.rb to access a function like trakingNumbers(categoryID) in my widget’s javascript code?