4 changed files with 129 additions and 4 deletions
@ -0,0 +1,121 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet"> |
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> |
||||||
|
<title>NoteHub API Testing</title> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<script> |
||||||
|
function request(type, data) { |
||||||
|
$("#request").text(JSON.stringify(data)); |
||||||
|
$.ajax({ |
||||||
|
type: type, |
||||||
|
dataType: 'json', |
||||||
|
url: "/api/note", |
||||||
|
data: data, |
||||||
|
success: function(result){ |
||||||
|
$("#response").text(JSON.stringify(result)); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
function selectForm(name) { |
||||||
|
["#get", "#post", "#update"].forEach(function(elem){ |
||||||
|
if(name==elem) { |
||||||
|
$(elem + "-form").show(); |
||||||
|
$(elem + "-li").addClass("active"); |
||||||
|
} else { |
||||||
|
$(elem + "-form").hide() |
||||||
|
$(elem + "-li").removeClass("active"); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
function getNote(){ |
||||||
|
var data = { |
||||||
|
noteID: $("#get-noteID").val(), |
||||||
|
version: $("#version").val() |
||||||
|
}; |
||||||
|
request("GET", data); |
||||||
|
} |
||||||
|
function postNote(){ |
||||||
|
var data = { |
||||||
|
note: $("#post-note").val(), |
||||||
|
pid: $("#pid").val(), |
||||||
|
signature: $("#post-signature").val(), |
||||||
|
password: $("#post-password").val(), |
||||||
|
version: $("#version").val() |
||||||
|
}; |
||||||
|
request("POST", data); |
||||||
|
} |
||||||
|
function updateNote(){ |
||||||
|
var data = { |
||||||
|
noteID: $("#update-noteID").val(), |
||||||
|
note: $("#update-note").val(), |
||||||
|
pid: $("#pid").val(), |
||||||
|
signature: $("#update-signature").val(), |
||||||
|
password: $("#update-password").val(), |
||||||
|
version: $("#version").val() |
||||||
|
}; |
||||||
|
request("PUT", data); |
||||||
|
} |
||||||
|
</script> |
||||||
|
<div class="container"> |
||||||
|
<div class="page-header"> |
||||||
|
<h1>NoteHub API Testing</h1> |
||||||
|
</div> |
||||||
|
<label>PID</label> |
||||||
|
<input id="pid" type="text"> |
||||||
|
<label>PSK</label> |
||||||
|
<input id="psk" type="text"> |
||||||
|
<label>API version</label> |
||||||
|
<input id="version" type="text" value="1.3"> |
||||||
|
<br/> |
||||||
|
<ul class="nav nav-tabs"> |
||||||
|
<li id="get-li" class="active"><a href="javascript:selectForm('#get')">Get Note</a></li> |
||||||
|
<li id="post-li"><a href="javascript:selectForm('#post')">Post Note</a></li> |
||||||
|
<li id="update-li"><a href="javascript:selectForm('#update')">Update Note</a></li> |
||||||
|
</ul> |
||||||
|
<form id="get-form"> |
||||||
|
<fieldset> |
||||||
|
<label>noteID</label> |
||||||
|
<input id="get-noteID" type="text" value="2014/1/3/lorem-ipsum"> |
||||||
|
<br/> |
||||||
|
<a href="javascript:getNote()" class="btn">Submit</a> |
||||||
|
</fieldset> |
||||||
|
</form> |
||||||
|
<form id="post-form" style="display: none;"> |
||||||
|
<fieldset> |
||||||
|
<label>note</label> |
||||||
|
<textarea id="post-note"></textarea> |
||||||
|
<label>signature (md5 hash of pid + psk + note)</label> |
||||||
|
<input id="post-signature" type="text" value=""> |
||||||
|
<label>password</label> |
||||||
|
<input id="post-password" type="text" value=""> |
||||||
|
<br/> |
||||||
|
<a href="javascript:postNote()" class="btn">Submit</a> |
||||||
|
</fieldset> |
||||||
|
</form> |
||||||
|
<form id="update-form" style="display: none;"> |
||||||
|
<fieldset> |
||||||
|
<label>noteID</label> |
||||||
|
<input id="update-noteID" type="text" value=""> |
||||||
|
<label>note</label> |
||||||
|
<textarea id="update-note"></textarea> |
||||||
|
<label>password</label> |
||||||
|
<input id="update-password" type="text" value=""> |
||||||
|
<label>signature (md5 of pid + psk + noteID + note + password)</label> |
||||||
|
<input id="update-signature" type="text" value=""> |
||||||
|
<br/> |
||||||
|
<a href="javascript:updateNote()" class="btn">Submit</a> |
||||||
|
</fieldset> |
||||||
|
</form> |
||||||
|
<h4>Request</h4> |
||||||
|
<pre id="request" class="prettyprint linenums"> |
||||||
|
</pre> |
||||||
|
<h4>Response</h4> |
||||||
|
<pre id="response" class="prettyprint linenums"> |
||||||
|
</pre> |
||||||
|
</div> |
||||||
|
</body> |
||||||
|
</html> |
||||||
Loading…
Reference in new issue