Moved the Code from JSFiddle to a .js file