Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
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
0
Merge Requests
0
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
Aurélien Vermylen
jio
Commits
4fe2c534
Commit
4fe2c534
authored
Mar 18, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jio dashboard function made promise based
parent
13c35ce3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
27 deletions
+31
-27
examples/jio_dashboard.html
examples/jio_dashboard.html
+31
-27
No files found.
examples/jio_dashboard.html
View file @
4fe2c534
...
...
@@ -272,19 +272,24 @@ function printLocalStorage() {
log
(
"
localStorage content
\n
"
+
JSON
.
stringify
(
localStorage
,
null
,
"
"
));
}
function
callback
(
err
,
val
,
begin_date
)
{
function
logError
(
begin_date
,
err
)
{
log
(
'
time :
'
+
(
Date
.
now
()
-
begin_date
));
error
(
'
return :
'
+
JSON
.
stringify
(
err
,
null
,
"
"
));
throw
err
;
}
function
logAnswer
(
begin_date
,
val
)
{
log
(
'
time :
'
+
(
Date
.
now
()
-
begin_date
));
if
(
err
)
{
return
error
(
'
return :
'
+
JSON
.
stringify
(
err
,
null
,
"
"
));
}
log
(
'
return :
'
+
JSON
.
stringify
(
val
,
null
,
"
"
));
return
val
;
}
function
command
(
method
,
num
)
{
var
begin_date
=
Date
.
now
(),
doc
=
{},
opts
=
{};
if
(
!
my_jio
)
{
return
error
(
'
no jio set
'
);
error
(
'
no jio set
'
);
return
;
}
doc
=
select
(
'
#metadata
'
).
value
;
...
...
@@ -302,22 +307,20 @@ function command(method, num) {
'
\n
opts:
'
+
JSON
.
stringify
(
opts
,
null
,
"
"
));
if
(
method
===
"
allDocs
"
)
{
my_jio
.
allDocs
(
opts
).
then
(
function
(
answer
)
{
callback
(
undefined
,
answer
,
begin_date
);
},
function
(
error
)
{
callback
(
error
,
undefined
,
begin_date
);
});
return
my_jio
.
allDocs
(
opts
).
then
(
logAnswer
.
bind
(
null
,
begin_date
),
logError
.
bind
(
null
,
begin_date
)
);
}
else
{
my_jio
[
method
](
doc
,
opts
).
then
(
function
(
answer
)
{
callback
(
undefined
,
answer
,
begin_date
);
},
function
(
error
)
{
callback
(
error
,
undefined
,
begin_date
);
});
return
my_jio
[
method
](
doc
,
opts
).
then
(
logAnswer
.
bind
(
null
,
begin_date
),
logError
.
bind
(
null
,
begin_date
)
);
}
}
function
doCommandNTimes
(
method
)
{
var
i
=
-
1
,
n
=
0
,
lock
;
var
i
=
-
1
,
n
=
0
,
lock
,
promise_list
=
[]
;
n
=
parseInt
(
select
(
"
#times
"
).
value
,
10
);
lock
=
select
(
"
#times-lock
"
).
checked
;
if
(
!
lock
)
{
...
...
@@ -327,39 +330,40 @@ function doCommandNTimes(method) {
n
=
1
;
}
while
(
++
i
<
n
)
{
command
(
method
,
i
);
promise_list
.
push
(
command
(
method
,
i
)
);
}
return
RSVP
.
all
(
promise_list
);
}
function
post
()
{
doCommandNTimes
(
"
post
"
);
return
doCommandNTimes
(
"
post
"
);
}
function
put
()
{
doCommandNTimes
(
"
put
"
);
return
doCommandNTimes
(
"
put
"
);
}
function
get
()
{
doCommandNTimes
(
"
get
"
);
return
doCommandNTimes
(
"
get
"
);
}
function
remove
()
{
doCommandNTimes
(
"
remove
"
);
return
doCommandNTimes
(
"
remove
"
);
}
function
putAttachment
()
{
doCommandNTimes
(
"
putAttachment
"
);
return
doCommandNTimes
(
"
putAttachment
"
);
}
function
getAttachment
()
{
doCommandNTimes
(
"
getAttachment
"
);
return
doCommandNTimes
(
"
getAttachment
"
);
}
function
removeAttachment
()
{
doCommandNTimes
(
"
removeAttachment
"
);
return
doCommandNTimes
(
"
removeAttachment
"
);
}
function
allDocs
()
{
doCommandNTimes
(
"
allDocs
"
);
return
doCommandNTimes
(
"
allDocs
"
);
}
function
check
()
{
doCommandNTimes
(
"
check
"
);
return
doCommandNTimes
(
"
check
"
);
}
function
repair
()
{
doCommandNTimes
(
"
repair
"
);
return
doCommandNTimes
(
"
repair
"
);
}
//-->
</script>
...
...
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