Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ShowGoogleAds() {
- var ads = $('.adContainer');
- $('.adContainer > ins').remove();
- setTimeout(function () {
- ads.each(function () {
- GetGoogleAd($(this), $(this).data("istext"), $(this).data("isvertical"));
- });
- }, 0);
- }
- function GetGoogleAd(ad, istext, isvertical) {
- if (ad == undefined) {
- console.log("The element to place the Google ad inside is NULL!");
- return;
- }
- istext = istext == undefined ? false : istext;
- isvertical = isvertical == undefined ? false : isvertical;
- var google_ad_client = "ca-pub-1231231231231231"; // Use your google ad ID here
- var google_ad_slot = "1231231231"; // Use your own ad slot ID here
- var adWidth = ad.width();
- var adHeight = ad.height();
- var google_ad_size;
- if (adWidth >= 970) {
- google_ad_size = ["970", "90"]; /* Large Leaderboard */
- }
- else if (adWidth >= 728) {
- if (istext)
- google_ad_size = ["728", "15"]; /* Text - Horizontal Large */
- else
- google_ad_size = ["728", "90"]; /* Leaderboard */
- }
- else if (adWidth >= 468) {
- if (istext)
- google_ad_size = ["468", "15"]; /* Text - Horizontal Medium */
- else {
- if (isvertical)
- google_ad_size = ["336", "280"]; /* Large Rectangle */
- else
- google_ad_size = ["468", "90"]; /* Banner */
- }
- }
- else if (adWidth >= 320) {
- if (isvertical)
- google_ad_size = ["320", "180"]; /* Large Mobile Banner */
- else
- google_ad_size = ["320", "50"]; /* Mobile Banner */
- }
- else if (adWidth >= 300) {
- if (isvertical)
- google_ad_size = ["300", "600"]; /* Large Skyscraper */
- else
- google_ad_size = ["300", "200"]; /* Medium Rectangle */
- }
- else if (adWidth >= 250) {
- if (isvertical)
- google_ad_size = ["250", "250"]; /* Square */
- else
- google_ad_size = ["234", "60"]; /* Half Banner */
- }
- else if (adWidth >= 200) {
- if (isvertical)
- google_ad_size = ["200", "200"]; /* */
- else
- google_ad_size = ["200", "90"]; /* RTL: Vertical X-Large */
- }
- else if (adWidth >= 180) {
- if (isvertical)
- google_ad_size = ["180", "150"]; /* Small Rectangle */
- else
- google_ad_size = ["180", "90"]; /* Vertical Large */
- }
- else if (adWidth >= 160) {
- if (isvertical)
- google_ad_size = ["160", "600"]; /* Wide Skyscraper */
- else
- google_ad_size = ["160", "90"]; /* Vertical Medium */
- }
- else if (adWidth >= 125) {
- google_ad_size = ["125", "125"]; /* Button */
- }
- else if (adWidth >= 120) {
- if (istext)
- google_ad_size = ["120", "90"]; /* Vertical Small */
- else {
- if (isvertical)
- google_ad_size = ["120", "600"]; /* Skyscraper */
- else
- google_ad_size = ["120", "240"]; /* Vertical Banner */
- }
- }
- else
- return;
- var adInsert = '<ins class="adsbygoogle" style="display:inline-block;width:'
- + google_ad_size[0] + 'px;height:'
- + google_ad_size[1] + 'px" data-ad-client="'
- + google_ad_client + '" data-ad-slot="'
- + google_ad_slot + '"></ins>';
- var scriptInsert = '<script type="text/javascript">(adsbygoogle = window.adsbygoogle || []).push({});</script>';
- ad.append(adInsert);
- ad.append(scriptInsert);
- }
Add Comment
Please, Sign In to add comment