From e62467cba1a8956c8efdef6fac50929e4e9869d0 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 30 Jun 2012 11:55:15 +0000 Subject: [PATCH] add pandora.logEvent --- static/js/pandora/utils.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 855617dc..6755f13e 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -951,6 +951,36 @@ pandora.isClipView = function(view, item) { ).indexOf(view) > -1; }; +pandora.logEvent = function(data, event, element) { + var element = this, + handlers = self.eventHandlers ? self.eventHandlers[event] : []; + if (!Ox.contains([ + 'mousedown', 'mouserepeat', 'anyclick', 'singleclick', 'doubleclick', + 'dragstart', 'drag', 'dragenter', 'dragleave', 'dragpause', 'dragend', + 'draganddropstart', 'draganddrop', 'draganddropenter', 'draganddropleave', 'draganddropend', + 'playing', 'position', 'progress', 'request' + ], event)) { + try { + data = JSON.stringify(data) + } catch(e) {} + Ox.print( + 'EVENT', + element.oxid, + '"' + element[0].className.split(' ').filter(function(className) { + return /^Ox/.test(className); + }).map(function(className) { + return className.replace(/^Ox/, ''); + }).join(' ') + '"', + event, + data, + handlers.length, + handlers.map(function(handler) { + return handler.toString().split('\n').shift(); + }) + ); + } +}; + pandora.signin = function(data) { pandora.user = data.user; Ox.extend(pandora.user, {