Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHamidreza Ghavami <hamid.r.gh.1998@gmail.com>2023-05-08 16:34:12 +0300
committerHamidreza Ghavami <hamid.r.gh.1998@gmail.com>2023-05-08 16:34:12 +0300
commitd137deccfa49fdd202dc7ce5147ad71d450c3134 (patch)
treed2b665f0cdf820cda9f69cfa767869db692bb02c /web/assets/js/util/common.js
parent00777e3a258c19301c8b98e55b2b79df8d9585a6 (diff)
fix style height when rotating + move cookie util to their specific file
Diffstat (limited to 'web/assets/js/util/common.js')
-rw-r--r--web/assets/js/util/common.js41
1 files changed, 32 insertions, 9 deletions
diff --git a/web/assets/js/util/common.js b/web/assets/js/util/common.js
index b3ebc0bd..808b1ba9 100644
--- a/web/assets/js/util/common.js
+++ b/web/assets/js/util/common.js
@@ -56,14 +56,37 @@ function toFixed(num, n) {
return Math.round(num * n) / n;
}
-function debounce (fn, delay) {
- var timeoutID = null
+function debounce(fn, delay) {
+ var timeoutID = null;
return function () {
- clearTimeout(timeoutID)
- var args = arguments
- var that = this
- timeoutID = setTimeout(function () {
- fn.apply(that, args)
- }, delay)
+ clearTimeout(timeoutID);
+ var args = arguments;
+ var that = this;
+ timeoutID = setTimeout(function () {
+ fn.apply(that, args);
+ }, delay);
+ };
+}
+
+function getCookie(cname) {
+ let name = cname + '=';
+ let decodedCookie = decodeURIComponent(document.cookie);
+ let ca = decodedCookie.split(';');
+ for (let i = 0; i < ca.length; i++) {
+ let c = ca[i];
+ while (c.charAt(0) == ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) == 0) {
+ return c.substring(name.length, c.length);
+ }
}
- } \ No newline at end of file
+ return '';
+}
+
+function setCookie(cname, cvalue, exdays) {
+ const d = new Date();
+ d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
+ let expires = 'expires=' + d.toUTCString();
+ document.cookie = cname + '=' + cvalue + ';' + expires + ';path=/';
+}