-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unused/useless code & Optimization Page
v3.1 (2022)
- Loading branch information
Showing
6 changed files
with
239 additions
and
318 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Author: KB | ||
// Version: 1.0 | ||
// All Rights Copyrights 2022 | ||
|
||
class cookieSupport{ | ||
static list(){ | ||
var cookies = document.cookie.split(";"); | ||
console.warn("[Cookie] List Availables Cookies") | ||
for (var cookie in cookies){ | ||
console.log(cookies[cookie]) | ||
} | ||
console.warn("=================================") | ||
} | ||
static check(cookie_name){ | ||
/*var res = document.cookie.indexOf(cookie_name + "="); | ||
if (res == 0){ | ||
return "[Cookie] " + cookie_name + " exist"; | ||
} | ||
else{ | ||
return "[Cookie] " + cookie_name + " no exist"; | ||
}*/ | ||
var res = this.get(cookie_name); | ||
if (res.length > 0){ | ||
return "[Cookie] " + cookie_name + " exist"; | ||
} | ||
else{ | ||
return "[Cookie] " + cookie_name + " no exist"; | ||
} | ||
} | ||
static check_val(cookie_name){ | ||
/*var res = document.cookie.indexOf(cookie_name + "="); | ||
if (res == 0){ | ||
return true; | ||
} | ||
else{ | ||
return false; | ||
}*/ | ||
var res = this.get(cookie_name); | ||
try{ | ||
if (res.length > 0){ | ||
return true; | ||
} | ||
else{ | ||
return false; | ||
} | ||
} | ||
catch{ | ||
return false; | ||
} | ||
} | ||
static get(cookie_name){ | ||
const value = `; ${document.cookie}`; | ||
const parts = value.split(`; ${cookie_name}=`); | ||
if (parts.length === 2) return parts.pop().split(';').shift(); | ||
} | ||
static add(cookie_name, value){ | ||
try{ | ||
document.cookie = cookie_name + "=" + value + "; expires=Thu, 31 Dec 2023 23:59:00 UTC"; | ||
return "[Cookie] " + cookie_name + " created"; | ||
} | ||
catch{ | ||
return "[Cookie] invalid cookie name or value"; | ||
} | ||
} | ||
static edit(cookie_name, value){ | ||
this.add(cookie_name, value) | ||
} | ||
static remove(cookie_name){ | ||
try{ | ||
document.cookie = cookie_name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | ||
document.cookie = cookie_name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | ||
return "[Cookie] " + cookie_name + " deleted" | ||
} | ||
catch{ | ||
return "[Cookie] Problem with delete Cookie " + cookie_name | ||
} | ||
} | ||
|
||
/* Setup Aliases */ | ||
|
||
static delete(cookie_name){ | ||
this.remove(cookie_name); | ||
} | ||
static del(cookie_name){ | ||
this.delete(cookie_name); | ||
} | ||
static find(cookie_name, value){ | ||
this.check(cookie_name); | ||
} | ||
} | ||
|
||
// Init | ||
const cst = cookieSupport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,148 +1,49 @@ | ||
/* EasyCookie v2.1 [Rewrited] */ | ||
/* EasyCookie v3 [Rewrited Class Edition] */ | ||
/* Created by Klubuntu */ | ||
/* Source Code: https://github.com/Klubuntu/EasyCookieJS */ | ||
|
||
const $prefix = '[EasyCookie] '; | ||
|
||
//easyCookieInterpreter | ||
function eCI(cmd, arg1 = "", arg2 = "") { | ||
msg = "[EasyCookie] "; | ||
function addCookie() { | ||
name = arg1 | ||
val = arg2 | ||
if (!name == "" || !name == null) { | ||
if (!val == "" || !val == null) { | ||
let usrcookie = getCookie(get = 1); | ||
if (usrcookie != "") { | ||
console.log(msg + "Cookie " + name + " has been already created") | ||
} else { | ||
if (name != "" && [name] != null) { | ||
document.cookie = name + "=" + val | ||
console.log(msg + "Cookie " + name + " has been created") | ||
} | ||
}; | ||
} | ||
else { | ||
console.warn(msg + "Cookie value no set") | ||
} | ||
} | ||
else { | ||
console.warn(msg + "Cookie name no set") | ||
} | ||
} | ||
function getCookie(get = 0) { | ||
name = arg1 | ||
if (!name == "" || !name == null) { | ||
//cname = cookiename | ||
cname = name; | ||
let tmpName = 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(tmpName) == 0) { | ||
xcookie = c.substring(tmpName.length, c.length); | ||
return c.substring(tmpName.length, c.length); | ||
} | ||
} | ||
if (get == 0) { | ||
return msg + "Cookie " + name + " no exists"; | ||
} | ||
else if (get == 1) { | ||
return ""; | ||
} | ||
|
||
} | ||
else { | ||
console.warn(msg + "Cookie name no set") | ||
class EasyCookie { | ||
static add(cookieName, cookieValue){ | ||
try{ | ||
document.cookie = cookieName + "=" + cookieValue + "; expires=Thu, 31 Dec 2023 23:59:00 UTC"; | ||
return $prefix + cookieName + " created"; | ||
} | ||
catch{ | ||
return $prefix + "invalid cookie name or value"; | ||
} | ||
} | ||
function editCookie() { | ||
name = arg1 | ||
val = arg2 | ||
if (!name == "" || !name == null) { | ||
if (!val == "" || !val == null) { | ||
let usrcookie = getCookie(get = 1); | ||
if (usrcookie != "") { | ||
document.cookie = document.cookie = name + "=" + val; | ||
} else { | ||
if (name != "" && [name] != null) { | ||
console.log(msg + "Cookie ", name, " not found.") | ||
} | ||
} | ||
} | ||
else { | ||
console.warn(msg + "Cookie value no set") | ||
} | ||
} | ||
else { | ||
console.warn(msg + "Cookie name no set") | ||
} | ||
} | ||
function delCookie() { | ||
name = arg1 | ||
if (!name == "" || !name == null) { | ||
let usrcookie = getCookie(get = 1); | ||
if (usrcookie != "") { | ||
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | ||
} else { | ||
if (name != "" && [name] != null) { | ||
console.log(msg + "Cookie ", name, " not found.") | ||
} | ||
} | ||
} | ||
else { | ||
console.warn(msg + "Cookie name no set") | ||
} | ||
static get(cookieName){ | ||
const value = `; ${document.cookie}`; | ||
const parts = value.split(`; ${cookieName}=`); | ||
if (parts.length === 2) return parts.pop().split(';').shift(); | ||
} | ||
|
||
function version(){ | ||
return( | ||
msg + "Version 2.1 [Rewrited]" + "\n" + "Check new release on https://github.com/Klubuntu/EasyCookieJS" | ||
) | ||
static edit(cookieName, cookieValue){ | ||
return this.add(cookieName, cookieValue); | ||
} | ||
|
||
|
||
if (cmd == "add") { | ||
addCookie(); | ||
} | ||
else if (cmd == "get") { | ||
getCookie(); | ||
} | ||
else if (cmd == "edit") { | ||
editCookie(); | ||
} | ||
else if (cmd == "del") { | ||
delCookie(); | ||
} | ||
else if(cmd == "ver"){ | ||
console.log(version()); | ||
static remove(cookieName){ | ||
try{ | ||
document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | ||
document.cookie = cookieName + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | ||
return $prefix + cookieName + " deleted" | ||
} | ||
catch{ | ||
return $prefix + "Problem with delete cookie " + cookieName | ||
} | ||
} | ||
else { | ||
return msg + "Unknown Command"; | ||
} | ||
} | ||
|
||
|
||
|
||
//define main function | ||
var easycookie = (function () { | ||
return { | ||
add: function (name, val) { return eCI("add", name, val) }, | ||
edit: function (name, val) { return eCI("edit", name, val) }, | ||
del: function (name) { return eCI("del", name) }, | ||
get: function (name) { return eCI("get", name) }, | ||
ver: function () { eCI("ver") }, | ||
// popular aliases | ||
set: function (name, val) { return eCI("add", name, val) }, | ||
change: function (name, val) { return eCI("edit", name, val) }, | ||
rem: function (name) { return eCI("del", name) }, | ||
remove: function (name) { return eCI("del", name) }, | ||
rm: function (name) { return eCI("del", name) }, | ||
check: function (name) { return eCI("get", name) }, | ||
version: function () { eCI("ver") }, | ||
about: function () { eCI("ver") }, | ||
}; | ||
})(); | ||
/* Setup Aliases */ | ||
|
||
static delete(cookieName){ | ||
return this.remove(cookieName); | ||
} | ||
static del(cookieName){ | ||
return this.delete(cookieName); | ||
} | ||
static find(cookieName){ | ||
return this.check(cookieName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
69987fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
klubuntu-eu-org – ./
klubuntu-eu-org.vercel.app
klubuntu-eu-org-git-main-klubuntu.vercel.app
beta.klubuntu.eu.org
klubuntu.social
klubuntu-eu-org-klubuntu.vercel.app
www.klubuntu.social
klubuntu.live
klubuntu.eu.org
www.klubuntu.live