Skip to content

Instantly share code, notes, and snippets.

@gautamk
Created April 13, 2012 10:30
Show Gist options
  • Save gautamk/2375664 to your computer and use it in GitHub Desktop.
Save gautamk/2375664 to your computer and use it in GitHub Desktop.
Flipkart Banner Aside designed for Octopress
<!--
Flipkart Banner Aside designed for Octopress
@file source/_include/custom/asides/flipkart_banners.html
@author Gautam
USAGE Scroll down
-->
<section id="flipkart-banner-container">
<h1>Recommendations</h1>
<p>
<style type="text/css">
#flipkart-banner{
width:230px;
height:165px;
overflow: hidden;
border:none;
}
</style>
<iframe id="flipkart-banner" src="" ></iframe>
<script type="text/javascript">
(function() {
/**
* Step 1
USAGE Enter your affiliate id (tracking ID) that you can get
by signing up at http://www.flipkart.com/affiliate/
* Step 2
Add a list for Product IDs to the array
BANNER_IDS
*/
var SETTINGS={
"affid":"Your_Affiliate_ID", //Affiliate Id
"width":200,
"height":150,
"base_url":"http://www.flipkart.com/affiliateWidget/simpleBanner?",
// Leave empty for false / no
"send_to_checkout":"",
"price":"yes",
"border":"",
/**
* Type
* Image Only 1
* Text Only 2
* Image and Text 3
*/
"type":1,
"timeout":10 // Timeout in seconds to change banner
};
/**
Getting Banner/Product IDs
* Visit Flipkart and open any product,
* See the URL, For example
http://www.flipkart.com/life-pi-0143028480/p/itmczym2uhxhebty?pid=9780143028482
* The value after `pid=` is the product ID
In this example it is 9780143028482
* Add it to the array below , The items are comma separated
*/
var BANNERS_IDS=[
"9785111121464",// The Secret Of The Nagas & The Immortals Of Meluha (set of 2 books)
"9788184040838",// Understanding the Linux Kernel
"9789380069227",// I’ll Do It My Way: The Incredible Journey of Aamir Khan
"9780099578512",// Midnight's Children
"9781591399728",// Hiring Smart for Competitive Advantage
"9780143028482",// Life Of Pi
];
/**
DO NOT CHANGE ANYTHING BELOW HERE , UNLESS YOU KNOW WHAT YOU ARE DOING
**/
var $BANNER=$("iframe#flipkart-banner");
var generate_banner_url=function(id){
var url = SETTINGS["base_url"];
url+="buy=" + SETTINGS["send_to_checkout"];
url+="&affid=" + SETTINGS["affid"];
url+="&type=" + SETTINGS["type"];
url+="&price=" + SETTINGS["price"];
url+="&border=" + SETTINGS["border"];
url+="&width=" + SETTINGS["width"];
url+="&height=" + SETTINGS["height"];
url+="&id=" + id;
return url;
};
var generate_random_banner_url=function(){
var random_no , id ;
random_no = Math.floor(Math.random()*BANNERS_IDS.length);
id = BANNERS_IDS[random_no];
return generate_banner_url(id);
}
var set_banner=function(url){
return $BANNER.attr("src",url);
}
var set_random_banner=function(){
return set_banner(generate_random_banner_url());
}
$(document).ready(function(){
set_random_banner();
setInterval(set_random_banner,SETTINGS["timeout"]*1000);
});
}).call(this);
</script>
</p>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment