Skip to content
This repository has been archived by the owner. It is now read-only.

Validate invalid track event times #97

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -21,16 +21,14 @@
okPressed,
cancelPressed;
function sendData( alsoClose ){
alsoClose = !!alsoClose;
function sendData(){
var popcornOptions = {};
for( var item in _manifest ) {
popcornOptions[ item ] = document.getElementById( item ).value;
}
document.getElementById( "message" ).innerHTML = "";
_comm.send( "submit", {
eventData: popcornOptions,
alsoClose: alsoClose
eventData: popcornOptions
});
} //sendData
@@ -57,6 +55,7 @@
var element = document.getElementById( item );
element.value = e.data[ item ];
} //for
_comm.send( "close" );
});
_comm.listen( "trackeventupdatefailed", function( e ) {
@@ -33,18 +33,34 @@ define( [ "./logger", "./eventmanager", "util/lang", "util/time" ], function( Lo
_popcornOptions.end = _popcornOptions.end || _popcornOptions.start + 1;
_popcornOptions.end = TimeUtil.roundTime( _popcornOptions.end );

this.update = function( updateOptions ) {
this.update = function( updateOptions, duration ) {
updateOptions.start = +updateOptions.start;
updateOptions.end = +updateOptions.end;
if( ( updateOptions.start != updateOptions.start ) ||
( updateOptions.end != updateOptions.end ) ||
updateOptions.start < 0 ||
updateOptions.end > duration ||
updateOptions.start >= updateOptions.end ){
_this.dispatch( "trackeventupdatefailed", {
error: "trackeventupdate::invalidtime",
message: "Invalid start/end times.",
mediaDuration: duration,
attemptedData: updateOptions
});
return;
} //if

for ( var prop in updateOptions ) {
if ( updateOptions.hasOwnProperty( prop ) ) {
_popcornOptions[ prop ] = updateOptions[ prop ];
} //if
} //for
if ( _popcornOptions.start ) {
_popcornOptions.start = TimeUtil.roundTime( _popcornOptions.start );
}
} //if
if ( _popcornOptions.end ) {
_popcornOptions.end = TimeUtil.roundTime( _popcornOptions.end );
}
} //if
_em.dispatch( "trackeventupdated", _this );
}; //update

@@ -86,33 +86,13 @@ define( [ "core/eventmanager", "dialog/iframe-dialog", "dialog/window-dialog", "
},
submit: function( e ){
var duration = TimeUtil.roundTime( butter.currentMedia.duration ),
popcornData = e.data.eventData,
alsoClose = e.data.alsoClose;
if( popcornData ){
popcornData.start = Number( popcornData.start );
popcornData.end = Number( popcornData.end );
if( isNaN( popcornData.start ) ||
isNaN( popcornData.end ) ||
popcornData.start < 0 ||
popcornData.end > duration ||
popcornData.start >= popcornData.end ){
trackEvent.dispatch( "trackeventupdatefailed", {
error: "trackeventupdate::invalidtime",
message: "Invalid start/end times.",
attemptedData: popcornData
});
}
else{
if( popcornData.target !== _currentTarget ){
_currentTarget = popcornData.target;
blinkTarget();
} //if
trackEvent.update( popcornData );
if( alsoClose ){
_dialog.close();
} //if
} //if
popcornData = e.data.eventData;

if( popcornData.target !== _currentTarget ){
_currentTarget = popcornData.target;
blinkTarget();
} //if
trackEvent.update( popcornData, duration );
},
close: function( e ){
trackEvent.unlisten( "trackeventupdated", onTrackEventUpdated );
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.