2019-04-24 12:39:15 +02:00
|
|
|
export class HelperFunctions {
|
|
|
|
//Use this class function to create queryParams Objects in format {key1:value1} or {key1:value1,key2:value2,key3:value3,...} for multiple parameters
|
|
|
|
constructor() {}
|
|
|
|
|
|
|
|
public static scroll() {
|
|
|
|
if (typeof document !== 'undefined') {
|
|
|
|
//this.element.nativeElement.scrollIntoView();
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
}
|
|
|
|
}
|
2019-06-06 12:51:39 +02:00
|
|
|
|
|
|
|
public static isTiny(url: string) {
|
|
|
|
return (url.indexOf('tinyurl.com') !== -1);
|
|
|
|
}
|
2019-11-11 14:27:18 +01:00
|
|
|
|
|
|
|
public static copy(element: any): any {
|
2019-11-20 11:31:14 +01:00
|
|
|
// return JSON.parse(JSON.stringify(element));
|
|
|
|
// return { ...element};
|
|
|
|
return Object.assign(Object.create(element), element);
|
2019-11-11 14:27:18 +01:00
|
|
|
}
|
2019-11-12 16:54:03 +01:00
|
|
|
|
|
|
|
public static encodeArray(elements: string[]): string[] {
|
|
|
|
let encoded: string[] = [];
|
|
|
|
elements.forEach(element => {
|
|
|
|
encoded.push(encodeURIComponent(element));
|
|
|
|
});
|
|
|
|
return encoded;
|
|
|
|
}
|
2019-06-06 12:51:39 +02:00
|
|
|
}
|