Skip to content

Commit dbe8b1f

Browse files
committed
cookies.js extensions functions added
1 parent 574588b commit dbe8b1f

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

src/js/api.constant.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
API - Constant
33
*******************************************************************************/
4-
const C_API_VERSION = "4.3.1";
4+
const C_API_VERSION = "5.0.0";
55

66
/*******************************************************************************
77
API - Constant - URI

src/js/api.constant.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/api.library.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -918,9 +918,8 @@ api.cookie.session.confirmExtension = function () { };
918918
api.cookie.session.start = function (pLength, pLogoutEnpoint, pLogoutMethod) {
919919
// Get unix timestamp to deal with numbers rather than dates
920920
var timestamp = Math.round(new Date().getTime() / 1000);
921-
922921
// Set the Session Cookie
923-
Cookies.set(
922+
Cookies.setJSON(
924923
C_API_COOKIE_SESSION,
925924
$.extend(true, {}, api.cookie.session.data,
926925
{
@@ -940,13 +939,13 @@ api.cookie.session.start = function (pLength, pLogoutEnpoint, pLogoutMethod) {
940939
*/
941940
api.cookie.session.extend = function () {
942941
// Get the session cookie if any
943-
var data = Cookies.get(C_API_COOKIE_SESSION);
942+
var data = Cookies.getJSON(C_API_COOKIE_SESSION);
944943

945944
if (data) {
946945
// Get unix timestamp to deal with numbers rather than dates
947946
var timestamp = Math.round(new Date().getTime() / 1000);
948947
// Extend Session Cookie
949-
Cookies.set(
948+
Cookies.setJSON(
950949
C_API_COOKIE_SESSION,
951950
$.extend(true, {}, data,
952951
{
@@ -963,7 +962,7 @@ api.cookie.session.extend = function () {
963962
api.cookie.session.end = function (logoutEndpoint, logoutMethod) {
964963
logoutEndpoint = logoutEndpoint || null;
965964
logoutMethod = logoutMethod || null;
966-
var session = Cookies.get(C_API_COOKIE_SESSION);
965+
var session = Cookies.getJSON(C_API_COOKIE_SESSION);
967966
// Run the Logout API
968967
api.ajax.jsonrpc.request(
969968
logoutEndpoint || session.logoutEndpoint,
@@ -993,7 +992,7 @@ api.cookie.session.endCallbak = function (data) {
993992
*/
994993
api.cookie.session.intervalRoutine = function () {
995994
// Get the session cookie if any
996-
var data = Cookies.get(C_API_COOKIE_SESSION);
995+
var data = Cookies.getJSON(C_API_COOKIE_SESSION);
997996
if (!data || $.active) {
998997
// If no session cookie or any running Ajax, then do nothing
999998
return;
@@ -1010,4 +1009,4 @@ api.cookie.session.intervalRoutine = function () {
10101009
} else {
10111010
// The session is valid, do nothing
10121011
}
1013-
};
1012+
};

src/js/api.library.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/api.plugin.cookie.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*******************************************************************************
2+
Application - Plugin - Cookies.js https://github.com/js-cookie/js-cookie
3+
*******************************************************************************/
4+
5+
Cookies.setJSON = function (cookieName, data, cookieOptions) {
6+
Cookies.set(cookieName, JSON.stringify(data), cookieOptions);
7+
}
8+
9+
10+
Cookies.getJSON = function (cookieName) {
11+
var cookieValue = Cookies.get(cookieName);
12+
debugger
13+
if (cookieValue) {
14+
return JSON.parse(cookieValue)
15+
}
16+
else {
17+
return cookieValue
18+
}
19+
}

src/js/api.plugin.cookie.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)