Commit c048fd03 authored by Tristan Cavelier's avatar Tristan Cavelier

Complex Example updated

parent 32db8461
...@@ -86,45 +86,33 @@ var clearlog = function () { ...@@ -86,45 +86,33 @@ var clearlog = function () {
<br /> <br />
<table border="1" style="width: 100%;"> <table border="1" style="width: 100%;">
<tr> <tr>
<td style="width: 50%;"> <td colspan="1" style="width: 50%;">
<label for="metadata">Metadata or document id:</label> <label for="metadata">Metadata or document id:</label>
<textarea id="metadata" rows="3" style="width: 98%;">{}</textarea> <textarea id="metadata" rows="3" style="width: 98%;">{}</textarea>
</td> </td>
<td style="width: 50%;"> <td colspan="1" style="text-align: center;">
<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;">
Options:<br /> Options:<br />
<label for="prev_rev">Previous revision:</label> <label for="show_conflicts">Get Conflicts</label>
<input type="text" id="prev_rev" value="" style="width: 40em;"/><br /> <input type="checkbox" id="show_conflicts" /><br />
<label for="show_conflicts">Show Conflicts</label> <label for="show_revision_history">Get Revision History</label>
<input type="checkbox" id="show_conflicts" />, <input type="checkbox" id="show_revision_history" /><br />
<label for="show_revision_history">Show Revision History</label> <label for="show_revision_info">Get Revision Info</label>
<input type="checkbox" id="show_revision_history" />, <input type="checkbox" id="show_revision_info" /><br />
<label for="show_revision_info">Show Revision Info</label>
<input type="checkbox" id="show_revision_info" />,<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)
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="text-align: center;"> <td colspan="2" 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> <button onclick="allDocs()">allDocs</button>
</td> <!-- </td> -->
<td style="text-align: center;"> <!-- <td style="text-align: center;"> -->
<button onclick="putAttachment()">putAttachment</button> - <button onclick="putAttachment()">putAttachment</button>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -233,50 +221,13 @@ var command = function (method) { ...@@ -233,50 +221,13 @@ var command = function (method) {
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');
switch (method) { doc = JSON.parse ($('#metadata').attr('value'));
case 'putAttachment': log ('doc: ' + JSON.stringify (doc));
doc.id = $('#document_id').attr('value');
doc.rev = $('#prev_rev').attr('value');
doc.data = $('#content').attr('value');
doc.mimetype = $('#mimetype').attr('value');
log ('attachment: '+ JSON.stringify (doc));
break;
case 'post':
case 'put':
doc = JSON.parse ($('#metadata').attr('value'));
log ('doc: ' + JSON.stringify (doc));
break;
case 'remove':
doc = JSON.parse ($('#metadata').attr('value'));
opts.rev = ($('#last_revision').attr('checked')?'last':undefined) ||
$('#prev_rev').attr('value') || undefined;
log ('doc: ' + JSON.stringify (doc));
break;
case 'get':
doc = $('#metadata').attr('value');
log ('docid: '+ doc)
case 'allDocs':
break;
}
log ('opts: ' + JSON.stringify (opts)); log ('opts: ' + JSON.stringify (opts));
switch (method) { my_jio[method](doc,opts,function (err,val) {
case "putAttachment": callback(err,val,begin_date);
case 'remove': });
case 'post':
case 'put':
case 'get':
my_jio[method](doc,opts,function (err,val) {
callback(err,val,begin_date);
});
break;
case 'allDocs':
my_jio[method](opts,function (err,val) {
callback(err,val,begin_date);
});
break;
}
}; };
var post = function () { var post = function () {
command('post'); command('post');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment