From 8ec47506bf0bad942321d32f546483fda658981d Mon Sep 17 00:00:00 2001 From: Alexander Holland Date: Wed, 11 Nov 2015 14:05:28 +0100 Subject: [PATCH] Issue #331 : Gruntfile : host as variable --- Gruntfile.js | 9 +++++---- src/js/controller/DrawingController.js | 9 +++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 59d602d..faed0ab 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,5 @@ module.exports = function(grunt) { + var ip = 'localhost'; var dateFormat = require('dateformat'); var now = new Date(); var version = '-' + dateFormat(now, "yyyy-mm-dd-hh-MM"); @@ -34,7 +35,7 @@ module.exports = function(grunt) { filesSrc : tests, options : { args : { - baseUrl : 'http://localhost:' + '<%= express.test.options.port %>/', + baseUrl : 'http://' + ip + ':' + '<%= express.test.options.port %>/', mode : '?debug', delay : conf.delay }, @@ -58,7 +59,7 @@ module.exports = function(grunt) { return { options: { port: port, - hostname : host || 'localhost', + hostname : host || ip, bases: bases } }; @@ -111,10 +112,10 @@ module.exports = function(grunt) { }, open : { regular : { - path : 'http://localhost:9001/' + path : 'http://' + ip + ':9001/' }, debug : { - path : 'http://localhost:9901/?debug' + path : 'http://' + ip + ':9901/?debug' } }, diff --git a/src/js/controller/DrawingController.js b/src/js/controller/DrawingController.js index 9683bd5..41f5ca4 100644 --- a/src/js/controller/DrawingController.js +++ b/src/js/controller/DrawingController.js @@ -142,8 +142,7 @@ $.publish(Events.MOUSE_EVENT, [event, this]); var frame = this.piskelController.getCurrentFrame(); var coords = this.getSpriteCoordinates(event.clientX, event.clientY); - if (typeof event.changedTouches != 'undefined' && - typeof event.changedTouches[0] != 'undefined') { + if (event.changedTouches && event.changedTouches[0]) { coords = this.getSpriteCoordinates(event.changedTouches[0].clientX, event.changedTouches[0].clientY); } @@ -170,8 +169,7 @@ ns.DrawingController.prototype.onMousemove_ = function (event) { this._clientX = event.clientX; this._clientY = event.clientY; - if (typeof event.changedTouches != 'undefined' && - typeof event.changedTouches[0] != 'undefined') { + if (event.changedTouches && event.changedTouches[0]) { this._clientX = event.changedTouches[0].clientX; this._clientY = event.changedTouches[0].clientY; } @@ -263,8 +261,7 @@ ns.DrawingController.prototype.onMouseup_ = function (event) { var frame = this.piskelController.getCurrentFrame(); var coords = this.getSpriteCoordinates(event.clientX, event.clientY); - if (typeof event.changedTouches != 'undefined' && - typeof event.changedTouches[0] != 'undefined') { + if (event.changedTouches && event.changedTouches[0]) { coords = this.getSpriteCoordinates(event.changedTouches[0].clientX, event.changedTouches[0].clientY); } if (this.isClicked) {