This repository was archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtools.js
77 lines (65 loc) · 1.95 KB
/
tools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// This is the file where I saved all the lagacy code that people wrote in the past.
// Maybe it will be useful in the future.
// I just keep it here for now.
// Huanzhi Mao
// ********** Helper functions related to cookie storage **********
// function createToken(token) {
// if (navigator.cookieEnabled) {
// createCookie("token", token, 1440);
// } else {
// createSession("token", token);
// }
// }
// function readToken() {
// if (navigator.cookieEnabled) {
// return readCookie("token");
// } else {
// return readSession("token");
// }
// }
// function deleteToken() {
// deleteSession("token");
// deleteCookie("token");
// }
// function createSession(name, value) {
// sessionStorage.setItem(encodeURIComponent(name), encodeURIComponent(value));
// }
// function readSession(name) {
// name = encodeURIComponent(name);
// if (sessionStorage.hasOwnProperty(name)) {
// return sessionStorage.getItem(name);
// } else {
// return null;
// }
// }
// function deleteSession(name) {
// name = encodeURIComponent(name);
// if (sessionStorage.hasOwnProperty(name)) {
// return sessionStorage.removeItem(name);
// }
// }
// function createCookie(name, value, minutes) {
// let date = new Date();
// date.setTime(date.getTime() + minutes * 60 * 1000);
// let expires = "; expires=" + date.toUTCString();
// document.cookie =
// encodeURIComponent(name) +
// "=" +
// encodeURIComponent(value) +
// expires +
// "; path=/";
// }
// function readCookie(name) {
// name = encodeURIComponent(name) + "=";
// for (c of document.cookie.split(";")) {
// c = c.trim();
// if (c.indexOf(name) === 0) {
// return decodeURIComponent(c.substring(name.length, c.length));
// }
// }
// return null;
// }
// function deleteCookie(name) {
// let expires = "; expires = Thu, 01 Jan 1970 00:00:00 GMT";
// document.cookie = encodeURIComponent(name) + "=/" + expires + "; path=/";
// }