My Wishlist

if (typeof sswPageInterval == 'undefined') {

var sswPageInterval = setInterval(function () {

if (typeof sswJqLoaded != 'undefined' && sswJqLoaded) {

clearInterval(sswPageInterval);

var path_name = window.location.pathname;

var ssw_substr = '/pages/';

var ssw_index = path_name.indexOf(ssw_substr) + ssw_substr.length;

var ssw_request_url = sswProxyUrl + '/lite2/' + path_name.substr(ssw_index);

if (path_name.indexOf('pages/profile-edit') > -1) {

ssw_request_url = sswProxyUrl + '/lite2/profile-edit';

}

else if (path_name.substr(ssw_index) == 'feed' || path_name.indexOf('pages/profile') > -1)

ssw_request_url = sswProxyUrl + '/lite2/' + path_name.substr(ssw_index) + '/';

else if (path_name.substr(ssw_index) == 'collections' || path_name.substr(ssw_index) == 'people' || path_name.substr(ssw_index) == 'invite' || path_name.substr(ssw_index) == 'faves' || path_name.substr(ssw_index) == 'edit-notifications' || path_name.substr(ssw_index) == 'reviews')

ssw_request_url = sswProxyUrl + '/lite2/' + path_name.substr(ssw_index);

var params = location.search.substring(1).replace(/_sid\=[0-9a-f-]+\&*|\bhash_key\b\=[0-9a-f-]+\&*/ig, '');

if (path_name.indexOf('pages/collections') && window.location.hash.substring(1)) {

if (params) {

params += '&' + window.location.hash.substring(1);

}

else {

params = window.location.hash.substring(1);

}

}

var data = '_sid=' + sswCookie('hesid');

if (typeof sswApp !== 'undefined' && typeof sswApp.accounts_enabled !== 'undefined') {

data += '&accounts_enabled=' + sswApp.accounts_enabled;

}

if (params) {

data += '&' + params;

}

if (sswCookie('mail_id')) {

data += '&resource_id=' + sswCookie('mail_id') + '&resource_type=mail';

}

sswUserChecked(function () {

if (path_name.substr(ssw_index) == 'reviews') {

/* Define TimeZone offset */

const customer_timezone_offset = -1 * new Date().getTimezoneOffset() * 60;

data += '&customer_timezone_offset=' + customer_timezone_offset;

}

data += '&hash_key=' + sswCookie('hash_key');

ssw.post(ssw_request_url, data, 'html').done(function (response) {

ssw('#ssw-page').css('opacity', 0);

ssw('#ssw-page').html(response).animate({

opacity: "1"

}, 50, function () {

if (typeof window.afterSswPageLoadedCallback === 'function') {

window.afterSswPageLoadedCallback(response);

}

sswDispatchEvent('sswPageLoaded', {

detail: {},

bubbles: true,

cancelable: false

});

});

}).fail(function(jqXHR) {

if (jqXHR?.responseJSON?.message === 'Storefront account is disabled') {

ssw('#ssw-page').slideUp( "slow");

}

});

});

}

}, 300);

}

This script efficiently manages dynamic content loading for various pages within the application, ensuring a smooth user experience. It intelligently constructs the `ssw_request_url` based on the current page's path, leveraging the `ssw_index` to accurately parse the relevant part of the URL. For instance, if a user navigates to a profile editing page, the `ssw_request_url` is specifically tailored to `/lite2/profile-edit`. The `substr ssw` logic ensures that the correct page segment is always identified, whether it's for 'feed', 'collections', 'people', or 'reviews'.

The system also handles diverse parameters, stripping out sensitive session identifiers for cleaner requests while incorporating crucial details like `mail_id` and `accounts_enabled` when applicable. For specific functionalities like 'reviews', it even includes the customer's timezone offset, enhancing the relevance and accuracy of displayed information. Once the `ssw_request_url` is finalized and all necessary data is compiled, the script performs an asynchronous post request. Upon successful retrieval, the `#ssw-page` element is smoothly updated with the new content, providing a seamless visual transition for the user. In cases where a storefront account might be disabled, the system gracefully handles the error by animating the `#ssw-page` to slide up, informing the user without disrupting the overall site functionality. This robust approach to content delivery significantly improves page load times and user engagement.