From 36130dab9c149585d37114b374b839ee39a6a06f Mon Sep 17 00:00:00 2001
From: Robert Goldmann <deadlocker@gmx.de>
Date: Mon, 29 Jul 2019 21:25:19 +0200
Subject: [PATCH] client: #24 - cleanup

---
 client/static/js/main.js | 75 ++++++++++++----------------------------
 1 file changed, 22 insertions(+), 53 deletions(-)

diff --git a/client/static/js/main.js b/client/static/js/main.js
index 9ffa155..7f4b5a8 100644
--- a/client/static/js/main.js
+++ b/client/static/js/main.js
@@ -150,59 +150,6 @@ function createTrainMap()
     }
 }
 
-function editTask(task_ID, milestone_ID)
-{
-    var edit = document.getElementById('edit').innerHTML;
-    var title = $('#title').val();
-    var description = $('#description').val();
-    ;
-    var done = document.getElementById("checkbox-done").checked;
-
-    if(isNull(title))
-    {
-        alert("Title shouldn't be empty!");
-        return;
-    }
-
-    if(done)
-    {
-        done = 1;
-    }
-    else
-    {
-        done = 0;
-    }
-
-    $.post('../admin/helper/edit-task.php',
-        {
-            "title": title,
-            "description": description,
-            "done": done,
-            "edit": edit,
-            "ID": task_ID,
-            "milestone-ID": milestone_ID
-
-        }, function(data, error)
-        {
-            data = data.toString().trim();
-            switch(data)
-            {
-                case "error":
-                    alert('An error occurred');
-                    break;
-                case "error-edit":
-                    alert('An error occurred while editing the task with the ID ' + task_ID);
-                    break;
-                case "error-insert":
-                    alert('An error occurred while inserting the new task');
-                    break;
-                default:
-                    window.location.href = "../admin/admin-tasks.php?id=" + milestone_ID;
-                    break;
-            }
-        });
-}
-
 function editSubtask(subtask_ID, task_ID)
 {
     var edit = document.getElementById('edit').innerHTML;
@@ -300,6 +247,7 @@ function validateNewRoadmapForm()
         return false;
     }
 }
+
 function validateNewMilestoneForm()
 {
     var versionCode = $('#version-code').val();
@@ -345,6 +293,27 @@ function validateNewMilestoneForm()
     return true;
 }
 
+
+function validateNewTaskForm()
+{
+    var title = $('#title').val();
+    var description = document.getElementById('description');
+
+    if(isNull(title))
+    {
+        alert("Title shouldn't be empty!");
+        return false;
+    }
+
+    if(isNull(description))
+    {
+        alert("Description shouldn't be empty!");
+        return false;
+    }
+
+    return true;
+}
+
 function markAllTasksAsDone(milestone_ID)
 {
     $.post('../admin/helper/mark-all-tasks-as-done.php',
-- 
GitLab