Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5f7c0bd7
Commit
5f7c0bd7
authored
Mar 11, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove Cookies class from global space
parent
77eda528
Changes
19
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
36 additions
and
185 deletions
+36
-185
app/assets/javascripts/activities.js
app/assets/javascripts/activities.js
+2
-1
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+1
-1
app/assets/javascripts/boards/components/board_blank_state.js
...assets/javascripts/boards/components/board_blank_state.js
+3
-1
app/assets/javascripts/boards/stores/boards_store.js
app/assets/javascripts/boards/stores/boards_store.js
+2
-1
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
...ets/javascripts/cycle_analytics/cycle_analytics_bundle.js
+1
-2
app/assets/javascripts/diff_notes/components/diff_note_avatars.js
...ts/javascripts/diff_notes/components/diff_note_avatars.js
+3
-1
app/assets/javascripts/issuable_context.js
app/assets/javascripts/issuable_context.js
+2
-1
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-2
app/assets/javascripts/merge_conflicts/merge_conflict_store.js
...ssets/javascripts/merge_conflicts/merge_conflict_store.js
+1
-1
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+2
-2
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+2
-2
app/assets/javascripts/project.js
app/assets/javascripts/project.js
+2
-1
app/assets/javascripts/right_sidebar.js
app/assets/javascripts/right_sidebar.js
+2
-1
app/assets/javascripts/user.js
app/assets/javascripts/user.js
+2
-1
app/assets/javascripts/user_callout.js
app/assets/javascripts/user_callout.js
+1
-1
spec/javascripts/boards/boards_store_spec.js
spec/javascripts/boards/boards_store_spec.js
+1
-1
spec/javascripts/test_bundle.js
spec/javascripts/test_bundle.js
+0
-1
spec/javascripts/user_callout_spec.js
spec/javascripts/user_callout_spec.js
+9
-8
vendor/assets/javascripts/js.cookie.js
vendor/assets/javascripts/js.cookie.js
+0
-156
No files found.
app/assets/javascripts/activities.js
View file @
5f7c0bd7
/* eslint-disable no-param-reassign, class-methods-use-this */
/* eslint-disable no-param-reassign, class-methods-use-this */
/* global Pager */
/* global Pager */
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
class
Activities
{
class
Activities
{
constructor
()
{
constructor
()
{
...
...
app/assets/javascripts/awards_handler.js
View file @
5f7c0bd7
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
import
emojiMap
from
'
emojis/digests.json
'
;
import
emojiMap
from
'
emojis/digests.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
...
...
app/assets/javascripts/boards/components/board_blank_state.js
View file @
5f7c0bd7
/* global ListLabel */
/* global ListLabel */
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
const
Store
=
gl
.
issueBoards
.
BoardsStore
;
export
default
{
export
default
{
...
...
app/assets/javascripts/boards/stores/boards_store.js
View file @
5f7c0bd7
/* eslint-disable comma-dangle, space-before-function-paren, one-var, no-shadow, dot-notation, max-len */
/* eslint-disable comma-dangle, space-before-function-paren, one-var, no-shadow, dot-notation, max-len */
/* global Cookies */
/* global List */
/* global List */
import
Cookies
from
'
js-cookie
'
;
(()
=>
{
(()
=>
{
window
.
gl
=
window
.
gl
||
{};
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
issueBoards
=
window
.
gl
.
issueBoards
||
{};
window
.
gl
.
issueBoards
=
window
.
gl
.
issueBoards
||
{};
...
...
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
View file @
5f7c0bd7
/* global Cookies */
/* global Flash */
/* global Flash */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Cookies
from
'
js-cookie
'
;
window
.
Cookies
=
require
(
'
js-cookie
'
);
require
(
'
./components/stage_code_component
'
);
require
(
'
./components/stage_code_component
'
);
require
(
'
./components/stage_issue_component
'
);
require
(
'
./components/stage_issue_component
'
);
require
(
'
./components/stage_plan_component
'
);
require
(
'
./components/stage_plan_component
'
);
...
...
app/assets/javascripts/diff_notes/components/diff_note_avatars.js
View file @
5f7c0bd7
/* global CommentsStore Cookies notes */
/* global CommentsStore */
/* global notes */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
collapseIcon
from
'
../icons/collapse_icon.svg
'
;
import
collapseIcon
from
'
../icons/collapse_icon.svg
'
;
...
...
app/assets/javascripts/issuable_context.js
View file @
5f7c0bd7
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-new, comma-dangle, quotes, prefer-arrow-callback, consistent-return, one-var, no-var, one-var-declaration-per-line, no-underscore-dangle, max-len */
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-new, comma-dangle, quotes, prefer-arrow-callback, consistent-return, one-var, no-var, one-var-declaration-per-line, no-underscore-dangle, max-len */
/* global UsersSelect */
/* global UsersSelect */
/* global Cookies */
/* global bp */
/* global bp */
import
Cookies
from
'
js-cookie
'
;
(
function
()
{
(
function
()
{
this
.
IssuableContext
=
(
function
()
{
this
.
IssuableContext
=
(
function
()
{
function
IssuableContext
(
currentUser
)
{
function
IssuableContext
(
currentUser
)
{
...
...
app/assets/javascripts/main.js
View file @
5f7c0bd7
/* eslint-disable func-names, space-before-function-paren, no-var, quotes, consistent-return, prefer-arrow-callback, comma-dangle, object-shorthand, no-new, max-len, no-multi-spaces, import/newline-after-import, import/first */
/* eslint-disable func-names, space-before-function-paren, no-var, quotes, consistent-return, prefer-arrow-callback, comma-dangle, object-shorthand, no-new, max-len, no-multi-spaces, import/newline-after-import, import/first */
/* global bp */
/* global bp */
/* global Cookies */
/* global Flash */
/* global Flash */
/* global ConfirmDangerModal */
/* global ConfirmDangerModal */
/* global Aside */
/* global Aside */
...
@@ -24,7 +23,6 @@ import './extensions/array';
...
@@ -24,7 +23,6 @@ import './extensions/array';
window
.
jQuery
=
jQuery
;
window
.
jQuery
=
jQuery
;
window
.
$
=
jQuery
;
window
.
$
=
jQuery
;
window
.
_
=
_
;
window
.
_
=
_
;
window
.
Cookies
=
Cookies
;
window
.
Pikaday
=
Pikaday
;
window
.
Pikaday
=
Pikaday
;
window
.
Dropzone
=
Dropzone
;
window
.
Dropzone
=
Dropzone
;
window
.
Sortable
=
Sortable
;
window
.
Sortable
=
Sortable
;
...
...
app/assets/javascripts/merge_conflicts/merge_conflict_store.js
View file @
5f7c0bd7
/* eslint-disable comma-dangle, object-shorthand, no-param-reassign, camelcase, no-nested-ternary, no-continue, max-len */
/* eslint-disable comma-dangle, object-shorthand, no-param-reassign, camelcase, no-nested-ternary, no-continue, max-len */
/* global Cookies */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Cookies
from
'
js-cookie
'
;
((
global
)
=>
{
((
global
)
=>
{
global
.
mergeConflicts
=
global
.
mergeConflicts
||
{};
global
.
mergeConflicts
=
global
.
mergeConflicts
||
{};
...
...
app/assets/javascripts/merge_request_tabs.js
View file @
5f7c0bd7
/* eslint-disable no-new, class-methods-use-this */
/* eslint-disable no-new, class-methods-use-this */
/* global Breakpoints */
/* global Breakpoints */
/* global Cookies */
/* global Flash */
/* global Flash */
import
Cookies
from
'
js-cookie
'
;
require
(
'
./breakpoints
'
);
require
(
'
./breakpoints
'
);
window
.
Cookies
=
require
(
'
js-cookie
'
);
require
(
'
./flash
'
);
require
(
'
./flash
'
);
/* eslint-disable max-len */
/* eslint-disable max-len */
...
...
app/assets/javascripts/notes.js
View file @
5f7c0bd7
/* eslint-disable no-restricted-properties, func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-use-before-define, camelcase, no-unused-expressions, quotes, max-len, one-var, one-var-declaration-per-line, default-case, prefer-template, consistent-return, no-alert, no-return-assign, no-param-reassign, prefer-arrow-callback, no-else-return, comma-dangle, no-new, brace-style, no-lonely-if, vars-on-top, no-unused-vars, no-sequences, no-shadow, newline-per-chained-call, no-useless-escape */
/* eslint-disable no-restricted-properties, func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-use-before-define, camelcase, no-unused-expressions, quotes, max-len, one-var, one-var-declaration-per-line, default-case, prefer-template, consistent-return, no-alert, no-return-assign, no-param-reassign, prefer-arrow-callback, no-else-return, comma-dangle, no-new, brace-style, no-lonely-if, vars-on-top, no-unused-vars, no-sequences, no-shadow, newline-per-chained-call, no-useless-escape */
/* global Flash */
/* global Flash */
/* global Autosave */
/* global Autosave */
/* global Cookies */
/* global ResolveService */
/* global ResolveService */
/* global mrRefreshWidgetUrl */
/* global mrRefreshWidgetUrl */
import
Cookies
from
'
js-cookie
'
;
require
(
'
./autosave
'
);
require
(
'
./autosave
'
);
window
.
autosize
=
require
(
'
vendor/autosize
'
);
window
.
autosize
=
require
(
'
vendor/autosize
'
);
window
.
Dropzone
=
require
(
'
dropzone
'
);
window
.
Dropzone
=
require
(
'
dropzone
'
);
window
.
Cookies
=
require
(
'
js-cookie
'
);
require
(
'
./dropzone_input
'
);
require
(
'
./dropzone_input
'
);
require
(
'
./gfm_auto_complete
'
);
require
(
'
./gfm_auto_complete
'
);
require
(
'
vendor/jquery.caret
'
);
// required by jquery.atwho
require
(
'
vendor/jquery.caret
'
);
// required by jquery.atwho
...
...
app/assets/javascripts/project.js
View file @
5f7c0bd7
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, quotes, consistent-return, no-new, prefer-arrow-callback, no-return-assign, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-else-return, newline-per-chained-call, no-shadow, vars-on-top, prefer-template, max-len */
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, quotes, consistent-return, no-new, prefer-arrow-callback, no-return-assign, one-var, one-var-declaration-per-line, object-shorthand, comma-dangle, no-else-return, newline-per-chained-call, no-shadow, vars-on-top, prefer-template, max-len */
/* global Cookies */
/* global ProjectSelect */
/* global ProjectSelect */
import
Cookies
from
'
js-cookie
'
;
(
function
()
{
(
function
()
{
this
.
Project
=
(
function
()
{
this
.
Project
=
(
function
()
{
function
Project
()
{
function
Project
()
{
...
...
app/assets/javascripts/right_sidebar.js
View file @
5f7c0bd7
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-unused-vars, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, object-shorthand, comma-dangle, no-else-return, no-param-reassign, max-len */
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-unused-vars, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, object-shorthand, comma-dangle, no-else-return, no-param-reassign, max-len */
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
(
function
()
{
(
function
()
{
var
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
var
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
...
...
app/assets/javascripts/user.js
View file @
5f7c0bd7
/* eslint-disable class-methods-use-this, comma-dangle, arrow-parens, no-param-reassign */
/* eslint-disable class-methods-use-this, comma-dangle, arrow-parens, no-param-reassign */
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
((
global
)
=>
{
((
global
)
=>
{
global
.
User
=
class
{
global
.
User
=
class
{
...
...
app/assets/javascripts/user_callout.js
View file @
5f7c0bd7
/* global Cookies */
import
Cookies
from
'
js-cookie
'
;
const
userCalloutElementName
=
'
.user-callout
'
;
const
userCalloutElementName
=
'
.user-callout
'
;
const
closeButton
=
'
.close-user-callout
'
;
const
closeButton
=
'
.close-user-callout
'
;
...
...
spec/javascripts/boards/boards_store_spec.js
View file @
5f7c0bd7
/* eslint-disable comma-dangle, one-var, no-unused-vars */
/* eslint-disable comma-dangle, one-var, no-unused-vars */
/* global BoardService */
/* global BoardService */
/* global boardsMockInterceptor */
/* global boardsMockInterceptor */
/* global Cookies */
/* global listObj */
/* global listObj */
/* global listObjDuplicate */
/* global listObjDuplicate */
/* global ListIssue */
/* global ListIssue */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
Cookies
from
'
js-cookie
'
;
require
(
'
~/lib/utils/url_utility
'
);
require
(
'
~/lib/utils/url_utility
'
);
require
(
'
~/boards/models/issue
'
);
require
(
'
~/boards/models/issue
'
);
...
...
spec/javascripts/test_bundle.js
View file @
5f7c0bd7
...
@@ -8,7 +8,6 @@ jasmine.getJSONFixtures().fixturesPath = 'base/spec/javascripts/fixtures';
...
@@ -8,7 +8,6 @@ jasmine.getJSONFixtures().fixturesPath = 'base/spec/javascripts/fixtures';
require
(
'
~/commons/index.js
'
);
require
(
'
~/commons/index.js
'
);
window
.
$
=
window
.
jQuery
=
require
(
'
jquery
'
);
window
.
$
=
window
.
jQuery
=
require
(
'
jquery
'
);
window
.
_
=
require
(
'
underscore
'
);
window
.
_
=
require
(
'
underscore
'
);
window
.
Cookies
=
require
(
'
js-cookie
'
);
// stub expected globals
// stub expected globals
window
.
gl
=
window
.
gl
||
{};
window
.
gl
=
window
.
gl
||
{};
...
...
spec/javascripts/user_callout_spec.js
View file @
5f7c0bd7
import
Cookies
from
'
js-cookie
'
;
const
UserCallout
=
require
(
'
~/user_callout
'
);
const
UserCallout
=
require
(
'
~/user_callout
'
);
const
USER_CALLOUT_COOKIE
=
'
user_callout_dismissed
'
;
const
USER_CALLOUT_COOKIE
=
'
user_callout_dismissed
'
;
const
Cookie
=
window
.
Cookies
;
describe
(
'
UserCallout
'
,
function
()
{
describe
(
'
UserCallout
'
,
function
()
{
const
fixtureName
=
'
static/user_callout.html.raw
'
;
const
fixtureName
=
'
static/user_callout.html.raw
'
;
...
@@ -9,7 +10,7 @@ describe('UserCallout', function () {
...
@@ -9,7 +10,7 @@ describe('UserCallout', function () {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
Cookie
.
remove
(
USER_CALLOUT_COOKIE
);
Cookie
s
.
remove
(
USER_CALLOUT_COOKIE
);
this
.
userCallout
=
new
UserCallout
();
this
.
userCallout
=
new
UserCallout
();
this
.
closeButton
=
$
(
'
.close-user-callout
'
);
this
.
closeButton
=
$
(
'
.close-user-callout
'
);
...
@@ -18,25 +19,25 @@ describe('UserCallout', function () {
...
@@ -18,25 +19,25 @@ describe('UserCallout', function () {
});
});
it
(
'
does not show when cookie is set not defined
'
,
()
=>
{
it
(
'
does not show when cookie is set not defined
'
,
()
=>
{
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBeUndefined
();
expect
(
Cookie
s
.
get
(
USER_CALLOUT_COOKIE
)).
toBeUndefined
();
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
});
});
it
(
'
shows when cookie is set to false
'
,
()
=>
{
it
(
'
shows when cookie is set to false
'
,
()
=>
{
Cookie
.
set
(
USER_CALLOUT_COOKIE
,
'
false
'
);
Cookie
s
.
set
(
USER_CALLOUT_COOKIE
,
'
false
'
);
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBeDefined
();
expect
(
Cookie
s
.
get
(
USER_CALLOUT_COOKIE
)).
toBeDefined
();
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
expect
(
this
.
userCalloutContainer
.
is
(
'
:visible
'
)).
toBe
(
true
);
});
});
it
(
'
hides when user clicks on the dismiss-icon
'
,
()
=>
{
it
(
'
hides when user clicks on the dismiss-icon
'
,
()
=>
{
this
.
closeButton
.
click
();
this
.
closeButton
.
click
();
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
expect
(
Cookie
s
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
it
(
'
hides when user clicks on the "check it out" button
'
,
()
=>
{
it
(
'
hides when user clicks on the "check it out" button
'
,
()
=>
{
this
.
userCalloutBtn
.
click
();
this
.
userCalloutBtn
.
click
();
expect
(
Cookie
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
expect
(
Cookie
s
.
get
(
USER_CALLOUT_COOKIE
)).
toBe
(
'
true
'
);
});
});
});
});
...
@@ -46,7 +47,7 @@ describe('UserCallout when cookie is present', function () {
...
@@ -46,7 +47,7 @@ describe('UserCallout when cookie is present', function () {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
Cookie
.
set
(
USER_CALLOUT_COOKIE
,
'
true
'
);
Cookie
s
.
set
(
USER_CALLOUT_COOKIE
,
'
true
'
);
this
.
userCallout
=
new
UserCallout
();
this
.
userCallout
=
new
UserCallout
();
this
.
userCalloutContainer
=
$
(
'
.user-callout
'
);
this
.
userCalloutContainer
=
$
(
'
.user-callout
'
);
});
});
...
...
vendor/assets/javascripts/js.cookie.js
deleted
100644 → 0
View file @
77eda528
/*!
* JavaScript Cookie v2.1.3
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(
function
(
factory
)
{
var
registeredInModuleLoader
=
false
;
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
define
(
factory
);
registeredInModuleLoader
=
true
;
}
if
(
typeof
exports
===
'
object
'
)
{
module
.
exports
=
factory
();
registeredInModuleLoader
=
true
;
}
if
(
!
registeredInModuleLoader
)
{
var
OldCookies
=
window
.
Cookies
;
var
api
=
window
.
Cookies
=
factory
();
api
.
noConflict
=
function
()
{
window
.
Cookies
=
OldCookies
;
return
api
;
};
}
}(
function
()
{
function
extend
()
{
var
i
=
0
;
var
result
=
{};
for
(;
i
<
arguments
.
length
;
i
++
)
{
var
attributes
=
arguments
[
i
];
for
(
var
key
in
attributes
)
{
result
[
key
]
=
attributes
[
key
];
}
}
return
result
;
}
function
init
(
converter
)
{
function
api
(
key
,
value
,
attributes
)
{
var
result
;
if
(
typeof
document
===
'
undefined
'
)
{
return
;
}
// Write
if
(
arguments
.
length
>
1
)
{
attributes
=
extend
({
path
:
'
/
'
},
api
.
defaults
,
attributes
);
if
(
typeof
attributes
.
expires
===
'
number
'
)
{
var
expires
=
new
Date
();
expires
.
setMilliseconds
(
expires
.
getMilliseconds
()
+
attributes
.
expires
*
864
e
+
5
);
attributes
.
expires
=
expires
;
}
try
{
result
=
JSON
.
stringify
(
value
);
if
(
/^
[\{\[]
/
.
test
(
result
))
{
value
=
result
;
}
}
catch
(
e
)
{}
if
(
!
converter
.
write
)
{
value
=
encodeURIComponent
(
String
(
value
))
.
replace
(
/%
(
23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C
)
/g
,
decodeURIComponent
);
}
else
{
value
=
converter
.
write
(
value
,
key
);
}
key
=
encodeURIComponent
(
String
(
key
));
key
=
key
.
replace
(
/%
(
23|24|26|2B|5E|60|7C
)
/g
,
decodeURIComponent
);
key
=
key
.
replace
(
/
[\(\)]
/g
,
escape
);
return
(
document
.
cookie
=
[
key
,
'
=
'
,
value
,
attributes
.
expires
?
'
; expires=
'
+
attributes
.
expires
.
toUTCString
()
:
''
,
// use expires attribute, max-age is not supported by IE
attributes
.
path
?
'
; path=
'
+
attributes
.
path
:
''
,
attributes
.
domain
?
'
; domain=
'
+
attributes
.
domain
:
''
,
attributes
.
secure
?
'
; secure
'
:
''
].
join
(
''
));
}
// Read
if
(
!
key
)
{
result
=
{};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var
cookies
=
document
.
cookie
?
document
.
cookie
.
split
(
'
;
'
)
:
[];
var
rdecode
=
/
(
%
[
0-9A-Z
]{2})
+/g
;
var
i
=
0
;
for
(;
i
<
cookies
.
length
;
i
++
)
{
var
parts
=
cookies
[
i
].
split
(
'
=
'
);
var
cookie
=
parts
.
slice
(
1
).
join
(
'
=
'
);
if
(
cookie
.
charAt
(
0
)
===
'
"
'
)
{
cookie
=
cookie
.
slice
(
1
,
-
1
);
}
try
{
var
name
=
parts
[
0
].
replace
(
rdecode
,
decodeURIComponent
);
cookie
=
converter
.
read
?
converter
.
read
(
cookie
,
name
)
:
converter
(
cookie
,
name
)
||
cookie
.
replace
(
rdecode
,
decodeURIComponent
);
if
(
this
.
json
)
{
try
{
cookie
=
JSON
.
parse
(
cookie
);
}
catch
(
e
)
{}
}
if
(
key
===
name
)
{
result
=
cookie
;
break
;
}
if
(
!
key
)
{
result
[
name
]
=
cookie
;
}
}
catch
(
e
)
{}
}
return
result
;
}
api
.
set
=
api
;
api
.
get
=
function
(
key
)
{
return
api
.
call
(
api
,
key
);
};
api
.
getJSON
=
function
()
{
return
api
.
apply
({
json
:
true
},
[].
slice
.
call
(
arguments
));
};
api
.
defaults
=
{};
api
.
remove
=
function
(
key
,
attributes
)
{
api
(
key
,
''
,
extend
(
attributes
,
{
expires
:
-
1
}));
};
api
.
withConverter
=
init
;
return
api
;
}
return
init
(
function
()
{});
}));
\ No newline at end of file
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