jQuery(function(){ var ParentId = 'ChirashiplusDiv'; var ThumbSize = jQuery('#'+ParentId).innerWidth() - 4; var Flyers = [ { id: 26326359, code: '1a4564457fd23f70796742ca30f92130', expose: '', title: 'We are Shonanian', client: 'saikaya', from: '2024-04-06 14:00:00', to: '2024-04-30 18:00:00', cms: '', url: '', thumb_uri: '//cips.chirashiplus.tv/1607/26326359/0/framein-288-288.jpg' } ]; $(document).on('click', '#' + ParentId + ' a' ,function(){ var linkurl = jQuery(this).parents('.Flyer').attr('url'); var viewername = jQuery(this).parents('.Flyer').attr('cms'); var fid = jQuery(this).parents('.Flyer').attr('fid'); var fcode = jQuery(this).parents('.Flyer').attr('code'); var client = jQuery(this).parents('.Flyer').attr('client'); var clientId = 1607; var storeId = 19997; var storeExtId = 'f74d5fec20debaf038c1318d041ed8e9'; var cmsFqdn = 'cms.mechao.tv'; var base = '//cms.mechao.tv/saikaya/'; var flyerUrl = 'https://' + cmsFqdn + '/' + client + '/flyer_redirect?s=' + storeExtId + '&' + 'eid=' + fcode; 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); img.width *= ratio; img.height *= ratio; var ret = { imgWidth: img.width * (expose=='all' ? 1 : 0.5), imgHeight: img.height, marginLeft: (expose=='r' ? img.width*(-0.5) : 0) }; return ret; } jQuery.each(Flyers,function(){ var flyer = this; var thumb = jQuery(''); var divId = 'Flyer' + flyer.id; jQuery('#'+ParentId).append( jQuery('
') ); thumb.load(function(){ var img = thumb.get(0); var div = jQuery('#'+divId); var imgView = jQuery('
'); div.append( imgView ) .append( jQuery('').text( flyer.title ) ); var thumbParam = calcThumbParam( img, flyer.expose, imgView.innerWidth() ); imgView.append( jQuery('').append( jQuery(img).css('margin-left',thumbParam.marginLeft) ) ) .css( { width: thumbParam.imgWidth, height: thumbParam.imgHeight } ); }) .attr( 'src', flyer.thumb_uri ); }); });