From 440b9389b0ff3471f0db7a7688b65215657b519b Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Tue, 17 Dec 2019 23:52:48 +0530 Subject: [PATCH 01/10] edit-form-validation --- .../contact-form/contact-form.component.html | 131 ++++++++++++++---- .../contact-form/contact-form.component.ts | 7 +- 2 files changed, 110 insertions(+), 28 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.html b/src/app/contact/contact-form/contact-form.component.html index 755531840..755996abf 100644 --- a/src/app/contact/contact-form/contact-form.component.html +++ b/src/app/contact/contact-form/contact-form.component.html @@ -1,47 +1,128 @@
-
+
Contact Form -
+
- -
- Name is required -
+ +
+ + Name is required + +
- -
- Valid Email is required -
+ +
+ + Valid Email is required + +
- - - - -
- Valid Mobile Number is required. -
+ + - + + +
+ + Valid Mobile Number is required. + +
- -
- Describe more with Minimum 100 characters. -
+ +
+ + Describe more with Minimum 100 characters. + +
*All fields are mandatory - - Your Form has been submitted + + Your Form has been submitted
diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 6fd8d875f..56794a226 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -9,13 +9,14 @@ import { countrycodearray } from '../../shared/countrycode/countrycode'; styleUrls: ['./contact-form.component.scss'] }) export class ContactFormComponent implements OnInit { + public contactForm: FormGroup; public submitted = false; public selectedValue = null; public countries = countrycodearray; @Output() hideContactForm: EventEmitter = new EventEmitter(); - constructor( private http: HttpClient ) { } + constructor( private http: HttpClient ) { } ngOnInit() { this.contactForm = new FormGroup({ @@ -26,12 +27,12 @@ export class ContactFormComponent implements OnInit { message: new FormControl('', [Validators.required, Validators.minLength(100)]) }); } - public sendtosuperuser(user) { this.hideContactForm.emit(false); const headers = new HttpHeaders(); - const formObj = user.getRawValue(); + const formObj = this.contactForm.value; const data = JSON.stringify(formObj); + console.log(this.contactForm.value); headers.append('Content-Type', 'application/X-www-form-urlencoded'); From 3f96ad5b1308fc60954a126ba3ea34993ba38fd0 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 00:11:04 +0530 Subject: [PATCH 02/10] edit-form-validation1 --- src/app/contact/contact-form/contact-form.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 56794a226..f758c2587 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -9,7 +9,6 @@ import { countrycodearray } from '../../shared/countrycode/countrycode'; styleUrls: ['./contact-form.component.scss'] }) export class ContactFormComponent implements OnInit { - public contactForm: FormGroup; public submitted = false; public selectedValue = null; From efc5b04482028e7e9aeab7e19e45cfb7874a9343 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 00:13:53 +0530 Subject: [PATCH 03/10] edit-form-validation2 --- .../contact-form/contact-form.component.ts | 65 ++++++++++++------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index f758c2587..63af26a0d 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -1,12 +1,14 @@ -import { Component, OnInit, Output, EventEmitter } from '@angular/core'; -import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { countrycodearray } from '../../shared/countrycode/countrycode'; +import { Component, OnInit, Output, EventEmitter } from "@angular/core"; +import { + FormGroup, + FormControl, + FormBuilder, + Validators +} from "@angular/forms"; +import { HttpClient, HttpHeaders } from "@angular/common/http"; +import { countrycodearray } from "../../shared/countrycode/countrycode"; -@Component({ - selector: 'contact-form', - templateUrl: './contact-form.component.html', - styleUrls: ['./contact-form.component.scss'] +@Component({selector: "contact-form", templateUrl: "./contact-form.component.html",styleUrls: ["./contact-form.component.scss"] }) export class ContactFormComponent implements OnInit { public contactForm: FormGroup; @@ -15,16 +17,26 @@ export class ContactFormComponent implements OnInit { public countries = countrycodearray; @Output() hideContactForm: EventEmitter = new EventEmitter(); - constructor( private http: HttpClient ) { } + constructor(private http: HttpClient) {} ngOnInit() { this.contactForm = new FormGroup({ - name: new FormControl('', [Validators.required]), - email: new FormControl('', [Validators.required, Validators.email]), - countrycode: new FormControl('', [Validators.required]), - telephone: new FormControl('', [Validators.required, Validators.minLength(10), Validators.pattern('^[0-9]*$')]), - message: new FormControl('', [Validators.required, Validators.minLength(100)]) - }); + name: new FormControl("", [Validators.required]), + email: new FormControl("", [ + Validators.required, + Validators.email + ]), + countrycode: new FormControl("", [Validators.required]), + telephone: new FormControl("", [ + Validators.required, + Validators.minLength(10), + Validators.pattern("^[0-9]*$") + ]), + message: new FormControl("", [ + Validators.required, + Validators.minLength(100) + ]) + }); } public sendtosuperuser(user) { this.hideContactForm.emit(false); @@ -33,22 +45,25 @@ export class ContactFormComponent implements OnInit { const data = JSON.stringify(formObj); console.log(this.contactForm.value); + headers.append("Content-Type", "application/X-www-form-urlencoded"); + headers.append("Accept", "application/json"); - headers.append('Content-Type', 'application/X-www-form-urlencoded'); - headers.append('Accept', 'application/json'); - - this.http.post('https://formspree.io/office@fossasia.org', data, { headers: headers }) - .subscribe((response) => { - this.http.post('https://formspree.io/office@fossasia.org', data, { headers: headers }) - .subscribe((responsesent) => { - console.log('Sent successfully'); + this.http + .post("https://formspree.io/office@fossasia.org", data, { + headers: headers + }) + .subscribe(response => { + this.http + .post("https://formspree.io/office@fossasia.org", data, { + headers: headers + }) + .subscribe(responsesent => { + console.log("Sent successfully"); }); }); } - public showSubmit() { this.submitted = true; } - } From 9f42a74f84a97bf7b96f67db9f011f4be04013fc Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 00:21:38 +0530 Subject: [PATCH 04/10] edit-form-validation --- .../contact-form/contact-form.component.ts | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 63af26a0d..6d8943727 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -1,14 +1,16 @@ -import { Component, OnInit, Output, EventEmitter } from "@angular/core"; +import { Component, OnInit, Output, EventEmitter } from '@angular/core'; import { FormGroup, FormControl, FormBuilder, Validators -} from "@angular/forms"; -import { HttpClient, HttpHeaders } from "@angular/common/http"; -import { countrycodearray } from "../../shared/countrycode/countrycode"; - -@Component({selector: "contact-form", templateUrl: "./contact-form.component.html",styleUrls: ["./contact-form.component.scss"] +} from '@angular/forms'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { countrycodearray } from '../../shared/countrycode/countrycode'; +@Component({ + selector: 'contact-form', + templateUrl: './contact-form.component.html', + styleUrls: ['./contact-form.component.scss'] }) export class ContactFormComponent implements OnInit { public contactForm: FormGroup; @@ -21,18 +23,18 @@ export class ContactFormComponent implements OnInit { ngOnInit() { this.contactForm = new FormGroup({ - name: new FormControl("", [Validators.required]), - email: new FormControl("", [ + name: new FormControl('', [Validators.required]), + email: new FormControl('', [ Validators.required, Validators.email ]), - countrycode: new FormControl("", [Validators.required]), - telephone: new FormControl("", [ + countrycode: new FormControl('', [Validators.required]), + telephone: new FormControl('', [ Validators.required, Validators.minLength(10), - Validators.pattern("^[0-9]*$") + Validators.pattern('^[0-9]*$') ]), - message: new FormControl("", [ + message: new FormControl('', [ Validators.required, Validators.minLength(100) ]) @@ -45,20 +47,20 @@ export class ContactFormComponent implements OnInit { const data = JSON.stringify(formObj); console.log(this.contactForm.value); - headers.append("Content-Type", "application/X-www-form-urlencoded"); - headers.append("Accept", "application/json"); + headers.append('Content-Type', 'application/X-www-form-urlencoded'); + headers.append('Accept', 'application/json'); this.http - .post("https://formspree.io/office@fossasia.org", data, { + .post('https://formspree.io/office@fossasia.org', data, { headers: headers }) .subscribe(response => { this.http - .post("https://formspree.io/office@fossasia.org", data, { + .post('https://formspree.io/office@fossasia.org', data, { headers: headers }) .subscribe(responsesent => { - console.log("Sent successfully"); + console.log('Sent successfully'); }); }); } From aa8982793006f09aeee9818a9522313a286b267c Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 00:53:11 +0530 Subject: [PATCH 05/10] edit-form-validation --- .../contact-form/contact-form.component.html | 122 +++++++++--------- .../contact-form/contact-form.component.ts | 2 - 2 files changed, 61 insertions(+), 63 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.html b/src/app/contact/contact-form/contact-form.component.html index 755996abf..2946cc5af 100644 --- a/src/app/contact/contact-form/contact-form.component.html +++ b/src/app/contact/contact-form/contact-form.component.html @@ -1,126 +1,126 @@ -
-
- +
+
+
Contact Form -
- +
+ -
+
Name is required
-
- +
+ -
+
Valid Email is required
-
- - +
+ + - -
+
Valid Mobile Number is required.
-
- +
+ -
+
Describe more with Minimum 100 characters.
-
+
*All fields are mandatory - - Your Form has been submitted
diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 6d8943727..a6e1d46a2 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -18,9 +18,7 @@ export class ContactFormComponent implements OnInit { public selectedValue = null; public countries = countrycodearray; @Output() hideContactForm: EventEmitter = new EventEmitter(); - constructor(private http: HttpClient) {} - ngOnInit() { this.contactForm = new FormGroup({ name: new FormControl('', [Validators.required]), From d7387ba039a2f37296a58d860776795fae8e8511 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 00:58:35 +0530 Subject: [PATCH 06/10] edit-form-validation --- src/app/contact/contact-form/contact-form.component.html | 2 +- src/app/contact/contact-form/contact-form.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.html b/src/app/contact/contact-form/contact-form.component.html index 2946cc5af..f06ca93ce 100644 --- a/src/app/contact/contact-form/contact-form.component.html +++ b/src/app/contact/contact-form/contact-form.component.html @@ -83,7 +83,7 @@ *ngIf=' !( contactForm.controls.telephone.valid || - (contactForm.controls.telephone.pristine && !submitted) + (contactForm.controls.telephone.pristine && !submitted) ) ' > diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index a6e1d46a2..7cf0b3bdc 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -43,7 +43,7 @@ export class ContactFormComponent implements OnInit { const headers = new HttpHeaders(); const formObj = this.contactForm.value; const data = JSON.stringify(formObj); - console.log(this.contactForm.value); + // console.log(this.contactForm.value); headers.append('Content-Type', 'application/X-www-form-urlencoded'); headers.append('Accept', 'application/json'); From fd941c7b977271d0f1c2181d88d9ec9e3e984075 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 01:00:02 +0530 Subject: [PATCH 07/10] edit-form-validation --- src/app/contact/contact-form/contact-form.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 7cf0b3bdc..4c8c8c050 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -43,8 +43,6 @@ export class ContactFormComponent implements OnInit { const headers = new HttpHeaders(); const formObj = this.contactForm.value; const data = JSON.stringify(formObj); - // console.log(this.contactForm.value); - headers.append('Content-Type', 'application/X-www-form-urlencoded'); headers.append('Accept', 'application/json'); From ad5365c1c75031db74310324c52f6c664d1df040 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 01:11:03 +0530 Subject: [PATCH 08/10] edit-form-validation --- .../contact-form/contact-form.component.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 4c8c8c050..eab61c2c8 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -46,18 +46,9 @@ export class ContactFormComponent implements OnInit { headers.append('Content-Type', 'application/X-www-form-urlencoded'); headers.append('Accept', 'application/json'); - this.http - .post('https://formspree.io/office@fossasia.org', data, { - headers: headers - }) - .subscribe(response => { - this.http - .post('https://formspree.io/office@fossasia.org', data, { - headers: headers - }) - .subscribe(responsesent => { - console.log('Sent successfully'); - }); + this.http.post('https://formspree.io/office@fossasia.org', data, {headers: headers}) + .subscribe((response) => {this.http.post('https://formspree.io/office@fossasia.org', data, {headers: headers}) + .subscribe((responsesent) => {console.log('Sent successfully');}); }); } From 081cf2b92884e4c2e1784d2bc82fe05cb350133c Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 01:19:33 +0530 Subject: [PATCH 09/10] edit-form-validation --- .../contact-form/contact-form.component.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index eab61c2c8..4c8c8c050 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -46,9 +46,18 @@ export class ContactFormComponent implements OnInit { headers.append('Content-Type', 'application/X-www-form-urlencoded'); headers.append('Accept', 'application/json'); - this.http.post('https://formspree.io/office@fossasia.org', data, {headers: headers}) - .subscribe((response) => {this.http.post('https://formspree.io/office@fossasia.org', data, {headers: headers}) - .subscribe((responsesent) => {console.log('Sent successfully');}); + this.http + .post('https://formspree.io/office@fossasia.org', data, { + headers: headers + }) + .subscribe(response => { + this.http + .post('https://formspree.io/office@fossasia.org', data, { + headers: headers + }) + .subscribe(responsesent => { + console.log('Sent successfully'); + }); }); } From 0fc25a2d77a7a5246d10f70d3b50cdc6d71ecec2 Mon Sep 17 00:00:00 2001 From: Aaryan-kapur <44099242+Aaryan-kapur@users.noreply.github.com> Date: Wed, 18 Dec 2019 23:18:14 +0530 Subject: [PATCH 10/10] edit-search-infobox-overflow-fix --- src/app/feed/info-box/info-box.component.html | 157 +++++++++++++----- src/app/feed/info-box/info-box.component.scss | 143 ++++++++-------- src/app/feed/info-box/info-box.component.ts | 67 ++++---- 3 files changed, 229 insertions(+), 138 deletions(-) diff --git a/src/app/feed/info-box/info-box.component.html b/src/app/feed/info-box/info-box.component.html index b7f395af7..29375feb1 100644 --- a/src/app/feed/info-box/info-box.component.html +++ b/src/app/feed/info-box/info-box.component.html @@ -1,34 +1,62 @@ -
+
-
+

Top Twitterers

- {{item[1][0]}} - {{item[1][0].length}} + {{ item[1][0] }} + {{ + item[1][0].length + }} - @{{item[1][0]}} + @{{ item[1][0] }}
-
+

Top Hashtags

- + @@ -36,17 +64,31 @@

Top Hashtags

-
+

Top Mentions

-
{{item[1]}}
+
{{ item[1] }}
- #{{item[0]}} + #{{ item[0] }}
@@ -54,33 +96,70 @@

Top Mentions

- - +
  + +  diff --git a/src/app/feed/info-box/info-box.component.scss b/src/app/feed/info-box/info-box.component.scss index e671f4ea3..4e5a027c4 100644 --- a/src/app/feed/info-box/info-box.component.scss +++ b/src/app/feed/info-box/info-box.component.scss @@ -3,12 +3,14 @@ } .info-box { - -webkit-box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - border-radius: 2px; - min-height: 420px; - width: 100%; - margin-bottom: 20px; + -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), + 0 0 0 1px rgba(0, 0, 0, 0.08); + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); + border-radius: 2px; + min-height: 420px; + width: 100%; + margin-bottom: 20px; + overflow: hidden; } .row:first-child { @@ -17,99 +19,100 @@ } .leaderboard-item { - text-align: left; - border-bottom: 2px solid #ccc; - padding: 4px 0; - font-size: 14px; - height: 40px; - img { - border-radius: 50%; - } - td { - position: relative; - padding-left: 10px; - padding-right: 0; - img { - height: 30px; - width: 30px; - } - } + text-align: left; + border-bottom: 2px solid #ccc; + padding: 4px 0; + font-size: 14px; + height: 40px; + img { + border-radius: 50%; + } + td { + position: relative; + padding-left: 10px; + padding-right: 0; + img { + height: 30px; + width: 30px; + } + } } .data { - display: inline-block; - text-decoration: none; - img { - height: 24px; - border-radius: 20%; - } - span { - padding: 5px; - vertical-align: super; - } + display: inline-block; + text-decoration: none; + img { + height: 24px; + border-radius: 20%; + } + span { + padding: 5px; + vertical-align: super; + } } .rss { - background-color: #F79128; - color: white; - height: 24px; - border-radius: 9%; + background-color: #f79128; + color: white; + height: 24px; + border-radius: 9%; } .json { - background-color: #5EBC62; - color: white; - height: 24px; - border-radius: 9%; + background-color: #5ebc62; + color: white; + height: 24px; + border-radius: 9%; } .leaderboard-count { - background-color: #337ab7; - height: 30px; - width: 30px; - padding: 8px 0; - text-align: center; - border-radius: 50%; - font-weight: bold; - font-size: 14px; - color: #fff; + background-color: #337ab7; + height: 30px; + width: 30px; + padding: 8px 0; + text-align: center; + border-radius: 50%; + font-weight: bold; + font-size: 14px; + color: #fff; } .leaderboard-label { - top: -8px; - font-size: 14px; - position: absolute; - left: 20px; - text-align: center; - line-height: 24px; - background-color: #337ab7; - border-radius: 50%; - color: #fff; - width: 23px; - height: 23px; + top: -8px; + font-size: 14px; + position: absolute; + left: 20px; + text-align: center; + line-height: 24px; + background-color: #337ab7; + border-radius: 50%; + color: #fff; + width: 23px; + height: 23px; } .leaderboard-text { - a { - font-size: 14px; - line-height: 21px; - } + a { + font-size: 14px; + line-height: 21px; + } } .link-sidebar-container { - -webkit-box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); + -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), + 0 0 0 1px rgba(0, 0, 0, 0.08); + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); border-radius: 2px; width: 100%; - display:flex; + display: flex; flex-wrap: wrap; margin: 30px 0px; padding: 15px 10px; } .link-sidebar { - margin: 3px 7px; - padding: 0px 15px; + margin: 3px 7px; + padding: 0px 15px; } @media (max-width: 470px) { diff --git a/src/app/feed/info-box/info-box.component.ts b/src/app/feed/info-box/info-box.component.ts index cbd4b3047..74b2dfb0e 100644 --- a/src/app/feed/info-box/info-box.component.ts +++ b/src/app/feed/info-box/info-box.component.ts @@ -38,18 +38,24 @@ export class InfoBoxComponent implements OnChanges { public configUrl = defaultUrlConfig; - constructor( private store: Store ) {} + constructor(private store: Store) {} ngOnChanges() { - this.store.select(fromRoot.getQuery).subscribe(query => this.stringQuery = query.displayString); + this.store + .select(fromRoot.getQuery) + .subscribe(query => (this.stringQuery = query.displayString)); this.parseApiResponseData(); - if ( hashtagRegExp.exec(this.stringQuery) !== null ) { + if (hashtagRegExp.exec(this.stringQuery) !== null) { // Check for hashtag this.stringQuery - this.queryString = '%23' + hashtagRegExp.exec(this.stringQuery)[1] + '' + hashtagRegExp.exec(this.stringQuery)[0]; - } else if ( fromRegExp.exec(this.stringQuery) !== null ) { + this.queryString = + '%23' + + hashtagRegExp.exec(this.stringQuery)[1] + + '' + + hashtagRegExp.exec(this.stringQuery)[0]; + } else if (fromRegExp.exec(this.stringQuery) !== null) { // Check for from user this.stringQuery this.queryString = 'from%3A' + fromRegExp.exec(this.stringQuery)[1]; - } else if ( mentionRegExp.exec(this.stringQuery) !== null ) { + } else if (mentionRegExp.exec(this.stringQuery) !== null) { // Check for mention this.stringQuery this.queryString = '%40' + mentionRegExp.exec(this.stringQuery)[1]; } else { @@ -64,7 +70,10 @@ export class InfoBoxComponent implements OnChanges { for (const s in statistics) { if (s) { for (let i = 0; i < statistics[s].length; i++) { - if ( this.stringQuery.substring(1).toLowerCase() !== statistics[s][i].toLowerCase() ) { + if ( + this.stringQuery.substring(1).toLowerCase() !== + statistics[s][i].toLowerCase() + ) { stored.push(statistics[s][i]); } } @@ -73,7 +82,6 @@ export class InfoBoxComponent implements OnChanges { this.topHashtags = this.parseRawDataWithFrequency(stored); this.areTopHashtagsAvailable = this.topHashtags.length > 0; return this.topHashtags; - } else if (typeof statistics === 'undefined') { this.topHashtags = []; this.areTopHashtagsAvailable = false; @@ -86,17 +94,17 @@ export class InfoBoxComponent implements OnChanges { for (let i = 0; i < statistics.length; i++) { let check = true; for (let j = 0; j < temp.length; j++) { - if ( statistics[i][0] === temp[j][0] ) { + if (statistics[i][0] === temp[j][0]) { check = false; } } - if ( check ) { + if (check) { temp.push(statistics[i]); } } statistics = temp; - for ( let i = 0; i < statistics.length - 1; i++ ) { - for ( let j = i + 1; j < statistics.length; j++ ) { + for (let i = 0; i < statistics.length - 1; i++) { + for (let j = i + 1; j < statistics.length; j++) { if (statistics[i][0] === statistics[j][0]) { if (i !== j) { statistics.splice(j, 1); @@ -110,10 +118,10 @@ export class InfoBoxComponent implements OnChanges { sortable.push([s, statistics[s]]); } } - sortable.sort(function (a, b) { + sortable.sort(function(a, b) { return b[1] - a[1]; }); - sortable = (sortable.slice(0, 10)); + sortable = sortable.slice(0, 10); this.topTwitterers = sortable; this.areTopTwitterersAvailable = true; return this.topTwitterers; @@ -122,7 +130,6 @@ export class InfoBoxComponent implements OnChanges { this.topTwitterers = []; return this.topTwitterers; } - } sortMentions(statistics) { const stored = []; @@ -130,7 +137,10 @@ export class InfoBoxComponent implements OnChanges { for (const s in statistics) { if (s) { for (let i = 0; i < statistics[s][0].length; i++) { - if ( this.stringQuery.substring(1).toLowerCase() !== statistics[s][0][i].toLowerCase() ) { + if ( + this.stringQuery.substring(1).toLowerCase() !== + statistics[s][0][i].toLowerCase() + ) { stored.push(statistics[s][0][i]); } } @@ -148,20 +158,20 @@ export class InfoBoxComponent implements OnChanges { public parseRawDataWithFrequency(stored) { let topFrequencyData = []; - stored = stored.reduce(function (acc, curr) { + stored = stored.reduce(function(acc, curr) { if (typeof acc[curr] === 'undefined') { - acc[curr] = 1; + acc[curr] = 1; } else { acc[curr] += 1; } return acc; }, []); topFrequencyData = Object.keys(stored) - .map(key => key.trim()) - .filter(key => key !== '') - .map(key => ([key, stored[key]])) - .sort((a, b) => b[1] - a[1]) - .slice(0, 10); + .map(key => key.trim()) + .filter(key => key !== '') + .map(key => [key, stored[key]]) + .sort((a, b) => b[1] - a[1]) + .slice(0, 10); return topFrequencyData; } @@ -182,7 +192,7 @@ export class InfoBoxComponent implements OnChanges { const screenStrings = []; const mentionStrings = []; const createdStrings = []; - for ( let i = 0; i < this.ApiResponseResult.length; i++) { + for (let i = 0; i < this.ApiResponseResult.length; i++) { if (this.ApiResponseResult[i]['hashtags'].length !== 0) { tagStrings.push(this.ApiResponseResult[i]['hashtags']); } @@ -193,9 +203,7 @@ export class InfoBoxComponent implements OnChanges { ]); } if (this.ApiResponseResult[i]['mentions'].length !== 0) { - mentionStrings.push([ - this.ApiResponseResult[i]['mentions'] - ]); + mentionStrings.push([this.ApiResponseResult[i]['mentions']]); } if (this.ApiResponseResult[i]['created_at'].length !== 0) { createdStrings.push(this.ApiResponseResult[i]['created_at']); @@ -208,12 +216,13 @@ export class InfoBoxComponent implements OnChanges { } getChartData(statistics) { - for (let i = 0; i < statistics.length; i++) { statistics[i] = JSON.stringify(statistics[i]).substring(1, 11); } const count = {}; - statistics.forEach(function(i) { count[i] = (count[i] || 0) + 1; }); + statistics.forEach(function(i) { + count[i] = (count[i] || 0) + 1; + }); if (statistics !== undefined && statistics.length !== 0) { const data = []; const labels = [];
- {{item[0]}} - {{item[1]}} + {{ item[0] }} + {{ item[1] }} - @{{item[0]}} + @{{ item[0] }}