Skip to content

Instantly share code, notes, and snippets.

@niechen
Created July 15, 2015 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niechen/1688869e03cbc28613fa to your computer and use it in GitHub Desktop.
Save niechen/1688869e03cbc28613fa to your computer and use it in GitHub Desktop.
slideshow ab test
var slideshowCallback = function (data) {
//LIFT Ignite call
if( data !== null && data.items.length ) {
//Render last slideshow lists with Lift Ignite Response
renderResponse( true, data );
//Fire LiftIgnite Track Call
BLOCK.lgLoader.track( {
elements: $j( '#lastSlideContent > li.item' ),
name : ( RNKR.query.isMobile ? 'mobile-slide-show' : 'desktop-slide-show' ),
source: 'LI'
} );
}
else {
//Get last page from API
$j.ajax( {
type : 'GET',
url : RNKR.server.relatedListsApiServer + '/lists/' + LIST.id + '/slideshownextlists',
data : 'limit=8&imageSize=160&isMobile=' + RNKR.query.isMobile,
success : function( response ){
//Catch JSON error
if( !response.error ){
//Render last slideshow lists with fall back api
renderResponse( false, response );
//Fire LiftIgnite Track call with BASE
BLOCK.lgLoader.track( {
elements: $j( '#lastSlideContent > li.item' ),
name : ( RNKR.query.isMobile ? 'mobile-slide-show' : 'desktop-slide-show' ),
source: 'base'
} );
}
else{
alert( response.errorCode + ': ' + response.errorMessage );
}
}
} );
}
}
var abTestHandler = function(hash) {
if (hash % 100 > 50) {
$p('register', {
max: 8,
widget: ( RNKR.query.isMobile ? 'mobile-slide-show' : 'desktop-slide-show' ),
callback: function(response){
//Save End of Slideshow response
slideshowCallback(response);
}
} );
}
$p( 'fetch' );
};
if ( LIST.format === 'SLIDESHOW' ) {
$p( 'userHash' , {callback: abTestHandler});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment