commit d8b87a026deffc9335cc586b7194526e8e521ad9
Author: Pavel Fidranský <fidransky@outlook.com>
Date:   Thu Oct 11 16:55:03 2018 +0200

    minor improvements

diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDiagram.java
index 1ed1f92..ff7fe7f 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/GetDiagram.java
@@ -14,7 +14,7 @@ public class GetDiagram extends BaseServlet {
 
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        String diagramId = request.getParameter("diagramId");
+        String diagramId = request.getParameter("id");
 
         if (Strings.isNullOrEmpty(diagramId)) {
             response.sendError(HttpServletResponse.SC_BAD_REQUEST);
@@ -24,29 +24,17 @@ public class GetDiagram extends BaseServlet {
         DB db = new DB(getServletContext());
         Diagram diagram = new Diagram(db, Integer.parseInt(diagramId));
 
-        JSONObject json = null;
-
-        if (diagram.isPublic()) {
-            json = new JSONObject(diagram.getDiagram());
-
-        } else {
-            if (isLoggedIn(request)) {
-                int loggedUserId = getUserId(request);
-
-                if (diagram.getUserId() == loggedUserId) {
-                    json = new JSONObject(diagram.getDiagram());
-                }
-            }
-        }
-
-        if (json == null) {
+        if (!diagram.isPublic() && (!isLoggedIn(request) || (isLoggedIn(request) && diagram.getUserId() != getUserId(request)))) {
             response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
-        } else {
-            response.setContentType("application/json");
-            response.setCharacterEncoding("UTF-8");
-            response.setStatus(HttpServletResponse.SC_OK);
-            response.getWriter().write(json.toString());
-            response.getWriter().flush();
+            return;
         }
+
+        JSONObject json = new JSONObject(diagram.getDiagram());
+
+        response.setContentType("application/json");
+        response.setCharacterEncoding("UTF-8");
+        response.setStatus(HttpServletResponse.SC_OK);
+        response.getWriter().write(json.toString());
+        response.getWriter().flush();
     }
 }
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
index a4fa994..5a10f92 100644
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
+++ b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/api/SaveDiagram.java
@@ -25,7 +25,7 @@ public class SaveDiagram extends BaseServlet {
 
         int loggedUserId = getUserId(request);
 
-        String diagramId = request.getParameter("diagramId");
+        String diagramId = request.getParameter("id");
         String name = request.getParameter("name");
         String graphJson = request.getParameter("graphJson");
         String isPublic = request.getParameter("public");
diff --git a/sources/src/main/webapp/css/main.css b/sources/src/main/webapp/css/main.css
index d23616e..789880e 100644
--- a/sources/src/main/webapp/css/main.css
+++ b/sources/src/main/webapp/css/main.css
@@ -11,6 +11,20 @@ ul {
 	padding-left: 0;
 }
 
+td {
+	padding: 0 0.8em;
+	line-height: 35px;
+}
+
+form input[type="text"],
+form input[type="password"] {
+	width: 150px;
+}
+
+form input[type="checkbox"] {
+	margin: 0;
+}
+
 .hidden {
 	display: none !important;
 }
@@ -120,18 +134,6 @@ ul {
 	line-height: 35px;
 }
 
-.header .login_popup td {
-	height: 35px;
-}
-.header .login_popup input {
-	margin-left: 15px;
-}
-
-.header .login_popup input[type=text],
-.header .login_popup input[type=password] {
-	width: 150px;
-}
-
 /* register popup */
 
 .header .register_popup {
diff --git a/sources/src/main/webapp/js/app.js b/sources/src/main/webapp/js/app.js
index f1dd013..d29a650 100644
--- a/sources/src/main/webapp/js/app.js
+++ b/sources/src/main/webapp/js/app.js
@@ -26,6 +26,8 @@ function App() {
 	/** @prop {Filter} filter */
 	this.filter = new Filter;
 
+	/** @prop {string} NAME Application name. */
+	this.NAME = document.title;
 	/** @prop {string} HOME_URL Application home URL. */
 	this.HOME_URL = null;
 	/** @prop {object} API Application programming interface paths. */
@@ -367,7 +369,7 @@ function App() {
 			loadGraphDataPromise = $.getJSON(self.API.loadGraphData);
 
 		} else {
-			getDiagramPromise = $.getJSON(self.API.getDiagram + '?diagramId=' + diagramId);
+			getDiagramPromise = $.getJSON(self.API.getDiagram + '?id=' + diagramId);
 
 			loadGraphDataPromise = getDiagramPromise.then(function(data) {
 				self.diagram = {
diff --git a/sources/src/main/webapp/showGraph.jsp b/sources/src/main/webapp/showGraph.jsp
index 1276b08..a1d619b 100644
--- a/sources/src/main/webapp/showGraph.jsp
+++ b/sources/src/main/webapp/showGraph.jsp
@@ -132,7 +132,7 @@
 							<hr class="navbar-separator">
 						</li>
 						<li>
-							<button class="btn" id="applyLayout" title="Apply layout to current graph.">
+							<button class="btn" id="applyLayout" title="Apply layout to current graph">
 								<img src="images/layout_off.png" id="applyLayoutImg" alt="Apply layout to current graph.">
 							</button>
 						</li>
@@ -140,7 +140,7 @@
 							<hr class="navbar-separator">
 						</li>
 						<li>
-							<button class="btn save-diagram" id="btnSaveDiagram" title="Save diagram as PNG.">
+							<button class="btn save-diagram" id="btnSaveDiagram" title="Save diagram as PNG">
 								<img src="images/png_save.png" id="applyLayoutImg" alt="Save diagram as PNG.">
 							</button>
 						</li>
diff --git a/sources/src/main/webapp/uploadFiles.jsp b/sources/src/main/webapp/uploadFiles.jsp
index 82325db..bbc08d9 100644
--- a/sources/src/main/webapp/uploadFiles.jsp
+++ b/sources/src/main/webapp/uploadFiles.jsp
@@ -37,7 +37,7 @@
 
 				<form method="post" enctype="multipart/form-data">
 					<div class="form-field">
-						<label for="file">Select SPADe data file:</label><br>
+						<label for="file">Select JSON data file:</label><br>
 						<input type="file" name="file" id="file">
 					</div>
 
@@ -67,7 +67,7 @@
 			<div class="diagrams-menu">
 				<h3>Public diagrams</h3>
 
-				<ul>
+				<ul id="publicDiagramList">
 					<c:forEach items="${diagramsPublic}" var="diagram">
 						<li>
 							<a href="${HOME_URL}graph?diagramId=${diagram.id}">${diagram.name}</a>
diff --git a/sources/src/main/webapp/userMenu.jsp b/sources/src/main/webapp/userMenu.jsp
index d774990..0bc0dfd 100644
--- a/sources/src/main/webapp/userMenu.jsp
+++ b/sources/src/main/webapp/userMenu.jsp
@@ -14,18 +14,18 @@
 		<table>
 			<tr>
 				<td>
-					Login name:
+					<label for="loginUsername">Login name:</label>
 				</td>
 				<td>
-					<input type="text" name="username">
+					<input type="text" name="username" id="loginUsername">
 				</td>
 			</tr>
 			<tr>
 				<td>
-					Password:
+					<label for="loginPassword">Password:</label>
 				</td>
 				<td>
-					<input type="password" name="password">
+					<input type="password" name="password" id="loginPassword">
 				</td>
 			</tr>
 			<tr>
@@ -43,42 +43,42 @@
 		<table>	  		
 			<tr>
 				<td>
-					Name:
+					<label for="registerName">Name:</label>
 				</td>
 				<td>
-					<input type="text" name="name">
+					<input type="text" name="name" id="registerName">
 				</td>
 			</tr>
 			<tr>
 				<td>
-					E-mail:
+					<label for="registerEmail">E-mail:</label>
 				</td>
 				<td>
-					<input type="text" name="email">
+					<input type="text" name="email" id="registerEmail">
 				</td>
 			</tr>
 			<tr>
 				<td>
-					Login name:
+					<label for="registerUsername">Login name:</label>
 				</td>
 				<td>
-					<input type="text" name="username">
+					<input type="text" name="username" id="registerUsername">
 				</td>
 			</tr>
 			<tr>
 				<td>
-					Password:
+					<label for="registerPassword">Password:</label>
 				</td>
 				<td>
-					<input type="password" name="password">
+					<input type="password" name="password" id="registerPassword">
 				</td>
 			</tr>
 			<tr>
 				<td>
-					Password again:
+					<label for="registerPasswordCheck">Password again:</label>
 				</td>
 				<td>
-					<input type="password" name="passwordCheck">
+					<input type="password" name="passwordCheck" id="registerPasswordCheck">
 				</td>
 			</tr>
 			<tr>
