From 31048637dddcc0a22a3a510e49005162d119ecca Mon Sep 17 00:00:00 2001 From: Miodec Date: Sat, 30 Jan 2021 21:26:51 +0000 Subject: [PATCH] switched the ad provider --- src/js/userconfig.js | 239 +++++++++++++++++++++++++++++++------------ src/sass/style.scss | 25 +++++ static/index.html | 47 ++++++--- 3 files changed, 234 insertions(+), 77 deletions(-) diff --git a/src/js/userconfig.js b/src/js/userconfig.js index 9183d5378..b7e10eaa3 100644 --- a/src/js/userconfig.js +++ b/src/js/userconfig.js @@ -1551,72 +1551,181 @@ function applyConfig(configObj) { setStrictSpace(configObj.strictSpace, true); setMode(configObj.mode, true); - setEnableAds(configObj.enableAds, true); - if (config.enableAds != "off") { - Notifications.add( - "Ads are temporairly disabled due to moving to a different ad provider.", - 0, - 5 - ); - } + try { + setEnableAds(configObj.enableAds, true); + let addemo = false; + if ( + firebase.app().options.projectId === "monkey-type-dev-67af4" || + window.location.hostname === "localhost" + ) { + addemo = true; + } - // try { - // setEnableAds(configObj.enableAds, true); - // if (config.enableAds === "on") { - // $("#ad1").removeClass("hidden"); - // $("#ad1") - // .html(` - // - // `); - // const adsbygoogle = window.adsbygoogle || []; - // adsbygoogle.push({}); - // } else if (config.enableAds === "max") { - // $("#ad1").removeClass("hidden"); - // $("#ad2").removeClass("hidden"); - // $("#ad3").removeClass("hidden"); - // $("#ad1").html(` - // - // `); - // $("#ad2") - // .html(` - // - // `); - // $("#ad3") - // .html(` - // - // `); - // const adsbygoogle = window.adsbygoogle || []; - // adsbygoogle.push({}); - // adsbygoogle.push({}); - // adsbygoogle.push({}); - // } else { - // $("#ad1").remove(); - // $("#ad2").remove(); - // $("#ad3").remove(); - // } - // } catch (e) { - // console.log("error initialising ads " + e.message); - // $("#ad1").remove(); - // $("#ad2").remove(); - // $("#ad3").remove(); - // } + if (config.enableAds === "max" || config.enableAds === "on") { + if (config.enableAds === "max") { + window["nitroAds"].createAd("nitropay_ad_left", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + sizes: [["160", "600"]], + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + mediaQuery: "(min-width: 1330px)", + demo: addemo, + }); + $("#nitropay_ad_left").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_right", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + sizes: [["160", "600"]], + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + mediaQuery: "(min-width: 1330px)", + demo: addemo, + }); + $("#nitropay_ad_right").removeClass("hidden"); + } else { + $("#nitropay_ad_left").remove(); + $("#nitropay_ad_right").remove(); + } + + window["nitroAds"].createAd("nitropay_ad_footer", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + sizes: [["970", "90"]], + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + mediaQuery: "(min-width: 1025px)", + demo: addemo, + }); + $("#nitropay_ad_footer").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_footer2", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + sizes: [["728", "90"]], + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + mediaQuery: "(min-width: 730px) and (max-width: 1024px)", + demo: addemo, + }); + $("#nitropay_ad_footer2").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_footer3", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + sizes: [["320", "50"]], + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + mediaQuery: "(max-width: 730px)", + demo: addemo, + }); + $("#nitropay_ad_footer3").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_about", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + demo: addemo, + }); + $("#nitropay_ad_about").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_settings1", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + demo: addemo, + }); + $("#nitropay_ad_settings1").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_settings2", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + demo: addemo, + }); + $("#nitropay_ad_settings2").removeClass("hidden"); + + window["nitroAds"].createAd("nitropay_ad_account", { + refreshLimit: 10, + refreshTime: 30, + renderVisibleOnly: false, + refreshVisibleOnly: true, + report: { + enabled: true, + wording: "Report Ad", + position: "bottom-right", + }, + demo: addemo, + }); + $("#nitropay_ad_account").removeClass("hidden"); + } else { + $("#nitropay_ad_left").remove(); + $("#nitropay_ad_right").remove(); + $("#nitropay_ad_footer").remove(); + $("#nitropay_ad_footer2").remove(); + $("#nitropay_ad_footer3").remove(); + $("#nitropay_ad_settings1").remove(); + $("#nitropay_ad_settings2").remove(); + $("#nitropay_ad_account").remove(); + $("#nitropay_ad_about").remove(); + } + } catch (e) { + Notifications.add("Error initialising ads: " + e.message); + console.log("error initialising ads " + e.message); + $("#nitropay_ad_left").remove(); + $("#nitropay_ad_right").remove(); + $("#nitropay_ad_footer").remove(); + $("#nitropay_ad_footer2").remove(); + $("#nitropay_ad_footer3").remove(); + $("#nitropay_ad_settings1").remove(); + $("#nitropay_ad_settings2").remove(); + $("#nitropay_ad_account").remove(); + $("#nitropay_ad_about").remove(); + } } updateTestModesNotice(); } diff --git a/src/sass/style.scss b/src/sass/style.scss index 0085537a0..e566878f0 100644 --- a/src/sass/style.scss +++ b/src/sass/style.scss @@ -3570,3 +3570,28 @@ key { display: block; } } + +#nitropay_ad_left, +#nitropay_ad_right { + margin-top: 1rem; +} + +// .adcontainer{ +// position: relative; +// &>div{ +// top: 0px; +// left: 0px; +// position: absolute; +// } +// .bg{ +// background: var(--bg-color); +// color: var(--sub-color); +// display: grid; +// align-items: center; +// justify-content: center; +// height: 100%; +// width: 100%; +// font-size: .75rem; +// user-select: none; +// } +// } diff --git a/static/index.html b/static/index.html index 7e3463951..fbd228e65 100644 --- a/static/index.html +++ b/static/index.html @@ -40,6 +40,15 @@ + + @@ -832,7 +841,7 @@
- + + + +