‘);
$(‘.lee-featured-subscription’).html(sFallBack);
}
function lee_formatPackage(oService){
try {
var bOnlyModal = true;
var oSettings = lee_getPackageSettings(oService.HomeMembership);
var newService = {};
if(parseInt(oService.WebFeatureFG) === 2) return false;
if(oService.WebStartPrice != ”){
var custom = JSON.parse(oService.WebStartPrice);
$.each(custom, function(k,v){
newService[k] = v;
});
}
if(bOnlyModal && newService.in_modal === ‘false’) return false;
if(!bOnlyModal && newService.not_members === ‘true’) return false;
newService.sort = parseInt((newService.sort) ? newService.sort : oSettings.sort);
newService.title = oSettings.title;
newService.level = oService.HomeMembership;
newService.html = oService.WebOfferHTML;
newService.disabled = newService.disable_purchase ? ‘disabled’ : ”;
var price = lee_formatPackagePrice(newService.start_price);
newService.start_price = price.cost;
newService.format_dollars = (price.format_dollars) ? price.format_dollars : ”;
newService.format_cents = (price.format_cents) ? price.format_cents : ”;
newService.start_at_rate = (newService.fixed_rate === ‘true’) ? ‘for the low price of’ : ‘starting at’;
if( !newService.term ) newService.term = ‘per month’;
if( newService.promotional_price && newService.promotional_price != ” ){
newService.has_promotion_class = ‘has-promotion’;
var promotion = lee_formatPackagePrice(newService.promotional_price);
newService.promotional_price = promotion.cost;
newService.promotional_format_dollars = (promotion.format_dollars) ? promotion.format_dollars : ”;
newService.promotional_format_cents = (promotion.format_cents) ? promotion.format_cents : ”;
}
newService.action_button = ‘Sign Up’;
if(newService.disabled === ‘disabled’){
newService.start_at_rate = ‘Call us at’;
newService.start_price = ‘800-452-7570’;
newService.term = ‘to get started’;
newService.action_button = ‘Call Today’;
}
window.lee_service_impressions.push({
‘id’: newService.level,
‘name’: newService.title,
‘price’: newService.start_price,
‘brand’: “qctimes.com”,
‘category’: ‘subscription’,
‘list’: ‘Block’,
‘position’: newService.sort
});
return newService;
} catch(e){
if(window.console) console.warn(e);
return false;
}
}
function lee_sortPackages(property) {
var sortOrder = 1;
if(property[0] === “-“) {
sortOrder = -1;
property = property.substr(1);
}
return function (a,b) {
var result = (a[property] b[property]) ? 1 : 0;
return result * sortOrder;
}
}
function lee_getPackageSettings(sPackage){
switch(sPackage.toLowerCase()){
case ‘dob’:
return {title: ‘Digital Basic’, sort: 0};
break;
case ‘dop’:
return {title: ‘Digital Plus’, sort: 1};
break;
case ‘dopl’:
return {title: ‘Digital Platinum’, sort: 2};
break;
case ‘silv’:
return {title: ‘Silver’, sort: 3};
break;
case ‘gold’:
return {title: ‘Gold’, sort: 4};
break;
case ‘plat’:
return {title: ‘Platinum’, sort: 5};
break;
}
}
function lee_replacePackageTokens(sPackage, oService, sCol){
var hasPromotion = false;
$.each(oService, function(k,v){
if( k === ‘html’){
v = v.replace(new RegExp(‘{{domain}}’, ‘gi’), ‘qctimes.com’)
.replace(new RegExp(‘{{site_name}}’, ‘gi’), ‘The Quad-City Times’)
.replace(new RegExp(‘{{business_name}}’, ‘gi’), ‘The Quad City Times’)
.replace(new RegExp(‘{{site_phone}}’, ‘gi’), ‘800-452-7570’);
}
sPackage = sPackage.replace(new RegExp(‘{{‘+k+’}}’, ‘gi’), v);
});
if(sCol) sPackage = sPackage.replace(‘{{col}}’, sCol);
return sPackage;
}
try {
var oPackages = [],
oFeatured = false,
sHtml = ”,
sTemplate = $(‘#lee-service-template’).html();
$.each(window.leeMembershipPackages, function(i, oService){
var oService = lee_formatPackage(oService);
if(oService){
oPackages.push(oService);
if(oService.featured === ‘true’) oFeatured = oService;
}
});
if(oPackages.length === 0){ throw ‘No packages defined’; }
oPackages.sort(lee_sortPackages(‘sort’));
if(!oFeatured) oFeatured = oPackages[0];
switch(oPackages.length){
case 6: var sCol = ‘2’; break;
case 5: var sCol = ‘5ths’; break;
case 4: var sCol = ‘3’; break;
case 3: var sCol = ‘4’; break;
case 2: var sCol = ‘6’; break;
default: var sCol = ’12’; break;
}
$(‘#lee-services-modal’).addClass(‘packages_’+oPackages.length);
$.each(oPackages, function(i, oService){
sHtml += lee_replacePackageTokens(sTemplate, oService, sCol);
});
$(‘#lee-services-list .packages’).html(sHtml).promise().then(function(){
setTimeout(function(){
$(‘#lee-services-list .body’).each(function(){
if( $(this).prop(‘scrollHeight’) 0 && oFeatured ){
$(‘.lee-featured-subscription’).each(function(){
var html = $(this).html();
if( !oFeatured.featured_button_text ){
if(oFeatured.promotional_price){
oFeatured.featured_button_text = oFeatured.promotional_format_dollars+oFeatured.promotional_price+oFeatured.promotional_format_cents+’ ‘+oFeatured.term;
} else {
oFeatured.featured_button_text = ‘Join for ‘+oFeatured.format_dollars+oFeatured.start_price+oFeatured.format_cents+’ ‘+oFeatured.term;
}
}
html = lee_replacePackageTokens(html, oFeatured);
$(this).html(html);
if(oFeatured.promotional_price) $(this).addClass(‘has-promotiom’);
if( $(this).hasClass(‘show-after-loaded’) ) $(this).show();
});
}
}
} catch (e) {
if(window.console) console.warn(e);
lee_serviceError();
}
window.lee_fetched_services = true;
});
Thanks for being a subscriber.
Sorry, your subscription does not include this content.
Please call 800-452-7570 to upgrade your subscription.