Refactored JS and attempted to complete display blocks generation

Code is untested, feel free to reject/rebase it!