@ -41,9 +41,11 @@
timeline.on('rangechange', function (properties) {
timeline.on('rangechange', function (properties) {
logEvent('rangechange', properties);
logEvent('rangechange', properties);
});
});
timeline.on('rangechanged', function (properties) {
timeline.on('rangechanged', function (properties) {
logEvent('rangechanged', properties);
logEvent('rangechanged', properties);
});
});
timeline.on('select', function (properties) {
timeline.on('select', function (properties) {
logEvent('select', properties);
logEvent('select', properties);
});
});
@ -52,6 +54,7 @@
logEvent('itemover', properties);
logEvent('itemover', properties);
setHoveredItem(properties.item);
setHoveredItem(properties.item);
});
});
timeline.on('itemout', function (properties) {
timeline.on('itemout', function (properties) {
logEvent('itemout', properties);
logEvent('itemout', properties);
setHoveredItem('none');
setHoveredItem('none');
@ -83,11 +86,23 @@
logEvent(event, properties);
logEvent(event, properties);
});
});
function stringifyObject (object) {
if (!object) return;
var replacer = function(key, value) {
if (value & & value.tagName) {
return "DOM Element";
} else {
return value;
}
}
return JSON.stringify(object, replacer)
}
function logEvent(event, properties) {
function logEvent(event, properties) {
var log = document.getElementById('log');
var log = document.getElementById('log');
var msg = document.createElement('div');
var msg = document.createElement('div');
msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' +
msg.innerHTML = 'event=' + JSON.stringify(event) + ', ' +
'properties=' + JSON.stringify(properties);
'properties=' + stringifyObject (properties);
log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg);
log.firstChild ? log.insertBefore(msg, log.firstChild) : log.appendChild(msg);
}
}