From e2afeffe2f447f6d3a6b7e1d4d8d44e0db768ad7 Mon Sep 17 00:00:00 2001 From: ziajka Date: Wed, 3 Apr 2019 16:30:21 +0200 Subject: [PATCH 1/3] Hacking including plain javascript into Angular, Ref: #361 --- src/app/app.module.ts | 4 +- .../adbutler/adbutler.component.html | 14 +++++ .../adbutler/adbutler.component.scss | 0 .../adbutler/adbutler.component.spec.ts | 25 ++++++++ .../components/adbutler/adbutler.component.ts | 61 +++++++++++++++++++ .../components/servers/servers.component.html | 2 + 6 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/app/components/adbutler/adbutler.component.html create mode 100644 src/app/components/adbutler/adbutler.component.scss create mode 100644 src/app/components/adbutler/adbutler.component.spec.ts create mode 100644 src/app/components/adbutler/adbutler.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index eab5be9e..ed86a430 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -177,6 +177,7 @@ import { StartCaptureDialogComponent } from './components/project-map/packet-cap import { SuspendLinkActionComponent } from './components/project-map/context-menu/actions/suspend-link/suspend-link-action.component'; import { ResumeLinkActionComponent } from './components/project-map/context-menu/actions/resume-link-action/resume-link-action.component'; import { StopCaptureActionComponent } from './components/project-map/context-menu/actions/stop-capture/stop-capture-action.component'; +import { AdbutlerComponent } from './components/adbutler/adbutler.component'; if (environment.production) { Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', { @@ -291,7 +292,8 @@ if (environment.production) { NameFilter, ListOfSnapshotsComponent, CustomAdaptersComponent, - NodesMenuComponent + NodesMenuComponent, + AdbutlerComponent ], imports: [ BrowserModule, diff --git a/src/app/components/adbutler/adbutler.component.html b/src/app/components/adbutler/adbutler.component.html new file mode 100644 index 00000000..54cd4178 --- /dev/null +++ b/src/app/components/adbutler/adbutler.component.html @@ -0,0 +1,14 @@ + + +
+
+ + + + + + +
+ + + \ No newline at end of file diff --git a/src/app/components/adbutler/adbutler.component.scss b/src/app/components/adbutler/adbutler.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/app/components/adbutler/adbutler.component.spec.ts b/src/app/components/adbutler/adbutler.component.spec.ts new file mode 100644 index 00000000..05212323 --- /dev/null +++ b/src/app/components/adbutler/adbutler.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AdbutlerComponent } from './adbutler.component'; + +describe('AdbutlerComponent', () => { + let component: AdbutlerComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AdbutlerComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AdbutlerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/adbutler/adbutler.component.ts b/src/app/components/adbutler/adbutler.component.ts new file mode 100644 index 00000000..69c3020e --- /dev/null +++ b/src/app/components/adbutler/adbutler.component.ts @@ -0,0 +1,61 @@ +import { Component, OnInit, ElementRef, ViewChild, AfterViewInit } from '@angular/core'; + +@Component({ + selector: 'app-adbutler', + templateUrl: './adbutler.component.html', + styleUrls: ['./adbutler.component.scss'] +}) +export class AdbutlerComponent implements OnInit, AfterViewInit { + id: number; + setId: number; + rnd: number; + abkw: string; + sparkCounter: number; + divId: string; + + @ViewChild('code') code: ElementRef; + + constructor() { } + + ngOnInit() { + var loadedTextAds355353 = (window as any).loadedTextAds355353; + if(loadedTextAds355353 == null) { + (window as any).loadedTextAds355353 = new Array(); + } + + (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); + } + +} diff --git a/src/app/components/servers/servers.component.html b/src/app/components/servers/servers.component.html index 124e91f1..7e44251c 100644 --- a/src/app/components/servers/servers.component.html +++ b/src/app/components/servers/servers.component.html @@ -55,5 +55,7 @@
+ + From 7b1371dff91c79a30ea42b185bfcc2a6b167b6f9 Mon Sep 17 00:00:00 2001 From: ziajka Date: Thu, 4 Apr 2019 09:13:06 +0200 Subject: [PATCH 2/3] Styles and fixes switching between pages, Ref: #361 --- src/app/components/adbutler/adbutler.component.html | 3 ++- src/app/components/adbutler/adbutler.component.scss | 7 +++++++ src/app/components/adbutler/adbutler.component.ts | 13 ++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/app/components/adbutler/adbutler.component.html b/src/app/components/adbutler/adbutler.component.html index 54cd4178..4e7940a3 100644 --- a/src/app/components/adbutler/adbutler.component.html +++ b/src/app/components/adbutler/adbutler.component.html @@ -1,4 +1,5 @@ - + +
diff --git a/src/app/components/adbutler/adbutler.component.scss b/src/app/components/adbutler/adbutler.component.scss index e69de29b..cdb7ea77 100644 --- a/src/app/components/adbutler/adbutler.component.scss +++ b/src/app/components/adbutler/adbutler.component.scss @@ -0,0 +1,7 @@ +.butler a { + color: #0097a7; +} + +.butler { + font-size: 14px; +} \ No newline at end of file diff --git a/src/app/components/adbutler/adbutler.component.ts b/src/app/components/adbutler/adbutler.component.ts index 69c3020e..54c5ae1d 100644 --- a/src/app/components/adbutler/adbutler.component.ts +++ b/src/app/components/adbutler/adbutler.component.ts @@ -1,11 +1,12 @@ -import { Component, OnInit, ElementRef, ViewChild, AfterViewInit } from '@angular/core'; +import { Component, OnInit, ElementRef, ViewChild, AfterViewInit, ViewEncapsulation, OnDestroy } from '@angular/core'; @Component({ selector: 'app-adbutler', templateUrl: './adbutler.component.html', - styleUrls: ['./adbutler.component.scss'] + styleUrls: ['./adbutler.component.scss'], + encapsulation: ViewEncapsulation.None }) -export class AdbutlerComponent implements OnInit, AfterViewInit { +export class AdbutlerComponent implements OnInit, AfterViewInit, OnDestroy { id: number; setId: number; rnd: number; @@ -58,4 +59,10 @@ export class AdbutlerComponent implements OnInit, AfterViewInit { this.code.nativeElement.appendChild(scriptElement); } + ngOnDestroy() { + // start from 0 when switching pages + (window as any).sparkCounter355353 = 0; + delete (window as any).loadedTextAds355353[this.sparkCounter]; + } + } From 88336ed9f7a15a4ab2b9a347df89c80a0e8c9a6e Mon Sep 17 00:00:00 2001 From: ziajka Date: Thu, 4 Apr 2019 10:00:36 +0200 Subject: [PATCH 3/3] Display placeholder in installedsoftware, Ref: #361 --- .../installed-software.component.html | 12 ++++++++++-- .../installed-software.component.ts | 6 +++++- src/app/components/servers/servers.component.html | 2 -- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/components/installed-software/installed-software.component.html b/src/app/components/installed-software/installed-software.component.html index 32d0e83e..28292ad4 100644 --- a/src/app/components/installed-software/installed-software.component.html +++ b/src/app/components/installed-software/installed-software.component.html @@ -8,13 +8,21 @@ Name - {{ row.name }} + + + {{ row.name }} + + + + + + - + diff --git a/src/app/components/installed-software/installed-software.component.ts b/src/app/components/installed-software/installed-software.component.ts index 2d8e098b..8ebdb4b0 100644 --- a/src/app/components/installed-software/installed-software.component.ts +++ b/src/app/components/installed-software/installed-software.component.ts @@ -47,7 +47,11 @@ export class InstalledSoftwareDataSource extends DataSource { disconnect() {} refresh() { - this.installed.next(this.installedSoftwareService.list()); + let installedSoftware = this.installedSoftwareService.list(); + installedSoftware.push({ + type: 'adbutler' + }); + this.installed.next(installedSoftware); } } diff --git a/src/app/components/servers/servers.component.html b/src/app/components/servers/servers.component.html index 7e44251c..124e91f1 100644 --- a/src/app/components/servers/servers.component.html +++ b/src/app/components/servers/servers.component.html @@ -55,7 +55,5 @@
- -