diff options
| -rw-r--r-- | public/assets/javascripts/mx/extensions/mx.movements.js | 2 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/reader/ReaderView.js | 3 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/reader/Tracker.js | 108 | ||||
| -rwxr-xr-x | public/assets/stylesheets/app.css | 2 | ||||
| -rw-r--r-- | views/partials/scripts.ejs | 1 |
5 files changed, 114 insertions, 2 deletions
diff --git a/public/assets/javascripts/mx/extensions/mx.movements.js b/public/assets/javascripts/mx/extensions/mx.movements.js index 669a7f4..cea3325 100644 --- a/public/assets/javascripts/mx/extensions/mx.movements.js +++ b/public/assets/javascripts/mx/extensions/mx.movements.js @@ -99,7 +99,7 @@ MX.Movements = function (cam) { break case 27: // esc - map.toggle() + map && map.toggle() break } }) diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index d80f225..c43dc9c 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -15,6 +15,9 @@ var ReaderView = View.extend({ if (window.location.search.indexOf("noui") !== -1) { $(".logo,.topLinks,#editorView").hide() } + else { + this.tracker = new Tracker () + } if (window.location.search.indexOf("mute") !== -1) { app.muted = true } diff --git a/public/assets/javascripts/ui/reader/Tracker.js b/public/assets/javascripts/ui/reader/Tracker.js new file mode 100644 index 0000000..7d9d936 --- /dev/null +++ b/public/assets/javascripts/ui/reader/Tracker.js @@ -0,0 +1,108 @@ +var Tracker = Fiber.extend(function(base){ + + var exports = { + init: function(opt){ + this.wall_id = null + this.scenery_id = null + this.clicks = 0 + + this.wallTimer = new Timer () + this.roomTimer = new Timer () + this.sceneryTimer = new Timer () + + this.events = [] + + this.bind() + this.trackPageview() + }, + + bind: function () { + // + window.addEventListener("click", this.trackClick.bind(this), true) + }, + + trackPageview: function(opt){ + this.events.push([ "view" ]) + }, + + // + // how long they spend in front of each wall + + trackChangeWall: function(opt){ + var duration = this.wallTimer.currentTime() + if (this.wall_id && duration > 5000) { + this.events.push([ "wall", this.wall_id, duration ]) + } + this.wall_id = opt.wall.id + this.wallTimer.start() + }, + + // + // how long the user spends on each item they click + + pickScenery: function(opt){ + this.sceneryTimer.start() + this.scenery_id = opt.scenery.id + }, + + trackScenery: function(){ + var duration = this.sceneryTimer.currentTime() + if (this.scenery_id && duration > 5000) { + this.events.push([ "scenery", this.scenery_id, duration ]) + } + this.scenery_id = null + this.sceneryTimer.reset() + }, + + // + // how long they spend in the room + + trackChangeRoom: function(opt){ + var duration = this.roomTimer.currentTime() + if (this.room_id && duration > 5000) { + this.events.push([ "room", this.room_id, duration ]) + } + this.room_id = opt.room.id + this.roomTimer.start() + }, + + // + // how many clicks per room + + trackClick: function(opt){ + console.log("track click") + this.clicks += 1 + }, + + save: function () { + }, + + } + + return exports +}) + + +var Timer = Fiber.extend(function(base){ + var exports = { + + init: function(opt){ + this.time = 0 + }, + + reset: function(){ + this.time = 0 + }, + + start: function(){ + this.time = Date.now() + }, + + currentTime: function(){ + return this.time ? Date.now() - this.time : 0 + }, + + } +}) + + diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 2cf65c0..30478a4 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1906,7 +1906,7 @@ a[data-role="forgot-password"] { position: fixed; right: 0px; bottom: 10px; - padding-right:10px; + padding: 3px 10px 3px 4px; background:rgba(255,255,255,0.95); z-index: 2; } diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index e0dd0f5..11512b9 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -102,6 +102,7 @@ <script type="text/javascript" src="/assets/javascripts/ui/reader/ReaderView.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/reader/MediaPlayer.js"></script> +<script type="text/javascript" src="/assets/javascripts/ui/reader/Tracker.js"></script> <script type="text/javascript" src="/assets/javascripts/ui/_router.js"></script> |
