Reorganize a little bit js for admin and main page to avoid duplications