Converted main logic in outer questions#show view to js from ruby code