Initial commit for the Angular part. We are nowhere yet.

This commit is contained in:
Amritanshu
2019-06-14 00:32:34 +05:30
parent 1a1fa7881d
commit d59c60e81d
123 changed files with 3748 additions and 374 deletions

View File

@ -0,0 +1,36 @@
import {Injectable} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CookieService {
constructor() {
}
public getCookie(name: string) {
const ca: Array<string> = document.cookie.split(';');
const caLen: number = ca.length;
const cookieName = `${name}=`;
let c: string;
for (let i = 0; i < caLen; i += 1) {
c = ca[i].replace(/^\s+/g, '');
if (c.indexOf(cookieName) === 0) {
return c.substring(cookieName.length, c.length);
}
}
return '';
}
public deleteCookie(name) {
this.setCookie(name, '', -1);
}
public setCookie(name: string, value: string, expireDays: number, path: string = '') {
const d: Date = new Date();
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
const expires: string = 'expires=' + d.toUTCString();
document.cookie = name + '=' + value + '; ' + expires + (path.length > 0 ? '; path=' + path : '');
}
}