From 590e67610bc0fd1b0a1f8da17e3a55e6631c4442 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 30 May 2011 13:36:17 -0700 Subject: [PATCH] UI: clean up js files. camli.js is common, rest are page-specific. --- server/go/camlistored/ui/{ui.js => camli.js} | 34 +++---------------- server/go/camlistored/ui/disco.html | 22 +++++++++++- server/go/camlistored/ui/index.html | 3 +- server/go/camlistored/ui/index.js | 35 ++++++++++++++++++++ server/go/camlistored/ui/permanode.html | 14 ++------ server/go/camlistored/ui/permanode.js | 7 ++++ server/go/camlistored/ui/search.html | 2 +- server/go/camlistored/ui/signing.html | 2 +- 8 files changed, 74 insertions(+), 45 deletions(-) rename server/go/camlistored/ui/{ui.js => camli.js} (81%) create mode 100644 server/go/camlistored/ui/index.js diff --git a/server/go/camlistored/ui/ui.js b/server/go/camlistored/ui/camli.js similarity index 81% rename from server/go/camlistored/ui/ui.js rename to server/go/camlistored/ui/camli.js index 084eeeb4e..e7333c852 100644 --- a/server/go/camlistored/ui/ui.js +++ b/server/go/camlistored/ui/camli.js @@ -22,22 +22,6 @@ function onConfiguration(conf) { console.log("Got config: " + JSON.stringify(conf)); } -// Or get configuration info like this: -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; - } - disco = JSON.parse(xhr.responseText); - document.getElementById("discores").innerHTML = JSON.stringify(disco); - }; - xhr.open("GET", "./?camli.mode=config", true); - xhr.send(); -} - function saneOpts(opts) { if (!opts) { opts = {} @@ -152,7 +136,8 @@ function camliUploadString(s, opts) { xhr.send(fd); } -function createNewPermanode() { +function camliCreateNewPermanode(opts) { + opts = saneOpts(opts); var json = { "camliVersion": 1, "camliType": "permanode", @@ -163,12 +148,9 @@ function createNewPermanode() { camliUploadString( got, { - success: function(blobref) { - // alert("uploaded permanode blobref: " + blobref); - window.location = "./?p=" + blobref; - }, + success: opts.success, fail: function(msg) { - alert("upload permanode fail: " + msg); + opts.fail("upload permanode fail: " + msg); } }); }, @@ -178,11 +160,3 @@ function createNewPermanode() { }); } -function camliOnload(e) { - var btnNew = document.getElementById("btnNew"); - if (btnNew) { - btnNew.addEventListener("click", createNewPermanode); - } -} - -window.addEventListener("load", camliOnload); diff --git a/server/go/camlistored/ui/disco.html b/server/go/camlistored/ui/disco.html index f2c990453..ce293731d 100644 --- a/server/go/camlistored/ui/disco.html +++ b/server/go/camlistored/ui/disco.html @@ -1,9 +1,29 @@ Camlistored UI - + +
diff --git a/server/go/camlistored/ui/index.html b/server/go/camlistored/ui/index.html index 53325a9ef..20baf7a95 100644 --- a/server/go/camlistored/ui/index.html +++ b/server/go/camlistored/ui/index.html @@ -4,7 +4,8 @@ - + +