1 |
55415
|
konstantin
|
export class HelperFunctions {
|
2 |
|
|
//Use this class function to create queryParams Objects in format {key1:value1} or {key1:value1,key2:value2,key3:value3,...} for multiple parameters
|
3 |
|
|
constructor() {}
|
4 |
|
|
|
5 |
|
|
public static scroll() {
|
6 |
|
|
if (typeof document !== 'undefined') {
|
7 |
|
|
//this.element.nativeElement.scrollIntoView();
|
8 |
|
|
window.scrollTo(0, 0);
|
9 |
|
|
}
|
10 |
|
|
}
|
11 |
56013
|
k.triantaf
|
|
12 |
|
|
public static isTiny(url: string) {
|
13 |
|
|
return (url.indexOf('tinyurl.com') !== -1);
|
14 |
|
|
}
|
15 |
57573
|
k.triantaf
|
|
16 |
|
|
public static copy(element: any): any {
|
17 |
57643
|
k.triantaf
|
// return JSON.parse(JSON.stringify(element));
|
18 |
|
|
// return { ...element};
|
19 |
|
|
return Object.assign(Object.create(element), element);
|
20 |
57573
|
k.triantaf
|
}
|
21 |
57590
|
k.triantaf
|
|
22 |
|
|
public static encodeArray(elements: string[]): string[] {
|
23 |
|
|
let encoded: string[] = [];
|
24 |
|
|
elements.forEach(element => {
|
25 |
|
|
encoded.push(encodeURIComponent(element));
|
26 |
|
|
});
|
27 |
|
|
return encoded;
|
28 |
|
|
}
|
29 |
56013
|
k.triantaf
|
}
|