I have a super long jquery snippet that I feel could be simplified with the right logic. I'm afraid to touch it since I finally got it to work.
the "else $target = #none" is literally a "show nothing" statement. I wasn't sure how to express that in a better way.
Thanks so much! -zeem
PS. links are to medical marijuana sites, so NSFW links!
$(function () {
var $target = $('#CO1');
if (mmjsRegion == 'CO') {
$target = $('#CO1');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CO1.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
$(function () {
var $target = $('#CO2');
if (mmjsRegion == 'CO') {
$target = $('#CO2');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CO2.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
$(function () {
var $target = $('#CO3');
if (mmjsRegion == 'CO') {
$target = $('#CO3');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CO3.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
$(function () {
var $target = $('#CA1');
if (mmjsRegion == 'CA') {
$target = $('#CA1');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CA1.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
$(function () {
var $target = $('#CA2');
if (mmjsRegion == 'CA') {
$target = $('#CA2');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CA2.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
$(function () {
var $target = $('#CA3');
if (mmjsRegion == 'CA') {
$target = $('#CA3');
} else {
$target = $('#none');
}
$target.imBannerRotater({
return_type: 'json',
data_map: {
image_name: 'name',
url_name: 'url'
},
image_url: 'http://www.kindreviews.com/wp-content/plugins/geoads/CA3.php',
base_path: 'http://www.kindreviews.com/wp-content/plugins/geoads/images/',
});
});
This should do it: