(function($){ var geo = false; $.fn.WPStealthAds = function(fn, params) { if(fn == 'config'){ return this.each(function() { return this.config(params); }); }else if(fn == 'ads'){ return this.each(function() { return this.ads(params); }); }else if(fn == 'update'){ return this.each(function() { return this.update(); }); } return this.each(function() { function escape_html(html){ var text = document.createTextNode(html); var div = document.createElement('div'); div.appendChild(text); return div.innerHTML; } function render_single(ad) { var template = "\r\n
<\/div>\r\n
%text%<\/div>\r\n<\/a>"; var country = '%country%'; var city = '%city%'; var region = '%region%'; if(geo){ try{ country = geo.country_name; city = geo.city; region = geo.region_name; if(region == ''){ region = country; } if(city == ''){ city = region; } }catch(e){} } return template .replace(/%text%/g, escape_html(ad.text)) .replace(/%image%/g, ad.image) .replace(/%url%/g, ad.url) .replace(/%display_url%/g, ad.display_url) .replace(/%id%/g, ad.id) .replace(/%country%/g, country) .replace(/%city%/g, city) .replace(/%region%/g, region); } function render_html(){ var template = " \r\n