diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-01-20 19:05:02 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-01-20 19:17:48 +0200 |
| commit | 17b89099b36a63ed2854083cdb4cb06f47a41e14 (patch) | |
| tree | 2db4ac8f2bafa8ff923b0080bbe400918ec7f6cd /scripts | |
| parent | 09b2d3ba6bd282982b609ff84410e2bb0e2f9d49 (diff) | |
Refactor file structure
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/client.js | 69 | ||||
| -rw-r--r-- | scripts/log.js | 15 |
2 files changed, 84 insertions, 0 deletions
diff --git a/scripts/client.js b/scripts/client.js new file mode 100644 index 0000000..8cef12a --- /dev/null +++ b/scripts/client.js @@ -0,0 +1,69 @@ +var ioc = angular.module('ioc', []); + +ioc.controller('ioctrl', function($scope) { + var soc = io(); + var pw = 0; + + $scope.uid = 0; + $scope.que = []; + $scope.row = ""; + $scope.name = ""; + $scope.qsize = 0; + $scope.outdated = true; + $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(); + }); + + 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("err", function(err) { + console.log("error! msg: " + err.msg); + }); + + $scope.popfirst = function() { + $scope.outdated = true; + 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/scripts/log.js b/scripts/log.js new file mode 100644 index 0000000..5b5409e --- /dev/null +++ b/scripts/log.js @@ -0,0 +1,15 @@ +var logapp = angular.module('logapp',[]); + +logapp.controller("logctrl",function($scope){ + $scope.logmessages = []; + var socket= io(); + socket.on("connect",function(data){ + socket.emit("logsubscribe","logclient"); + console.log("socket connected"); + }); + socket.on("logmessage",function(data){ + + $scope.logmessages.push(data); + $scope.$apply(); + }); +}); |
