From 82c88af49d62547369ad61a3b4549f88f7411560 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 16 Apr 2011 16:26:59 -0700 Subject: [PATCH] start of javascript search --- server/go/camlistored/ui/index.html | 14 ++++++++------ server/go/camlistored/ui/ui.js | 21 +++++++++++++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/server/go/camlistored/ui/index.html b/server/go/camlistored/ui/index.html index 61b721f2b..7137b8f9c 100644 --- a/server/go/camlistored/ui/index.html +++ b/server/go/camlistored/ui/index.html @@ -1,15 +1,17 @@ Camlistored UI - + +

Camlistored UI

-

Camlistored UI

- -
- -
+
+

+
(discovery results)
+

+
(search results)
+
diff --git a/server/go/camlistored/ui/ui.js b/server/go/camlistored/ui/ui.js index c9c5dedf6..0b3598b63 100644 --- a/server/go/camlistored/ui/ui.js +++ b/server/go/camlistored/ui/ui.js @@ -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 = "
" + xhr.responseText + "
"; + }; + xhr.open("GET", disco.searchRoot + "camli/search", true); + xhr.send(); +}