commit 7b03cdcc5e20197f048bad79b984a18700363c0c
Author: Pavel Fidranský <fidransky@outlook.com>
Date:   Sat Oct 20 21:52:31 2018 +0200

    reworked utils to ES6 classes with static methods

diff --git a/sources/src/main/webapp/js/app.js b/sources/src/main/webapp/js/app.js
index 870c616..e85caf6 100644
--- a/sources/src/main/webapp/js/app.js
+++ b/sources/src/main/webapp/js/app.js
@@ -13,12 +13,6 @@ function App() {
 	this.loader = new Loader;
 	/** @prop {Zoom} zoom */
 	this.zoom = new Zoom(0.8);
-	/** @prop {Utils} utils */
-	this.utils = new Utils;
-	/** @prop {DOM} dom */
-	this.dom = new DOM;
-	/** @prop {Cookies} cookies */
-	this.cookies = new Cookies;
 	/** @prop {MarkSymbol} markSymbol */
 	this.markSymbol = new MarkSymbol;
 
diff --git a/sources/src/main/webapp/js/utils/cookies.js b/sources/src/main/webapp/js/utils/cookies.js
index e38e17a..8497509 100644
--- a/sources/src/main/webapp/js/utils/cookies.js
+++ b/sources/src/main/webapp/js/utils/cookies.js
@@ -1,24 +1,23 @@
 /**
  * Class containing cookie utility functions.
- * @constructor
  */
-function Cookies() {
+class Cookies {
 	/**
 	 * Gets the value of a cookie.
 	 * 
 	 * @param {string} name Name of the cookie.
 	 */
-	this.get = function(name) {
-		var cookies = document.cookie.split('; ');
+	static get(name) {
+		const cookies = document.cookie.split('; ');
 
-		var cookie = cookies.find(function(cookie) {
+		const cookie = cookies.find(cookie => {
 			return cookie.startsWith(name + '=');
 		});
 
 		if (typeof cookie === 'undefined') return null;
 
 		return cookie.split('=')[1];
-	};
+	}
 
 	/**
 	 * Sets a new cookie.
@@ -26,9 +25,9 @@ function Cookies() {
 	 * @param {string} name Name of the cookie.
 	 * @param {string} value Value of the cookie.
 	 */
-	this.set = function(name, value) {
-		var date = new Date();
+	static set(name, value) {
+		const date = new Date();
 
 		document.cookie = name + "=" + value + "; path=/imiger";
-	};
+	}
 }
diff --git a/sources/src/main/webapp/js/utils/dom.js b/sources/src/main/webapp/js/utils/dom.js
index ad715eb..f965510 100644
--- a/sources/src/main/webapp/js/utils/dom.js
+++ b/sources/src/main/webapp/js/utils/dom.js
@@ -1,11 +1,7 @@
 /**
  * Class containing Document Object Model utility functions.
- * @constructor
  */
-function DOM() {
-	var htmlTags = JSON.parse(document.getElementById('htmlTags').textContent);
-	var svgTags = JSON.parse(document.getElementById('svgTags').textContent);
-
+class DOM {
 	/**
 	 * Creates a new HTML DOM element from HTML string. Since only the first HTML element in the set is returned, the input 
 	 * string should contain a wrapping element that would hold all inner elements.
@@ -13,12 +9,12 @@ function DOM() {
 	 * @param {string} html HTML string.
 	 * @returns {Element} HTML element.
 	 */
-	this.htmlStringToElement = function(html) {
-		var template = document.createElement('template');
+	static htmlStringToElement(html) {
+		const template = document.createElement('template');
 		template.innerHTML = html;
 
 		return template.content.firstChild;
-	};
+	}
 
 	/**
 	 * Creates a new HTML DOM element. If the tagName passed as a parameter is not a valid HTML tag, exception is thrown.
@@ -28,18 +24,18 @@ function DOM() {
 	 * @returns {Element} HTML DOM element.
 	 * @throws {InvalidArgumentError} Thrown when tagName is not a valid HTML tag.
 	 */
-	this.createHtmlElement = function(tagName, attributes) {
-		if (htmlTags.indexOf(tagName) === -1) {
+	static createHtmlElement(tagName, attributes = {}) {
+		if (DOM.validHTMLTags.indexOf(tagName) === -1) {
 			throw new InvalidArgumentError(tagName + 'is not a valid HTML element');
 		}
 
-		var element = document.createElement(tagName);
+		const element = document.createElement(tagName);
 		for (let key in attributes) {
 			element.setAttribute(key, attributes[key]);
 		}
 
 		return element;
-	};
+	}
 	
 	/**
 	 * Creates a new SVG DOM element. If the tagName passed as a parameter is not a valid SVG tag, exception is thrown.
@@ -49,25 +45,28 @@ function DOM() {
 	 * @returns {Element} SVG DOM element.
 	 * @throws {InvalidArgumentError} Thrown when tagName is not a valid SVG tag.
 	 */
-	this.createSvgElement = function(tagName, attributes) {
-		if (svgTags.indexOf(tagName) === -1) {
+	static createSvgElement(tagName, attributes = {}) {
+		if (DOM.validSVGTags.indexOf(tagName) === -1) {
 			throw new InvalidArgumentError(tagName + 'is not a valid SVG element');
 		}
 
-		var element = document.createElementNS('http://www.w3.org/2000/svg', tagName);
+		const element = document.createElementNS('http://www.w3.org/2000/svg', tagName);
 		for (let key in attributes) {
 			element.setAttribute(key, attributes[key]);
 		}
 
 		return element;
-	};
+	}
 
 	/**
 	 * Creates a new DOM node containing the text.
 	 * 
 	 * @param {string} text Text to create the element for.
 	 */
-	this.createTextElement = function(text) {
+	static createTextElement(text) {
 		return document.createTextNode(text);
-	};
+	}
 }
+
+DOM.validHTMLTags = JSON.parse(document.getElementById('htmlTags').textContent);
+DOM.validSVGTags = JSON.parse(document.getElementById('svgTags').textContent);
diff --git a/sources/src/main/webapp/js/utils/utils.js b/sources/src/main/webapp/js/utils/utils.js
index b11b998..09f68a2 100644
--- a/sources/src/main/webapp/js/utils/utils.js
+++ b/sources/src/main/webapp/js/utils/utils.js
@@ -1,20 +1,19 @@
 /**
  * Class containing common utility functions.
- * @constructor
  */
-function Utils() {
+class Utils {
 	/**
 	 * No operation function.
 	 */
-	this.noop = function() {};
+	static noop() {}
 
 	/**
 	 * Stops propagation of the mouse interaction to parental elements.
 	 * @param {MouseEvent} e Click/double-click event.
 	 */
-	this.stopPropagation = function(e) {
+	static stopPropagation(e) {
 		e.stopPropagation();
-	};
+	}
 
 	/**
 	 * Checks whether the variable passed as parameter is defined.
@@ -22,9 +21,9 @@ function Utils() {
 	 * @param variable Variable to be checked.
 	 * @return {boolean} true if the variable is defined, otherwise false
 	 */
-	this.isDefined = function(variable) {
+	static isDefined(variable) {
 		return typeof variable !== 'undefined';
-	};
+	}
 
 	/**
 	 * Checks whether the variable passed as parameter is not defined.
@@ -32,24 +31,9 @@ function Utils() {
 	 * @param variable Variable to be checked.
 	 * @return {boolean} true if the variable is NOT defined, otherwise false
 	 */
-	this.isUndefined = function(variable) {
+	static isUndefined(variable) {
 		return typeof variable === 'undefined';
-	};
-
-	// TODO: move to DOM class
-	this.createHtmlElement = function(tagName, attributes) {
-		return app.dom.createHtmlElement(tagName, attributes);
-	};
-
-	// TODO: move to DOM class
-	this.createSvgElement = function(tagName, attributes) {
-		return app.dom.createSvgElement(tagName, attributes);
-	};
-	
-	// TODO: move to DOM class
-	this.createTextElement = function(text) {
-		return app.dom.createTextElement(text);
-	};
+	}
 
 	/**
 	 * Returns a new promise that is resolved at the moment when all promises passed as function parameter are resolved.
@@ -58,7 +42,7 @@ function Utils() {
 	 * @param promises Array of promises to wait for.
 	 * @return New promise.
 	 */
-	this.promiseAll = function(promises) {
+	static promiseAll(promises) {
 		if (!Array.isArray(promises)) {
 			throw new TypeError('Parameter must be an array.');
 		}
@@ -71,7 +55,7 @@ function Utils() {
 				return Array.prototype.slice.call(arguments, 0);
 			}
 		})
-	};
+	}
 
 	/**
 	 * Extracts value of a query parameter from the current URL.
@@ -80,7 +64,7 @@ function Utils() {
 	 * @param {string} variable 
 	 * @returns value of the query parameter or false if the parameter does not exist
 	 */
-	this.getQueryVariable = function(variable) {
+	static getQueryVariable(variable) {
 		var query = window.location.search.substring(1);
 		var vars = query.split('&');
 
@@ -93,14 +77,14 @@ function Utils() {
 		}
 
 		return false;
-	};
+	}
 
     /**
      * @param {(Vertex|Group)} node Graph node.
      * @returns {string} Unique identifier of a graph node (group or vertex).
      */
-    this.getUniqueId = function(node) {
-    	if(this.isUndefined(node)) return '';
+    static getUniqueId(node) {
+    	if (Utils.isUndefined(node)) return '';
 
     	var prefix;
         if (node instanceof Vertex) {
@@ -112,5 +96,5 @@ function Utils() {
         }
 
         return prefix + node.id;
-    };
+    }
 }
