More like this…
won’t be needed when origin is fixed bFirstRun_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = true; // true until we hit sFirstID_1d905f91_b3c2_53bb_b896_aeceb5d9f48e again bStop_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = false; // Stop retrieving assets iDisplayCount_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = 0; // count of assets ready to display iMaxDisplay_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = 12; // max number of assets to display } sURL = scrubURL(sURL); // Until the origin paramter for cms.search.mlt functions, we have to start/stop the looping on our own // This will require not displaying any assets until we hit this.asset. // Then we loop through and display until we’ve been through everything up to our origin or max display $.ajax(sURL).then(function(oResponse, sStatus, oXHR) { var sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = null; var oEngagementStage_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = $(‘.engagement-stage’); var oEngagementSlide_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = $(‘.engagement-slide’); var oEngagementMore_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = $(“#engagement-more”); var oEngagementContainer_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = oEngagementSlide_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.find(“.engagement-container”); var oEngagementSpinner_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = oEngagementStage_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.find(‘.engagement-spinner’); if (typeof oResponse.next_url == ‘undefined’) { // URL supplied is no good. Revert to original URL sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = sOriginURL_1d905f91_b3c2_53bb_b896_aeceb5d9f48e; } else { sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = scrubURL(oResponse.next_url); } if(sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e == “”){ sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = “/tncms/search/mlt/?origin=1d905f91-b3c2-53bb-b896-aeceb5d9f48e&app=editorial&inline=feature&type=collection”; } // Manage response if (typeof oResponse.assets != ‘undefined’ && oResponse.assets.length > 0) { // Remove old more data oEngagementMore_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.remove(); // Add a ‘start’ static engagement items if((oEngagementStage_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.find(“.engagement-item-static”).length)>0){ oEngagementStage_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.find(“.engagement-items-static.start”).find(“.engagement-item”).each(function(){ var sHTML_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = ”; if((oEngagementContainer_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.find(“.engagement-item-static”).length)<1){ iDisplayCount_1d905f91_b3c2_53bb_b896_aeceb5d9f48e ++; sHTML_1d905f91_b3c2_53bb_b896_aeceb5d9f48e += '' + $(this).html() + ']]>‘;
oEngagementContainer_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.append(sHTML_1d905f91_b3c2_53bb_b896_aeceb5d9f48e);
}
});
}
// Build engagement set
$.each(oResponse.assets, function(index) {
if (index == 1 && sOriginID_1d905f91_b3c2_53bb_b896_aeceb5d9f48e == null) {
sOriginID_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = oResponse.assets[0].id;
}
// Display assets once origin is found
// Find origin then begin displaying assets
if (bFoundOrigin_1d905f91_b3c2_53bb_b896_aeceb5d9f48e == true) {
if (this.id == sOriginID_1d905f91_b3c2_53bb_b896_aeceb5d9f48e) {
// Found orgin a second time. Stop gathering assets and kill next_url
bStop_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = true;
sNextUrl_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = null;
oEngagementMore_1d905f91_b3c2_53bb_b896_aeceb5d9f48e.remove();
} else if (bStop_1d905f91_b3c2_53bb_b896_aeceb5d9f48e == false && this.id != ‘1d905f91-b3c2-53bb-b896-aeceb5d9f48e’) {
// Display asset
var sHTML_1d905f91_b3c2_53bb_b896_aeceb5d9f48e = ”;
if (this.content.includes(‘engagement-asset’) && iDisplayCount_1d905f91_b3c2_53bb_b896_aeceb5d9f48e < iMaxDisplay_1d905f91_b3c2_53bb_b896_aeceb5d9f48e) {
iDisplayCount_1d905f91_b3c2_53bb_b896_aeceb5d9f48e ++;
sHTML_1d905f91_b3c2_53bb_b896_aeceb5d9f48e +=...
Continue reading