More like this…
won’t be needed when origin is fixed bFirstRun_d438ddcc_1374_5af2_a239_75a9025a27a3 = true; // true until we hit sFirstID_d438ddcc_1374_5af2_a239_75a9025a27a3 again bStop_d438ddcc_1374_5af2_a239_75a9025a27a3 = false; // Stop retrieving assets iDisplayCount_d438ddcc_1374_5af2_a239_75a9025a27a3 = 0; // count of assets ready to display iMaxDisplay_d438ddcc_1374_5af2_a239_75a9025a27a3 = 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_d438ddcc_1374_5af2_a239_75a9025a27a3 = null; var oEngagementStage_d438ddcc_1374_5af2_a239_75a9025a27a3 = $(‘.engagement-stage’); var oEngagementSlide_d438ddcc_1374_5af2_a239_75a9025a27a3 = $(‘.engagement-slide’); var oEngagementMore_d438ddcc_1374_5af2_a239_75a9025a27a3 = $(“#engagement-more”); var oEngagementContainer_d438ddcc_1374_5af2_a239_75a9025a27a3 = oEngagementSlide_d438ddcc_1374_5af2_a239_75a9025a27a3.find(“.engagement-container”); var oEngagementSpinner_d438ddcc_1374_5af2_a239_75a9025a27a3 = oEngagementStage_d438ddcc_1374_5af2_a239_75a9025a27a3.find(‘.engagement-spinner’); if (typeof oResponse.next_url == ‘undefined’) { // URL supplied is no good. Revert to original URL sNextUrl_d438ddcc_1374_5af2_a239_75a9025a27a3 = sOriginURL_d438ddcc_1374_5af2_a239_75a9025a27a3; } else { sNextUrl_d438ddcc_1374_5af2_a239_75a9025a27a3 = scrubURL(oResponse.next_url); } if(sNextUrl_d438ddcc_1374_5af2_a239_75a9025a27a3 == “”){ sNextUrl_d438ddcc_1374_5af2_a239_75a9025a27a3 = “/tncms/search/mlt/?origin=d438ddcc-1374-5af2-a239-75a9025a27a3&app=editorial&inline=feature&type=collection”; } // Manage response if (typeof oResponse.assets != ‘undefined’ && oResponse.assets.length > 0) { // Remove old more data oEngagementMore_d438ddcc_1374_5af2_a239_75a9025a27a3.remove(); // Add a ‘start’ static engagement items if((oEngagementStage_d438ddcc_1374_5af2_a239_75a9025a27a3.find(“.engagement-item-static”).length)>0){ oEngagementStage_d438ddcc_1374_5af2_a239_75a9025a27a3.find(“.engagement-items-static.start”).find(“.engagement-item”).each(function(){ var sHTML_d438ddcc_1374_5af2_a239_75a9025a27a3 = ”; if((oEngagementContainer_d438ddcc_1374_5af2_a239_75a9025a27a3.find(“.engagement-item-static”).length)<1){ iDisplayCount_d438ddcc_1374_5af2_a239_75a9025a27a3 ++; sHTML_d438ddcc_1374_5af2_a239_75a9025a27a3 += '' + $(this).html() + ']]>‘;
oEngagementContainer_d438ddcc_1374_5af2_a239_75a9025a27a3.append(sHTML_d438ddcc_1374_5af2_a239_75a9025a27a3);
}
});
}
// Build engagement set
$.each(oResponse.assets, function(index) {
if (index == 1 && sOriginID_d438ddcc_1374_5af2_a239_75a9025a27a3 == null) {
sOriginID_d438ddcc_1374_5af2_a239_75a9025a27a3 = oResponse.assets[0].id;
}
// Display assets once origin is found
// Find origin then begin displaying assets
if (bFoundOrigin_d438ddcc_1374_5af2_a239_75a9025a27a3 == true) {
if (this.id == sOriginID_d438ddcc_1374_5af2_a239_75a9025a27a3) {
// Found orgin a second time. Stop gathering assets and kill next_url
bStop_d438ddcc_1374_5af2_a239_75a9025a27a3 = true;
sNextUrl_d438ddcc_1374_5af2_a239_75a9025a27a3 = null;
oEngagementMore_d438ddcc_1374_5af2_a239_75a9025a27a3.remove();
} else if (bStop_d438ddcc_1374_5af2_a239_75a9025a27a3 == false && this.id != ‘d438ddcc-1374-5af2-a239-75a9025a27a3’) {
// Display asset
var sHTML_d438ddcc_1374_5af2_a239_75a9025a27a3 = ”;
if (this.content.includes(‘engagement-asset’) && iDisplayCount_d438ddcc_1374_5af2_a239_75a9025a27a3 < iMaxDisplay_d438ddcc_1374_5af2_a239_75a9025a27a3) {
iDisplayCount_d438ddcc_1374_5af2_a239_75a9025a27a3 ++;
sHTML_d438ddcc_1374_5af2_a239_75a9025a27a3 +=...
Continue reading