Put the script into an external file, set the selector there and enqueue it from your shortcode:
if(! function_exists ('aisis_toc') )
{
function aisis_toc()
{
if ( ! is_singular() )
return;
wp_enqueue_script(
'jquery-toc',
plugins_url( 'js/jquery-toc.js', __FILE__ ),
array ( 'jquery' ),
NULL,
TRUE);
return;
}
}