Sanitise DOM Injected data to avoid possible XSS attempts

Includes .mario’s DOMPurify to sanitise data before writing to DOM
Fixed syntax error in ternary operation
Cleared some redundant code

Cleared some redundant code, still lot more to clear.
Fixed syntax error
Merge pull request #1 from prakharprasad/master

Some enhancement and fixes