jQuery(function(){
var ParentId = 'ChirashiplusFlyersListDivH';
jQuery('#'+ParentId).append('
ホームセンター
');
var ThumbSize = jQuery('#'+ParentId).innerWidth() - 4;
var Flyers = [
{
id: 26553773,
code: '6e3e5c74ecc59f08e7c4317dabebb244',
expose: '20245801',
title: '【24/5/8~5/20】暮らし全力応援',
client: 'shimachu',
from: '20240508',
now: '20240508',
fromto: '2024年5月8日 ~ 2024年5月20日',
sale: '売出期間:5/8~5/20',
linkurl: '',
thumburl: 'https://cips.chirashiplus.tv/2526/26553773/0/framein-150-210.jpg'
},
{
id: 26458779,
code: 'aeb5299b4526196c0b1f7bfde9531930',
expose: '20245701',
title: '【24/5/7~6/3】虫の少ない快適生活',
client: 'shimachu',
from: '20240507',
now: '20240508',
fromto: '2024年5月7日 ~ 2024年6月3日',
sale: '売出期間:5/7~6/3',
linkurl: '',
thumburl: 'https://cips.chirashiplus.tv/2526/26458779/0/framein-150-210.jpg'
},
{
id: 26271379,
code: '326fea3067c2333b0f2e35f9be588d21',
expose: '202441336',
title: '【24/4/13~5/13】補助金でお得にリフォーム',
client: 'shimachu',
from: '20240413',
now: '20240508',
fromto: '2024年4月13日 ~ 2024年5月13日',
sale: '売出期間:4/13~5/13',
linkurl: '',
thumburl: 'https://cips.chirashiplus.tv/2526/26271379/0/framein-150-210.jpg'
},
];
//リンククリック時
jQuery(document).on('click', '#' + ParentId + ' a', function(){
var linkurl = jQuery(this).parents('.shopflyer-list-item').attr('linkurl');
var fid = jQuery(this).parents('.shopflyer-list-item').attr('fid');
var code = jQuery(this).parents('.shopflyer-list-item').attr('code');
var client = jQuery(this).parents('.shopflyer-list-item').attr('client');
var clientId = 2526;
var storeId = 86020;
var storeExtId = 'c7f3a3b5b417867f91da3785e78fd1f9';
var cmsFqdn = 'cms.mechao.tv';
var flyerUrl = 'https://' + cmsFqdn + '/' + client + '/flyer_redirect?s=' + storeExtId + '&' + 'eid=' + code;
if ( linkurl ) {
window.open(linkurl, '_blank');
} else {
window.open(flyerUrl, '_blank');
}
return false;
});
//サムネイル画像 縦横サイズ設定
function calcThumbParam( img, directive, areasize )
{
var matches = /\{thumb-(all|r|l)\}/.exec( directive );
var expose = 'all';
if ( matches ) {
expose = matches[1];
}
var clip = { w: (expose=='all' ? img.width : img.width/2), h: img.height };
var ratio = (Math.floor(clip.h / clip.w)==0 ? areasize / clip.w : areasize / clip.h);
var ret = {
imgWidth: img.width * (expose=='all' ? 1 : 0.5),
imgHeight: img.height,
marginLeft: (expose=='r' ? img.width*(-0.5) : 0)
};
return ret;
}
if (Flyers.length != 0) {
//ULタグを追加する
jQuery('#'+ParentId).append('');
//公開中のチラシ数分 繰り返す
jQuery.each(Flyers, function(){
var flyer = this;
var thumb = jQuery('');
var divId = 'Flyer' + flyer.id;
// セールス期間 or 表示期間
if (flyer.sale != "") {
var flyersale = flyer.sale;
} else {
var flyersale = flyer.fromto;
}
// NEWマーク
if (flyer.from == flyer.now) {
var newmark = '';
} else {
var newmark = "";
}
//チラシブロックを表示する
jQuery('#'+ParentId+" ul.shopflyer-list").append(
jQuery('')
);
//チラシ情報を表示する
thumb.on('load', function(){
var img = thumb.get(0);
var imgView = jQuery('');
var thumbParam = calcThumbParam( img, flyer.expose, imgView.innerWidth() );
jQuery('#'+divId).append( jQuery(imgView)
.append( jQuery(img).css('margin-left',thumbParam.marginLeft) )
//.css( { width: thumbParam.imgWidth, height: thumbParam.imgHeight } )
);
jQuery('#'+divId).append( jQuery('')
.append( jQuery('').append(flyer.title) )
.append( jQuery('')
.append( jQuery(newmark) ).append( flyersale )
)
.append( jQuery('') )
);
})
.attr('src', flyer.thumburl);
});
} else {
jQuery('#'+ParentId).append( jQuery('現在、配信しているチラシはございません。
') );
}
});