From 09b2d3ba6bd282982b609ff84410e2bb0e2f9d49 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 20 Jan 2016 18:48:43 +0200 Subject: Add error message if the input is not sane --- f/images/delete.jpg | Bin 1307 -> 0 bytes f/scripts/client.js | 99 ++++++++++++++++++++++++++++++------------------- f/styles/style.css | 9 ++++- f/templates/index.html | 4 ++ 4 files changed, 72 insertions(+), 40 deletions(-) delete mode 100644 f/images/delete.jpg (limited to 'f') diff --git a/f/images/delete.jpg b/f/images/delete.jpg deleted file mode 100644 index 1ae7bfa..0000000 Binary files a/f/images/delete.jpg and /dev/null differ diff --git a/f/scripts/client.js b/f/scripts/client.js index b02123f..8cef12a 100644 --- a/f/scripts/client.js +++ b/f/scripts/client.js @@ -1,48 +1,69 @@ -var ioc = angular.module('ioc',[]); +var ioc = angular.module('ioc', []); -ioc.controller('ioctrl',function($scope){ - var soc= io(); - var pw =0; +ioc.controller('ioctrl', function($scope) { + var soc = io(); + var pw = 0; - $scope.uid =0; - $scope.que=[]; - $scope.row=""; - $scope.name=""; - $scope.qsize=0; + $scope.uid = 0; + $scope.que = []; + $scope.row = ""; + $scope.name = ""; + $scope.qsize = 0; $scope.outdated = true; - - $scope.submit = function(){ - soc.emit("queadd",{"row":$scope.row,"name":$scope.name,"uid":$scope.uid}); - $scope.row=""; - $scope.name=""; - }; - - soc.on("quedata",function(data){ - $scope.que=data; - $scope.qsize=data.length; + $scope.error_message = ""; + + $scope.submit = function() { + if ($scope.row == "") + $scope.error_message = "Valitse rivi ennen lisäämistä!"; + else if ($scope.name == "") + $scope.error_message = "Kirjoita nimesi ennen lisäämistä!"; + else { + soc.emit("queadd", { + "row": $scope.row, + "name": $scope.name, + "uid": $scope.uid + }); + $scope.error_message = ""; + $scope.row = ""; + $scope.name = ""; + } + }; + + soc.on("quedata", function(data) { + $scope.que = data; + $scope.qsize = data.length; $scope.outdated = false; - $scope.$apply(); - }); + $scope.$apply(); + }); - soc.on("userinfo",function(data){ - $scope.uid = data.uid; - pw= data.pw; - }); + soc.on("userinfo", function(data) { + $scope.uid = data.uid; + pw = data.pw; + }); - soc.on("disconnect",function(data){ - setTimeout(function(){console.log("blblbl");$scope.uid = data.uid;pw= data.pw;$scope.$apply();},1000) - }); + soc.on("disconnect", function(data) { + setTimeout(function() { + console.log("blblbl"); + $scope.uid = data.uid; + pw = data.pw; + $scope.$apply(); + }, 1000); + }); - soc.on("err",function(err){ - console.log("error! msg: "+err.msg); - }); + soc.on("err", function(err) { + console.log("error! msg: " + err.msg); + }); - $scope.popfirst = function(){ + $scope.popfirst = function() { $scope.outdated = true; - soc.emit("quepopfirst",""); - }; - $scope.querm = function(qid){ - data = {"qid":qid,"pw":pw}; - soc.emit("quedelete",data); - }; -}); + soc.emit("quepopfirst", ""); + }; + + $scope.querm = function(qid) { + data = { + "qid": qid, + "pw": pw + }; + soc.emit("quedelete", data); + }; +}); \ No newline at end of file diff --git a/f/styles/style.css b/f/styles/style.css index 3209cef..1d5df84 100644 --- a/f/styles/style.css +++ b/f/styles/style.css @@ -15,6 +15,13 @@ body{ font-style: italic; } +#add-error { + margin-top: 10px; + color: #c0392b; + font-style: italic; + font-weight: 700; +} + .form-name { font-weight: 700; } @@ -90,7 +97,7 @@ td { text-decoration:none; } .removeButton:hover { - background-color:#408c99; + background-color: #a53a2b; } .removeButton:active { position:relative; diff --git a/f/templates/index.html b/f/templates/index.html index 81e2b7c..488f6b9 100644 --- a/f/templates/index.html +++ b/f/templates/index.html @@ -42,6 +42,10 @@ Lisää +
+ {{error_message}} +
+
Poista {{person.name}} -- cgit v1.3