start of javascript search

This commit is contained in:
Brad Fitzpatrick 2011-04-16 16:26:59 -07:00
parent 6601225738
commit 82c88af49d
2 changed files with 27 additions and 8 deletions

View File

@ -1,15 +1,17 @@
<html>
<head>
<title>Camlistored UI</title>
<script src='ui.js'></script>
<script src="ui.js"></script>
</head>
<body>
<h1>Camlistored UI</h1>
<h1>Camlistored UI</h1>
<form>
<input type='button' id='discobtn' onclick='discover()' value="Do Discovery" />
</form>
<form>
<p><input type="button" id="discobtn" onclick="discover()" value="Do Discovery" /></p>
<div id="discores" style="border: 2px solid gray">(discovery results)</div>
<p><input type="button" id="searchbtn" onclick="search()" value="Do Search" /></p>
<div id="searchres" style="border: 2px solid gray">(search results)</div>
</form>
</body>
</html>

View File

@ -14,16 +14,33 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
var disco = null;
function discover() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4) { return; }
if (xhr.status != 200) {
console.log("no status 200; got " + xhr.status);
return;
}
var disco = JSON.parse(xhr.responseText);
alert(JSON.stringify(disco));
disco = JSON.parse(xhr.responseText);
document.getElementById("discores").innerHTML = JSON.stringify(disco);
};
xhr.open("GET", "./?camli.mode=config", true);
xhr.send();
}
function search() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState != 4) { return; }
if (xhr.status != 200) {
console.log("no status 200; got " + xhr.status);
return;
}
document.getElementById("searchres").innerHTML = "<pre>" + xhr.responseText + "</pre>";
};
xhr.open("GET", disco.searchRoot + "camli/search", true);
xhr.send();
}