Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
jio
Commits
80087264
Commit
80087264
authored
Nov 23, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complex example has been modified according to the new JIO API
parent
2b579525
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
78 deletions
+118
-78
examples/complex_example.html
examples/complex_example.html
+118
-78
No files found.
examples/complex_example.html
View file @
80087264
...
@@ -42,8 +42,7 @@ var clearlog = function () {
...
@@ -42,8 +42,7 @@ var clearlog = function () {
};
};
//-->
//-->
</script>
</script>
<div
id=
"main"
>
<table
border=
"1"
style=
"width: 100%;"
>
<table>
<tr
style=
"font-style:italic;"
>
<tr
style=
"font-style:italic;"
>
<th>
simple storage
</th><th>
multi storage
</th><th>
distant storage
</th>
<th>
simple storage
</th><th>
multi storage
</th><th>
distant storage
</th>
<th>
conflict managing
</th><th>
custom storage description
</th>
<th>
conflict managing
</th><th>
custom storage description
</th>
...
@@ -73,7 +72,7 @@ var clearlog = function () {
...
@@ -73,7 +72,7 @@ var clearlog = function () {
<input
type=
"text"
id=
"conflictapp"
value=
"localapp"
placeholder=
"applicationname"
/><br
/>
<input
type=
"text"
id=
"conflictapp"
value=
"localapp"
placeholder=
"applicationname"
/><br
/>
</th>
</th>
<th
style=
"width:100%;"
>
<th
style=
"width:100%;"
>
<textarea
id=
"customstorage"
style=
"width:100
%;"
>
{
"
type
"
:
"
local
"
,
"
username
"
:
"
customuser
"
,
"
applicationname
"
:
"
customapp
"
,
"
customkey
"
:
"
customvalue
"
}
</textarea>
<textarea
id=
"customstorage"
style=
"width:98
%;"
>
{
"
type
"
:
"
local
"
,
"
username
"
:
"
customuser
"
,
"
applicationname
"
:
"
customapp
"
,
"
customkey
"
:
"
customvalue
"
}
</textarea>
</th>
</th>
</tr>
</tr>
<tr>
<tr>
...
@@ -84,34 +83,56 @@ var clearlog = function () {
...
@@ -84,34 +83,56 @@ var clearlog = function () {
<th><button
onclick=
"newCustomJio()"
>
Create New jIO
</button></th>
<th><button
onclick=
"newCustomJio()"
>
Create New jIO
</button></th>
</tr>
</tr>
</table>
</table>
</div>
<hr
/>
<input
type=
"text"
id=
"filepath"
value=
""
placeholder=
"filepath"
/>
<input
type=
"text"
id=
"content"
value=
""
placeholder=
"content"
/>
<input
type=
"text"
id=
"prev_rev"
value=
""
placeholder=
"previous revision"
/>
<br
/>
<br
/>
<table
border=
"1"
style=
"width: 100%;"
>
<tr>
<td
style=
"width: 50%;"
>
<label
for=
"metadata"
>
Metadata or document id:
</label>
<textarea
id=
"metadata"
rows=
"3"
style=
"width: 98%;"
>
{}
</textarea>
</td>
<td
style=
"width: 50%;"
>
<label
for=
"document_id"
>
Document Id:
</label>
<input
type=
"text"
id=
"document_id"
value=
""
/>
<label
for=
"mimetype"
>
Mime Type:
</label>
<input
type=
"text"
id=
"mimetype"
value=
""
/><br
/>
<label
for=
"content"
>
Content:
</label>
<textarea
id=
"content"
rows=
"3"
style=
"width: 98%;"
></textarea><br
/>
</td>
</tr>
<tr>
<td
colspan=
"2"
style=
"text-align: center;"
>
<label
for=
"prev_rev"
>
Previous revision:
</label>
<input
type=
"text"
id=
"prev_rev"
value=
""
style=
"width: 40em;"
/><br
/>
<label
for=
"show_conflicts"
>
Show Conflicts
</label>
<label
for=
"show_conflicts"
>
Show Conflicts
</label>
<input
type=
"checkbox"
id=
"show_conflicts"
/>
,
<input
type=
"checkbox"
id=
"show_conflicts"
/>
,
<label
for=
"show_revision_history"
>
Show Revision History
</label>
<label
for=
"show_revision_history"
>
Show Revision History
</label>
<input
type=
"checkbox"
id=
"show_revision_history"
/>
,
<input
type=
"checkbox"
id=
"show_revision_history"
/>
,
<label
for=
"show_revision_info"
>
Show Revision Info
</label>
<label
for=
"show_revision_info"
>
Show Revision Info
</label>
<input
type=
"checkbox"
id=
"show_revision_info"
/>
,
<input
type=
"checkbox"
id=
"show_revision_info"
/>
,
<br
/>
<label
for=
"last_revision"
>
Remove Last Revision
</label>
<input
type=
"checkbox"
id=
"last_revision"
/>
,
<br
/>
<label
for=
"max_retry"
>
Max Retry
</label>
<label
for=
"max_retry"
>
Max Retry
</label>
<input
type=
"number"
id=
"max_retry"
value=
"0"
style=
"width:30px;"
/>
<input
type=
"number"
id=
"max_retry"
value=
"0"
style=
"width:30px;"
/>
(0 = infinite),
(0 = infinite)
<label
for=
"metadata_only"
>
Metadata Only
</label>
</td>
<input
type=
"checkbox"
id=
"metadata_only"
/>
</tr>
<hr
/>
<tr>
<td
style=
"text-align: center;"
>
<button
onclick=
"post()"
>
post
</button>
<button
onclick=
"post()"
>
post
</button>
<button
onclick=
"put()"
>
put
</button>
<button
onclick=
"put()"
>
put
</button>
<button
onclick=
"get()"
>
get
</button>
<button
onclick=
"get()"
>
get
</button>
<button
onclick=
"remove()"
>
remove
</button>
<button
onclick=
"remove()"
>
remove
</button>
<button
onclick=
"allDocs()"
>
allDocs
</button><br
/>
<button
onclick=
"allDocs()"
>
allDocs
</button>
</td>
<td
style=
"text-align: center;"
>
<button
onclick=
"putAttachment()"
>
putAttachment
</button>
</td>
</tr>
</table>
<br
/>
<div
style=
"text-align: center;"
>
<button
onclick=
"printLocalStorage()"
>
print localStorage
</button>
<button
onclick=
"printLocalStorage()"
>
print localStorage
</button>
<button
onclick=
"localStorage.clear()"
>
clear localStorage
</button><br
/>
<button
onclick=
"localStorage.clear()"
>
clear localStorage
</button><br
/>
<button
onclick=
"clearlog()"
>
Clear Log
</button>
<button
onclick=
"clearlog()"
>
Clear Log
</button>
</div>
<hr
/>
<hr
/>
<div
id=
"log"
>
<div
id=
"log"
>
</div>
</div>
...
@@ -195,7 +216,7 @@ var callback = function (err,val,begin_date) {
...
@@ -195,7 +216,7 @@ var callback = function (err,val,begin_date) {
log
(
'
return :
'
+
JSON
.
stringify
(
val
));
log
(
'
return :
'
+
JSON
.
stringify
(
val
));
};
};
var
command
=
function
(
method
)
{
var
command
=
function
(
method
)
{
var
begin_date
=
Date
.
now
(),
doc
=
{},
opts
=
{};
var
begin_date
=
Date
.
now
(),
doc
=
{},
opts
=
{}
,
other
=
{}
;
log
(
method
);
log
(
method
);
if
(
!
my_jio
)
{
if
(
!
my_jio
)
{
return
error
(
'
no jio set
'
);
return
error
(
'
no jio set
'
);
...
@@ -205,27 +226,35 @@ var command = function (method) {
...
@@ -205,27 +226,35 @@ var command = function (method) {
opts
.
revs
=
$
(
'
#show_revision_history
'
).
attr
(
'
checked
'
)?
true
:
false
;
opts
.
revs
=
$
(
'
#show_revision_history
'
).
attr
(
'
checked
'
)?
true
:
false
;
opts
.
revs_info
=
$
(
'
#show_revision_info
'
).
attr
(
'
checked
'
)?
true
:
false
;
opts
.
revs_info
=
$
(
'
#show_revision_info
'
).
attr
(
'
checked
'
)?
true
:
false
;
opts
.
max_retry
=
parseInt
(
$
(
'
#max_retry
'
).
attr
(
'
value
'
)
||
'
0
'
);
opts
.
max_retry
=
parseInt
(
$
(
'
#max_retry
'
).
attr
(
'
value
'
)
||
'
0
'
);
opts
.
metadata_only
=
$
(
'
#metadata_only
'
).
attr
(
'
checked
'
)?
true
:
false
;
switch
(
method
)
{
switch
(
method
)
{
case
'
putAttachment
'
:
other
.
docid
=
$
(
'
#document_id
'
).
attr
(
'
value
'
);
other
.
revision
=
$
(
'
#prev_rev
'
).
attr
(
'
value
'
);
other
.
content
=
$
(
'
#content
'
).
attr
(
'
value
'
);
other
.
mimetype
=
$
(
'
#mimetype
'
).
attr
(
'
value
'
);
log
(
'
docid:
'
+
other
.
docid
);
log
(
'
revision:
'
+
other
.
revision
);
log
(
'
content:
'
+
other
.
content
);
log
(
'
mimetype:
'
+
other
.
mimetype
);
case
'
post
'
:
case
'
post
'
:
case
'
put
'
:
case
'
put
'
:
doc
.
content
=
$
(
'
#content
'
).
attr
(
'
value
'
);
doc
=
JSON
.
parse
(
$
(
'
#metadata
'
).
attr
(
'
value
'
));
doc
.
_id
=
$
(
'
#filepath
'
).
attr
(
'
value
'
);
log
(
'
doc:
'
+
JSON
.
stringify
(
doc
));
doc
.
_rev
=
$
(
'
#prev_rev
'
).
attr
(
'
value
'
)
||
undefined
;
break
;
break
;
case
'
remove
'
:
case
'
remove
'
:
doc
.
_id
=
$
(
'
#filepath
'
).
attr
(
'
value
'
);
doc
=
JSON
.
parse
(
$
(
'
#metadata
'
).
attr
(
'
value
'
)
);
opts
.
rev
=
(
$
(
'
#last_revision
'
).
attr
(
'
checked
'
)?
'
last
'
:
undefined
)
||
opts
.
rev
=
(
$
(
'
#last_revision
'
).
attr
(
'
checked
'
)?
'
last
'
:
undefined
)
||
$
(
'
#prev_rev
'
).
attr
(
'
value
'
)
||
undefined
;
$
(
'
#prev_rev
'
).
attr
(
'
value
'
)
||
undefined
;
log
(
'
doc:
'
+
JSON
.
stringify
(
doc
));
break
;
break
;
case
'
get
'
:
case
'
get
'
:
doc
=
$
(
'
#filepath
'
).
attr
(
'
value
'
);
doc
=
$
(
'
#metadata
'
).
attr
(
'
value
'
);
log
(
'
docid:
'
+
doc
)
case
'
allDocs
'
:
case
'
allDocs
'
:
break
;
break
;
}
}
log
(
'
doc:
'
+
JSON
.
stringify
(
doc
));
log
(
'
opts:
'
+
JSON
.
stringify
(
opts
));
log
(
'
opts:
'
+
JSON
.
stringify
(
opts
));
switch
(
method
)
{
switch
(
method
)
{
...
@@ -242,6 +271,14 @@ var command = function (method) {
...
@@ -242,6 +271,14 @@ var command = function (method) {
callback
(
err
,
val
,
begin_date
);
callback
(
err
,
val
,
begin_date
);
});
});
break
;
break
;
case
'
putAttachment
'
:
my_jio
[
method
](
other
.
docid
,
other
.
revision
,
other
.
content
,
other
.
mimetype
,
opts
,
function
(
err
,
val
)
{
callback
(
err
,
val
,
begin_date
);
}
);
break
;
}
}
};
};
var
post
=
function
()
{
var
post
=
function
()
{
...
@@ -258,7 +295,10 @@ var remove = function () {
...
@@ -258,7 +295,10 @@ var remove = function () {
};
};
var
allDocs
=
function
()
{
var
allDocs
=
function
()
{
command
(
'
allDocs
'
);
command
(
'
allDocs
'
);
}
};
var
putAttachment
=
function
()
{
command
(
'
putAttachment
'
);
};
//-->
//-->
</script>
</script>
</body>
</body>
...
...
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