Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
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() {
...
@@ -272,19 +272,24 @@ function printLocalStorage() {
log
(
"
localStorage content
\n
"
+
JSON
.
stringify
(
localStorage
,
null
,
"
"
));
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
));
log
(
'
time :
'
+
(
Date
.
now
()
-
begin_date
));
if
(
err
)
{
return
error
(
'
return :
'
+
JSON
.
stringify
(
err
,
null
,
"
"
));
}
log
(
'
return :
'
+
JSON
.
stringify
(
val
,
null
,
"
"
));
log
(
'
return :
'
+
JSON
.
stringify
(
val
,
null
,
"
"
));
return
val
;
}
}
function
command
(
method
,
num
)
{
function
command
(
method
,
num
)
{
var
begin_date
=
Date
.
now
(),
doc
=
{},
opts
=
{};
var
begin_date
=
Date
.
now
(),
doc
=
{},
opts
=
{};
if
(
!
my_jio
)
{
if
(
!
my_jio
)
{
return
error
(
'
no jio set
'
);
error
(
'
no jio set
'
);
return
;
}
}
doc
=
select
(
'
#metadata
'
).
value
;
doc
=
select
(
'
#metadata
'
).
value
;
...
@@ -302,22 +307,20 @@ function command(method, num) {
...
@@ -302,22 +307,20 @@ function command(method, num) {
'
\n
opts:
'
+
JSON
.
stringify
(
opts
,
null
,
"
"
));
'
\n
opts:
'
+
JSON
.
stringify
(
opts
,
null
,
"
"
));
if
(
method
===
"
allDocs
"
)
{
if
(
method
===
"
allDocs
"
)
{
my_jio
.
allDocs
(
opts
).
then
(
function
(
answer
)
{
return
my_jio
.
allDocs
(
opts
).
then
(
callback
(
undefined
,
answer
,
begin_date
);
logAnswer
.
bind
(
null
,
begin_date
),
},
function
(
error
)
{
logError
.
bind
(
null
,
begin_date
)
callback
(
error
,
undefined
,
begin_date
);
);
});
}
else
{
}
else
{
my_jio
[
method
](
doc
,
opts
).
then
(
function
(
answer
)
{
return
my_jio
[
method
](
doc
,
opts
).
then
(
callback
(
undefined
,
answer
,
begin_date
);
logAnswer
.
bind
(
null
,
begin_date
),
},
function
(
error
)
{
logError
.
bind
(
null
,
begin_date
)
callback
(
error
,
undefined
,
begin_date
);
);
});
}
}
}
}
function
doCommandNTimes
(
method
)
{
function
doCommandNTimes
(
method
)
{
var
i
=
-
1
,
n
=
0
,
lock
;
var
i
=
-
1
,
n
=
0
,
lock
,
promise_list
=
[]
;
n
=
parseInt
(
select
(
"
#times
"
).
value
,
10
);
n
=
parseInt
(
select
(
"
#times
"
).
value
,
10
);
lock
=
select
(
"
#times-lock
"
).
checked
;
lock
=
select
(
"
#times-lock
"
).
checked
;
if
(
!
lock
)
{
if
(
!
lock
)
{
...
@@ -327,39 +330,40 @@ function doCommandNTimes(method) {
...
@@ -327,39 +330,40 @@ function doCommandNTimes(method) {
n
=
1
;
n
=
1
;
}
}
while
(
++
i
<
n
)
{
while
(
++
i
<
n
)
{
command
(
method
,
i
);
promise_list
.
push
(
command
(
method
,
i
)
);
}
}
return
RSVP
.
all
(
promise_list
);
}
}
function
post
()
{
function
post
()
{
doCommandNTimes
(
"
post
"
);
return
doCommandNTimes
(
"
post
"
);
}
}
function
put
()
{
function
put
()
{
doCommandNTimes
(
"
put
"
);
return
doCommandNTimes
(
"
put
"
);
}
}
function
get
()
{
function
get
()
{
doCommandNTimes
(
"
get
"
);
return
doCommandNTimes
(
"
get
"
);
}
}
function
remove
()
{
function
remove
()
{
doCommandNTimes
(
"
remove
"
);
return
doCommandNTimes
(
"
remove
"
);
}
}
function
putAttachment
()
{
function
putAttachment
()
{
doCommandNTimes
(
"
putAttachment
"
);
return
doCommandNTimes
(
"
putAttachment
"
);
}
}
function
getAttachment
()
{
function
getAttachment
()
{
doCommandNTimes
(
"
getAttachment
"
);
return
doCommandNTimes
(
"
getAttachment
"
);
}
}
function
removeAttachment
()
{
function
removeAttachment
()
{
doCommandNTimes
(
"
removeAttachment
"
);
return
doCommandNTimes
(
"
removeAttachment
"
);
}
}
function
allDocs
()
{
function
allDocs
()
{
doCommandNTimes
(
"
allDocs
"
);
return
doCommandNTimes
(
"
allDocs
"
);
}
}
function
check
()
{
function
check
()
{
doCommandNTimes
(
"
check
"
);
return
doCommandNTimes
(
"
check
"
);
}
}
function
repair
()
{
function
repair
()
{
doCommandNTimes
(
"
repair
"
);
return
doCommandNTimes
(
"
repair
"
);
}
}
//-->
//-->
</script>
</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