Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
17
Merge Requests
17
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
e5ff2cc2
Commit
e5ff2cc2
authored
May 03, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authentication added when send request to REST API
parent
d0b7358f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
118 deletions
+136
-118
jQuery/static/js/slapOs.js
jQuery/static/js/slapOs.js
+136
-118
No files found.
jQuery/static/js/slapOs.js
View file @
e5ff2cc2
;(
function
(
$
)
{
;(
function
(
$
)
{
var
methods
=
{
var
methods
=
{
defaults
:
{
host
:
''
},
init
:
function
(
options
){
init
:
function
(
options
){
var
settings
=
$
.
extend
({
var
settings
=
$
.
extend
({
'
host
'
:
''
'
host
'
:
''
,
'
access_token
'
:
''
,
'
clientID
'
:
''
},
options
);
},
options
);
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
methods
[
'
store
'
]
=
Modernizr
.
localstorage
?
methods
.
lStore
:
methods
.
cStore
;
methods
[
'
store
'
]
=
Modernizr
.
localstorage
?
methods
.
lStore
:
methods
.
cStore
;
$
(
this
).
slapos
(
'
store
'
,
'
host
'
,
settings
.
host
);
for
(
var
setting
in
settings
){
$
(
this
).
slapos
(
'
store
'
,
setting
,
settings
[
setting
]);
}
});
});
},
},
/* Getters & Setters shortcuts */
access_token
:
function
(
value
){
return
$
(
this
).
slapos
(
'
store
'
,
'
access_token
'
,
value
);
},
host
:
function
(
value
){
return
$
(
this
).
slapos
(
'
store
'
,
'
host
'
,
value
);
},
clientID
:
function
(
value
){
return
$
(
this
).
slapos
(
'
store
'
,
'
clientID
'
,
value
);
},
/* Local storage method */
/* Local storage method */
lStore
:
function
(
name
,
value
)
{
lStore
:
function
(
name
,
value
)
{
if
(
Modernizr
.
localstorage
)
if
(
Modernizr
.
localstorage
)
return
value
==
undefined
?
window
.
localStorage
[
name
]
:
window
.
localStorage
[
name
]
=
value
;
return
value
==
undefined
?
window
.
localStorage
[
name
]
:
window
.
localStorage
[
name
]
=
value
;
return
false
;
return
false
;
...
@@ -44,16 +55,23 @@
...
@@ -44,16 +55,23 @@
}
}
},
},
request
:
function
(
type
,
url
,
callback
,
statusEvent
,
data
)
{
request
:
function
(
type
,
url
,
callback
,
statusEvent
,
data
)
{
data
=
data
||
''
;
data
=
data
||
''
;
statusEvent
=
statusEvent
||
this
.
statusDefault
;
statusEvent
=
statusEvent
||
this
.
statusDefault
;
return
this
.
each
(
function
(){
return
this
.
each
(
function
(){
$
.
ajax
({
$
.
ajax
({
url
:
methods
.
store
(
'
host
'
)
+
url
,
url
:
"
http://
"
+
$
(
this
).
slapos
(
'
host
'
)
+
url
,
type
:
type
,
contentType
:
'
application/octet-stream
'
,
data
:
JSON
.
stringify
(
data
),
dataType
:
'
json
'
,
dataType
:
'
json
'
,
data
:
data
,
context
:
$
(
this
),
context
:
$
(
this
),
type
:
type
,
beforeSend
:
function
(
xhr
){
if
(
$
(
this
).
slapos
(
"
access_token
"
)
)
{
xhr
.
setRequestHeader
(
"
Authorization
"
,
$
(
this
).
slapos
(
"
store
"
,
"
token_type
"
)
+
"
"
+
$
(
this
).
slapos
(
"
access_token
"
));
xhr
.
setRequestHeader
(
"
Accept
"
,
"
application/json
"
);
}
},
statusCode
:
statusEvent
,
statusCode
:
statusEvent
,
success
:
callback
success
:
callback
});
});
...
@@ -61,7 +79,7 @@
...
@@ -61,7 +79,7 @@
},
},
newInstance
:
function
(
data
,
callback
,
statusEvent
){
newInstance
:
function
(
data
,
callback
,
statusEvent
){
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/request
'
,
callback
,
statusEvent
,
data
);
return
$
(
this
).
slapos
(
'
request
'
,
'
POST
'
,
'
/instance
'
,
callback
,
statusEvent
,
data
);
},
},
deleteInstance
:
function
(
id
,
callback
,
statusEvent
){
deleteInstance
:
function
(
id
,
callback
,
statusEvent
){
...
...
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