Skip to content

Commit bcaf6f6

Browse files
author
Georg Eschbacher
committed
bugfixed hall of fame redis names and added working animations on table
1 parent d3bee00 commit bcaf6f6

File tree

11 files changed

+49
-51
lines changed

11 files changed

+49
-51
lines changed

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = function(grunt) {
1212
module: true,
1313
document: true,
1414
smarttabs: true
15-
},
15+
}
1616
}
1717
},
1818
watch: {

app.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ server.get("/image/:id", function(req, res) {
3535

3636
var serverAuth = {
3737
incoming: function(message, callback) {
38-
if(message.channel === '/drone/drone' || message.channel === '/drone/move'
39-
|| message.channel === '/drone/animate' || message.channel === '/drone/recording'
40-
|| message.channel === '/drone/qrcode' || message.channel === '/drone/saveImage'
41-
|| message.channel === '/drone/release') {
38+
if(message.channel === '/drone/drone' || message.channel === '/drone/move' || message.channel === '/drone/animate' || message.channel === '/drone/recording' || message.channel === '/drone/qrcode' || message.channel === '/drone/saveImage' || message.channel === '/drone/release') {
4239
var msgToken = message.ext && message.ext.token;
4340
if (token !== msgToken) {
4441
message.error = 'Invalid auth token';
@@ -55,7 +52,7 @@ var setNewToken = function(callback) {
5552
callback();
5653
}
5754
});
58-
}
55+
};
5956

6057
var adapter = new faye.NodeAdapter({
6158
mount:'/faye',
@@ -122,7 +119,7 @@ adapter.getClient().subscribe("/drone/release", function(){
122119
});
123120

124121
adapter.getClient().subscribe('/drone/halloffame', function(data) {
125-
redisClient.setName(data.data, function() {
122+
redisCli.setNames(data.data, function() {
126123
adapter.getClient().publish("/drone/newgame/"+data.guid, {});
127124
});
128125
});
@@ -153,26 +150,26 @@ drone.createPngStream().on("data", function(frame) {
153150

154151
imageSendingPaused = true;
155152
return setTimeout((function() {
156-
return imageSendingPaused = false;
153+
imageSendingPaused = false;
157154
}), 100);
158155
});
159156

160157
var droneAction = function(cmd) {
161158
var _name;
162159
console.log('dronecommand:', cmd);
163160
return typeof drone[_name = cmd.action] === "function" ? drone[_name]() : void 0;
164-
}
161+
};
165162

166163
var moveAction = function(cmd) {
167164
var _name = cmd.action;
168165
console.log("move", cmd);
169166
return typeof drone[_name = cmd.action] === "function" ? drone[_name](cmd.speed) : void 0;
170-
}
167+
};
171168

172169
var animateAction = function(cmd) {
173170
console.log('animate', cmd);
174171
drone.animate(cmd.action, cmd.duration);
175-
}
172+
};
176173

177174
var record = function() {
178175
if(recording) {
@@ -187,7 +184,7 @@ var record = function() {
187184
fs.mkdirSync('video/'+folder);
188185
recording = true;
189186
}
190-
}
187+
};
191188

192189
var snap = function() {
193190
var imagedata = '';
@@ -198,7 +195,7 @@ var snap = function() {
198195
if(err) throw err;
199196
});
200197
}
201-
}
198+
};
202199

203200

204201

public/javascripts/main.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ require.config({
5656
},
5757
'decoder':{
5858
deps:['gf256']
59-
},
59+
}
6060
}
6161
});
6262

@@ -90,14 +90,11 @@ require(['jQuery', 'underscore', 'keydrown','faye', 'joystick', 'bacon', 'onsnap
9090

9191
droneFaye.addExtension({
9292
outgoing: function(message, callback) {
93-
if(message.channel === '/drone/drone' || message.channel === '/drone/move'
94-
|| message.channel === '/drone/animate' || message.channel === '/drone/recording'
95-
|| message.channel === '/drone/qrcode' || message.channel === '/drone/saveImage'
96-
|| message.channel === '/drone/release') {
93+
if(message.channel === '/drone/drone' || message.channel === '/drone/move' || message.channel === '/drone/animate' || message.channel === '/drone/recording' || message.channel === '/drone/qrcode' || message.channel === '/drone/saveImage' || message.channel === '/drone/release') {
9794
message.ext = message.ext || {};
9895
message.ext.token = USER_TOKEN;
9996
}
100-
callback(message)
97+
callback(message);
10198
}
10299
});
103100

@@ -116,8 +113,8 @@ require(['jQuery', 'underscore', 'keydrown','faye', 'joystick', 'bacon', 'onsnap
116113
});
117114

118115
droneFaye.subscribe("/drone/newgame/"+guid, function(src) {
119-
$("#qr").remove();
120-
});
116+
$("#qr").remove();
117+
});
121118

122119
droneFaye.subscribe("/drone/freeDrone", function(data) {
123120
$('.controls').addClass('disabled');

public/javascripts/model.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ define(['jQuery', 'logger', 'keydrown', 'underscore', 'faye', 'bacon'],
33
var DroneModel = function () {
44

55
this._batteryState = undefined;
6-
this._droneState={
7-
};
8-
this.currentImg;
6+
this.currentImg = 0;
97

108
this._isMobileBrowser = this._checkIfMobile(navigator.userAgent || navigator.vendor || window.opera);
119
};
@@ -23,10 +21,11 @@ define(['jQuery', 'logger', 'keydrown', 'underscore', 'faye', 'bacon'],
2321

2422
DroneModel.prototype.setCurrentImg = function(src) {
2523
this.currentImg = src;
26-
}
24+
};
25+
2726
DroneModel.prototype.getCurrentImg = function() {
2827
return this.currentImg;
29-
}
28+
};
3029

3130

3231
return DroneModel;

public/javascripts/views/QrDecoder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function($, logger, grid, version, detector, formatinf, errorlevel, bitmat, data
88
try{
99
qrcode.decode(that.qrImg.src);
1010
qrcode.callback = function (data){
11-
//R-Code Inhalt hier verfügbar!!
11+
console.log(data);
1212
that.checkMessage(data)
1313
};
1414
}catch(e){

public/javascripts/views/StreamView.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['jQuery', 'logger'], function($, logger) {
1+
define(['jQuery', 'logger', 'keydrown'], function($, logger, kd) {
22
var StreamView = function (droneFaye, model, $element, qrDecoder) {
33
this.model=model;
44
this.droneFaye = droneFaye;
@@ -10,7 +10,7 @@ define(['jQuery', 'logger'], function($, logger) {
1010
$(".btn-player").click(function() {
1111
var name = $('playerNameInput').val();
1212
});
13-
$("#intro .btn-player").on("click", this.onBtnPlayerClick);
13+
$("#intro .btn-player").on("click", this.onBtnPlayerClick.bind(this));
1414

1515

1616

@@ -43,7 +43,7 @@ define(['jQuery', 'logger'], function($, logger) {
4343
$("#attention").css("opacity","100");
4444
$("#attention").hide();
4545
$('#stats').append('\
46-
<table id="qr" class="table table-striped table-bordered">\
46+
<table id="qr" class="table table-bordered">\
4747
<tr>\
4848
<th>QR-Code</th>\
4949
<th>Number of Scanns</th>\
@@ -59,24 +59,31 @@ define(['jQuery', 'logger'], function($, logger) {
5959
       if ($("#playerNameInput").val()) {
6060
           name = $("#playerNameInput").val();
6161
       }
62-
that.droneFaye.publish("/drone/halloffame", {
62+
this.droneFaye.publish("/drone/halloffame", {
6363
data:name
6464
});
65+
66+
kd.run(function () {
67+
kd.tick();
68+
});
69+
6570
       e.preventDefault();
6671
};
6772

6873
StreamView.prototype.renderStatistics = function () {
69-
var value;
74+
var value, counter=0;
7075
for(var index in this.statistics) {
7176
if(this.statistics.hasOwnProperty(index)) {
77+
counter++;
7278
value = index.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,'');;
7379
if(($("#"+value).length)>0){
7480
$("#"+value).html(this.statistics[index]);
7581
}
7682
else {
7783
$("#qr>tbody").append('<tr class="blinkLine"><td>'+index+'</td><td id ='+value+'>'+this.statistics[index]+'</td></tr>');
7884
}
79-
if(index == 2) {
85+
if(counter == 3) {
86+
kd.stop();
8087
$("#intro").addClass('active');
8188
}
8289
}

public/stylesheets/style.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,8 @@ body {
208208

209209
.blinkLine {
210210
-webkit-transition:all 1s ease-in-out;
211-
-webkit-animation: blink123 normal 3 infinite ease-in-out;
211+
-webkit-animation: blinkTR normal 3s 3 ease-in-out;
212212
}
213-
214213
@media screen and (device-aspect-ratio: 40/71) and (orientation : landscape) {
215214
body{
216215
padding: 0 !important;

redisClient.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ redisClient = redis.createClient();
44

55
exports.saveToRedis = function(key,callback) {
66
if(redisClient.sismember('codes',key)) {
7-
console.log('ismember');
87
redisClient.incr(key);
98
redisClient.get(key, function(err, reply) {
109
// reply is null when the key is missing
@@ -14,13 +13,13 @@ exports.saveToRedis = function(key,callback) {
1413
}
1514

1615
exports.getNames = function(callback) {
17-
redisClient.smembers('thomas',function(err,reply) {
16+
redisClient.smembers('userList',function(err,reply) {
1817
callback(reply);
1918
});
2019
}
2120

22-
exports.setNames = function(callback) {
23-
redisClient.sadd('thomas',function(err,reply) {
21+
exports.setNames = function(key, callback) {
22+
redisClient.sadd('userList', key, function(err,reply) {
2423
callback(reply);
2524
});
2625
}

routes/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
redisCli = require('../redisClient'),
66

77

8-
exports.index = function(req, res){
8+
/*exports.index = function(req, res){
99
res.render('index', { title: 'Node-Copter', author: 'Georg Eschbacher & Michael Hettegger', description: 'Fly the Node-Copter'});
1010
};
1111
1212
1313
exports.contact = function(req, res){
1414
res.render('contact', { title: 'Node-Copter', author: 'Georg Eschbacher & Michael Hettegger', description: 'Fly the Node-Copter'});
1515
};
16-
16+
*/
1717
exports.about = function(req, res){
1818
redisCli.getNames(function(data) {
1919
var names = data;
2020
res.render('about', {names : names, title: 'Node-Copter', author: 'Georg Eschbacher & Michael Hettegger', description: 'Fly the Node-Copter'});
2121
});
2222
};
23-
23+
/*
2424
exports.connect = function(req, res){
2525
res.render('connect', { title: 'Node-Copter', author: 'Georg Eschbacher & Michael Hettegger', description: 'Fly the Node-Copter'});
2626
};
2727
2828
exports.i18n = function(req, res){
2929
res.render('i18n', { title: 'Node-Copter', author: 'Georg Eschbacher & Michael Hettegger', description: 'Fly the Node-Copter'});
30-
};
30+
};*/

test/drone.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Check if the drone is connected and ', function(){
4949
socket.publish("/drone/image", "/image/" + (Math.random()));
5050
imageSendingPaused = true;
5151
return setTimeout((function() {
52-
return imageSendingPaused = false;
52+
imageSendingPaused = false;
5353
}), 100);
5454
});
5555
socket.subscribe("/drone/move", function(cmd) {
@@ -64,7 +64,6 @@ describe('Check if the drone is connected and ', function(){
6464
var _name;
6565
console.log('drone command: ', cmd);
6666
droneBool = true;
67-
console.log('----------------------------------')
6867
return typeof drone[_name = cmd.action] === "function" ? drone[_name]() : void 0;
6968
});
7069

@@ -149,7 +148,7 @@ describe('Check if the drone is connected and ', function(){
149148
expect(droneBool).to.equal(true);
150149
droneBool = false;
151150
done();
152-
},100)
151+
},100);
153152
});
154153
});
155154

0 commit comments

Comments
 (0)