Major update: the javascript is redone

Major:
—Speed-up
— Improved readability by refactoring and indentation
Minor:
— Updated the fabric file
— added a img element to the ad part of the HTML code
conflicted main