Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
9cd5c980
Commit
9cd5c980
authored
Dec 07, 2015
by
Ray Schamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Jar formatting consistent with everything else
parent
3c307e17
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
31 deletions
+29
-31
src/lib/jar.js
src/lib/jar.js
+29
-31
No files found.
src/lib/jar.js
View file @
9cd5c980
...
@@ -9,9 +9,8 @@ var xhr = require('xhr');
...
@@ -9,9 +9,8 @@ var xhr = require('xhr');
* set(name, value) – synchronously sets the cookie
* set(name, value) – synchronously sets the cookie
* use(name, uri, callback) – can by sync or async, gets cookie from the uri if not there.
* use(name, uri, callback) – can by sync or async, gets cookie from the uri if not there.
*/
*/
var
Jar
=
{};
var
Jar
=
{
get
:
function
(
name
,
callback
)
{
Jar
.
get
=
function
(
name
,
callback
)
{
// Get cookie by name
// Get cookie by name
var
obj
=
cookie
.
parse
(
document
.
cookie
)
||
{};
var
obj
=
cookie
.
parse
(
document
.
cookie
)
||
{};
...
@@ -22,9 +21,8 @@ Jar.get = function (name, callback) {
...
@@ -22,9 +21,8 @@ Jar.get = function (name, callback) {
}
}
return
obj
[
name
];
return
obj
[
name
];
};
},
use
:
function
(
name
,
uri
,
callback
)
{
Jar
.
use
=
function
(
name
,
uri
,
callback
)
{
// Attempt to get cookie
// Attempt to get cookie
Jar
.
get
(
name
,
function
(
err
,
obj
)
{
Jar
.
get
(
name
,
function
(
err
,
obj
)
{
if
(
typeof
obj
!==
'
undefined
'
)
return
callback
(
null
,
obj
);
if
(
typeof
obj
!==
'
undefined
'
)
return
callback
(
null
,
obj
);
...
@@ -37,13 +35,13 @@ Jar.use = function (name, uri, callback) {
...
@@ -37,13 +35,13 @@ Jar.use = function (name, uri, callback) {
Jar
.
get
(
name
,
callback
);
Jar
.
get
(
name
,
callback
);
});
});
});
});
};
},
set
:
function
(
name
,
value
)
{
Jar
.
set
=
function
(
name
,
value
)
{
var
obj
=
cookie
.
serialize
(
name
,
value
);
var
obj
=
cookie
.
serialize
(
name
,
value
);
var
expires
=
'
; expires=
'
+
new
Date
(
new
Date
().
setYear
(
new
Date
().
getFullYear
()
+
1
)).
toUTCString
();
var
expires
=
'
; expires=
'
+
new
Date
(
new
Date
().
setYear
(
new
Date
().
getFullYear
()
+
1
)).
toUTCString
();
var
path
=
'
; path=/
'
;
var
path
=
'
; path=/
'
;
document
.
cookie
=
obj
+
expires
+
path
;
document
.
cookie
=
obj
+
expires
+
path
;
}
};
};
module
.
exports
=
Jar
;
module
.
exports
=
Jar
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment