Refactored JS and new palette

Now the code is more Object-Oriented than before.