Skip to content

Commit

Permalink
Updated zones IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Elias Ruiz Monserrat committed Feb 19, 2023
1 parent 720e65d commit 42fc0a1
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 36 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<script async>window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>

<!-- Instant.page -->
<script async src="//instant.page/5.1.0" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>
<!-- <script async src="//instant.page/5.1.0" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script> -->

<script src="//m.servedby-buysellads.com/monetization.custom.js" type="text/javascript"></script>
<!-- <script src="//m.servedby-buysellads.com/monetization.custom.js" type="text/javascript"></script> -->

<script async type="module" src="./src/main.js"></script>
<script async>window.global = window;</script>
Expand Down
3 changes: 2 additions & 1 deletion src/components/H3Description.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
</p>
<!-- :adId="'iconbar-js-h3'" -->
<NativeAd
:adId="'resources-ad'"
:template="1"
:key="$route.fullPath + 'ad' + '_resources'"
zoneKey="CWYDCK3J"
adId="CWYDCK3J"
/>
</div>

Expand Down
5 changes: 3 additions & 2 deletions src/components/Hero.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
>
<NativeAd
:template="1"
:adId="'iconbar-js-hero'"
:key="$route.fullPath + 'ad' + '_hero'"
adId="CWYDCK3J"
zoneKey="CWYDCK3J"
key="CWYDCK3J"
/>
</div>

Expand Down
20 changes: 14 additions & 6 deletions src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@
<!-- Loading error -->
<div v-if="false" class="waiting-wrapper">

<NativeAd :adPosition="'Loading error'" :adId="'iconbar-js-card-grid'" :key="$route.fullPath + 'ad'"/>
<NativeAdIconGrid
:adPosition="'Loading error'"
:template="2"
adId="CWYD65Q7"
zoneKey="CWYD65Q7"
key="CWYD65Q7"
/>

<h3 class="coral-Heading--M">
The site is temporarily down for maintenance purposes.
Expand Down Expand Up @@ -375,10 +381,12 @@
class="p-b-32 icon-list-area"
>

<NativeAd
:adId="'homePage'"
<NativeAdIconGrid
:template="2"
class="grid-ad"
adId="CWYD65Q7"
zoneKey="CWYD65Q7"
key="CWYD65Q7"
/>

<!-- v-for="icon in search" -->
Expand Down Expand Up @@ -415,7 +423,7 @@ import { defineAsyncComponent } from 'vue';
import { mapActions, mapGetters } from 'vuex';
import Hero from './Hero.vue';
import NativeAd from './NativeAd.vue';
import NativeAdIconGrid from './NativeAdIconGrid.vue';
import StickyBanner from './StickyBanner.vue';
import CarbonAd from './CarbonAd.vue';
import UserIconCardLoading from './UserIconCardLoading.vue';
Expand Down Expand Up @@ -490,7 +498,7 @@ export default {
"IconDialog": defineAsyncComponent(() => import('@/components/IconDialog.vue')),
UserIconCard,
Hero,
NativeAd,
NativeAdIconGrid,
StickyBanner,
CarbonAd,
UserIconCardLoading,
Expand Down Expand Up @@ -646,7 +654,7 @@ export default {
this.handleParseError(error)
}
this.getAd()
// this.getAd()
this.cmdK()
this.searchForPathQuery()
this.setEventListenersOnStart()
Expand Down
51 changes: 39 additions & 12 deletions src/components/NativeAd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default {
// type: Boolean,
// default: false,
// },
zoneKey: '',
fullWidth: '',
adId: '',
template: {
Expand All @@ -39,6 +40,7 @@ export default {
data(){
return{
isAd: false,
count: 0
}
},
Expand Down Expand Up @@ -66,20 +68,45 @@ export default {
`
let template = this.template == 1 ? templateCompact : templateCard
let zoneKey = this.zoneKey;
let count = this.count
function initAds() {
if (typeof _bsa !== 'undefined' && _bsa) {
_bsa.init('custom', zoneKey, 'placement:macosiconscom', {
target: '#' + adId,
template: template,
})
_bsa.callback = BSANativeCallbacks // This is the callback function
}
};
function BSANativeCallbacks(a) {
// console.log(a.ads);
if (a.ads.length == 0) {
count++
console.log(adId + ' ' + count);
initAds();
// Do something here to display fallback when the ads array is empty
}
}
// initAds()
// return
function getAd(el){
try {
if (typeof _bsa !== 'undefined' && !parent.isAd ) {
document.getElementById(adId).innerHTML = ''
// el.innerHTML = ''
_bsa.init('custom', 'CESDC2QN', 'placement:macosiconscom',
{
_bsa.init('custom', zoneKey, 'placement:macosiconscom',{
target: '#'+adId,
template: template
}
);
});
// _bsa.callback = BSANativeCallback
}
} catch (error) {
console.log(error);
}
}
Expand Down Expand Up @@ -114,15 +141,15 @@ export default {
}, 800);
}
let el = document.getElementById(adId+"customAd")
let el = document.getElementById(adId)
window.BSANativeCallback = (a) => {
const total = a.ads.length;
if (!total) {
getAd(el)
parent.isAd = true
}
}
// function BSANativeCallback(a){
// console.log(a.ads);
// if (a.ads.length == 0) {
// getAd(el)
// parent.isAd = true
// }
// }
if (!parent.isAd) {
try {
Expand Down
201 changes: 201 additions & 0 deletions src/components/NativeAdIconGrid.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
<template>
<div :class="{fullWidth: fullWidth, 'mobile-hidden': true}">
<p v-if="sponsored" class="coral-Detail coral-Detail--S coral-Detail--light opacity-50">
Sponsored
</p>
<div
@click="adClick"
:class="{
'coral-card': template == 2,
'native-ad-wrapper': template == 1,
'card-grid-nativeAd': template != 1
}"
:id="adId">
</div>
</div>
</template>

<script>
export default {
name:"NativeAd",
props:{
sponsored: '',
// sponsored: {
// type: Boolean,
// default: false,
// },
zoneKey: '',
fullWidth: '',
adId: '',
template: {
type: Number,
default: 1
},
},
components:{},
data(){
return{
isAd: false,
count: 0
}
},
mounted: function(){
let parent = this
var adId = parent.adId
const templateCompact = `
<a href="##statlink##" target="_blank" rel="noopener sponsored" id="`+adId+`customAd" class="bsa-link coral-card">
<div class="bsa-icon" style="background-image: url(##image##); background-color: ##backgroundColor##;"></div>
<div class="bsa-desc">##company## - ##tagline##</div>
</a>
`
const templateCard = `
<a href="##statlink##" target="_blank" rel="noopener sponsored" id="`+adId+`customAd"" class="bsa-link">
<div class="bsa-img-wrapper" style="background-color: ##backgroundColor##;">
<div class="bsa-icon" style="background-image: url(##logo##);"></div>
</div>
<div class="text-ad-wrapper">
<img style="background: ##backgroundColor##" src="##image##">
<div class="bsa-desc">##description##</div>
</div>
</a>
`
let template = this.template == 1 ? templateCompact : templateCard
let zoneKey = this.zoneKey;
let count = this.count
function initAds() {
if (typeof _bsa !== 'undefined' && _bsa) {
_bsa.init('custom', zoneKey, 'placement:macosiconscom', {
target: '#' + adId,
template: template,
})
// check if _bsa.callback is already defined;
// if not, define it as a function
console.log(_bsa.callback);
_bsa.callback = BSANativeCallbacks // This is the callback function
}
};
function BSANativeCallbacks(a) {
// console.log(a.ads);
if (a.ads.length == 0) {
count++
console.log(adId + ' ' + count);
initAds();
// Do something here to display fallback when the ads array is empty
}
}
// initAds()
// return
function getAd(el){
try {
if (typeof _bsa !== 'undefined' && !parent.isAd ) {
document.getElementById(adId).innerHTML = ''
// el.innerHTML = ''
_bsa.init('custom', zoneKey, 'placement:macosiconscom',{
target: '#'+adId,
template: template
});
// _bsa.callback = BSANativeCallback // This is the callback function
}
} catch (error) {
console.log(error);
}
}
getAd()
var attempts = 0
function adExist(){
var adExists
setTimeout(() => {
try {
adExists = document.getElementById(adId).children.length
} catch (error) {
}
if (adExists > 0 || attempts >= 25) return;
// if (attempts >= 25) return;
if (adExists == 0) {
try {
attempts++
adExist()
getAd()
} catch (error) {
attempts++
adExist()
getAd()
parent.isAd = false
}
} else return
}, 800);
}
let el = document.getElementById(adId)
// function BSANativeCallback(a){
// console.log(a.ads);
// if (a.ads.length == 0) {
// getAd(el)
// parent.isAd = true
// }
// }
if (!parent.isAd) {
try {
adExist()
} catch (error) {
}
}
setTimeout(() =>{
try {
let nodeList = document.querySelector("#"+adId).children
for(let el in nodeList){
let newNodeList = document.querySelector("#"+adId).children
if(newNodeList.length > 1){
console.log(newNodeList.length);
el.parentNode.removeChild(el);
} else{
// console.log(newNodeList.length);
return
}
};
} catch (error) {
}
}, 100)
},
methods:{
adClick(){
window.plausible("adClick", {props: {
path: this.$route.name
}})
}
}
}
</script>

<style>
.fullWidth .bsa-link{
width: 100%
}
</style>
Loading

0 comments on commit 42fc0a1

Please sign in to comment.