Implementation of custom html ad

This commit is contained in:
Piotr Pekala 2019-07-09 03:48:02 -07:00
parent 230aaf31fd
commit 2be02a8bd0
6 changed files with 63 additions and 97 deletions

View File

@ -1,12 +1 @@
<div class="ad" #ad></div>
<table class="butler" height=80 [ngClass]="(theme=='dark')?'butlerdark':'butlerlight'" cellSpacing=0 cellPadding=3>
<tr><td height=80 [ngClass]="(theme=='dark')?'rowdark':'rowlight'" #code>
<div id="{{ this.divId }}"></div>
<!-- Begin Ad Code -->
<!-- End Ad Code -->
</td></tr>
</table>

View File

@ -1,27 +1,24 @@
.butler a { .ad {
background-color: #263238;
width: 400px;
padding-top: 10px;
padding-bottom: 10px;
font-size: 12px;
}
button {
background-color: #0097a7;
margin-top: 10px;
border: none;
outline: none;
padding: 5px;
color: white;
font-weight: bold;
padding-right: 15px;
padding-left: 15px;
border-radius: 5px;
}
a {
color: #0097a7; color: #0097a7;
} }
.butler {
font-size: 14px;
}
.butlerdark {
width: 400px;
border: 0px solid #C0C0C0;
background-color: #263238;
}
.butlerlight {
width: 400px;
border: 0px solid #C0C0C0;
background-color: white;
}
.rowdark {
background-color: #263238;
}
.rowlight {
background-color: #263238;
}

View File

@ -1,4 +1,6 @@
import { Component, OnInit, ElementRef, ViewChild, AfterViewInit, ViewEncapsulation, OnDestroy, Input } from '@angular/core'; import { Component, OnInit, ElementRef, ViewChild, ViewEncapsulation, Input } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { AdButlerResponse } from '../../models/adbutler';
@Component({ @Component({
selector: 'app-adbutler', selector: 'app-adbutler',
@ -6,64 +8,20 @@ import { Component, OnInit, ElementRef, ViewChild, AfterViewInit, ViewEncapsulat
styleUrls: ['./adbutler.component.scss'], styleUrls: ['./adbutler.component.scss'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class AdbutlerComponent implements OnInit, AfterViewInit, OnDestroy { export class AdbutlerComponent implements OnInit {
id: number; @ViewChild('ad') ad: ElementRef;
setId: number;
rnd: number;
abkw: string;
sparkCounter: number;
divId: string;
@ViewChild('code') code: ElementRef;
@Input() theme: string; @Input() theme: string;
constructor() { } htmlCode: string;
constructor(
private httpClient: HttpClient
) {}
ngOnInit() { ngOnInit() {
var loadedTextAds355353 = (window as any).loadedTextAds355353; this.httpClient.get('https://servedbyadbutler.com/adserve/;ID=165803;size=0x0;setID=371476;type=json;').subscribe((response: AdButlerResponse) => {
if(loadedTextAds355353 == null) { this.htmlCode = response.placements.placement_1.body;
(window as any).loadedTextAds355353 = new Array(); this.ad.nativeElement.insertAdjacentHTML('beforeend', this.htmlCode);
} });
(window as any).id355353 = 165803;
(window as any).setID355353 = 355353;
(window as any).rnd = (window as any).rnd || Math.floor(Math.random()*10e6);
(window as any).abkw = (window as any).abkw ||'';
var sparkCounter355353 = (window as any).sparkCounter355353;
if(sparkCounter355353 == null) {
sparkCounter355353 = 1;
}
else {
sparkCounter355353 = sparkCounter355353 + 1
}
(window as any).sparkCounter355353 = sparkCounter355353;
(window as any).loadedTextAds355353[sparkCounter355353] = false;
this.id = (window as any).id355353;
this.divId = "abta355353" + sparkCounter355353;
this.setId = (window as any).setID355353;
this.abkw = (window as any).abkw;
this.rnd = (window as any).rnd;
this.sparkCounter = (window as any).sparkCounter355353;
} }
ngAfterViewInit() {
const scriptUrl = "https://servedbyadbutler.com/adserve/;ID=" + this.id + ";setID=" + this.setId + ";type=textad;kw=" + this.abkw + ";pid=" + this.rnd + ";layoutID=" + this.sparkCounter;
const scriptElement = document.createElement('script');
scriptElement.src = scriptUrl;
scriptElement.type = 'text/javascript';
scriptElement.async = true;
scriptElement.charset = 'utf-8';
this.code.nativeElement.appendChild(scriptElement);
}
ngOnDestroy() {
// start from 0 when switching pages
(window as any).sparkCounter355353 = 0;
delete (window as any).loadedTextAds355353[this.sparkCounter];
}
} }

View File

@ -1,10 +1,9 @@
<div class="notification-box" *ngIf="isVisible"> <div class="notification-box" *ngIf="isVisible">
<mat-progress-bar mode="determinate" [value]="progress"></mat-progress-bar> <mat-progress-bar mode="determinate" [value]="progress"></mat-progress-bar>
<div style="display: flex; height: 82px;"> <div style="display: flex; height: 102px;">
<div class="content"> <div class="content">
<app-adbutler theme="dark"></app-adbutler> <app-adbutler theme="dark"></app-adbutler>
<mat-icon (click)="closeNotification()" class="close-button">close</mat-icon> <mat-icon (click)="closeNotification()" class="close-button">close</mat-icon>
<!-- <button class="check-button" mat-button>CHECK IT OUT</button> -->
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@
bottom: 20px; bottom: 20px;
right: 20px; right: 20px;
width: 412px; width: 412px;
height: 88px; height: 108px;
} }
.content { .content {
@ -16,7 +16,7 @@
.close-button { .close-button {
position: fixed; position: fixed;
bottom: 70px; bottom: 90px;
right: 30px; right: 30px;
cursor: pointer; cursor: pointer;
} }

View File

@ -0,0 +1,23 @@
export interface Placement1 {
banner_id: string;
width: string;
height: string;
alt_text: string;
accompanied_html: string;
target: string;
tracking_pixel: string;
body: string;
redirect_url: string;
refresh_url: string;
refresh_time: string;
image_url: string;
}
export interface Placements {
placement_1: Placement1;
}
export interface AdButlerResponse {
status: string;
placements: Placements;
}