mirror of https://github.com/perkeep/perkeep.git
UI: clean up js files. camli.js is common, rest are page-specific.
This commit is contained in:
parent
5c7e645e7a
commit
590e67610b
|
@ -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);
|
|
@ -1,9 +1,29 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Camlistored UI</title>
|
||||
<script src="ui.js"></script>
|
||||
<script src="camli.js"></script>
|
||||
<script src="sigdebug.js"></script>
|
||||
<script src="./?camli.mode=config&cb=onConfiguration"></script>
|
||||
<script>
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
<script type="text/javascript" src="base64.js"></script>
|
||||
<script type="text/javascript" src="Crypto.js"></script>
|
||||
<script type="text/javascript" src="SHA1.js"></script>
|
||||
<script src="ui.js"></script>
|
||||
<script src="camli.js"></script>
|
||||
<script src="index.js"></script>
|
||||
<script src="?camli.mode=config&cb=onConfiguration"></script>
|
||||
<style>
|
||||
#btnnew {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Copyright 2011 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
function btnCreateNewPermanode(e) {
|
||||
camliCreateNewPermanode(
|
||||
{
|
||||
success: function(blobref) {
|
||||
window.location = "./?p=" + blobref;
|
||||
},
|
||||
fail: function(msg) {
|
||||
alert("create permanode failed: " + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("load", function (e) {
|
||||
var btnNew = document.getElementById("btnNew");
|
||||
if (!btnNew) {
|
||||
alert("missing btnNew");
|
||||
}
|
||||
btnNew.addEventListener("click", btnCreateNewPermanode);
|
||||
});
|
|
@ -1,19 +1,11 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Permanode</title>
|
||||
<script src="ui.js"></script>
|
||||
<script src="?camli.mode=config&cb=onConfiguration"></script>
|
||||
<script type="text/javascript" src="camli.js"></script>
|
||||
<script type="text/javascript" src="?camli.mode=config&cb=onConfiguration"></script>
|
||||
<script type="text/javascript" src="permanode.js"></script>
|
||||
<script type="text/javascript">
|
||||
function fillPage() {
|
||||
var permanode = getPermanodeParam();
|
||||
if (permanode) {
|
||||
document.getElementById('permanode').innerText = permanode;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="fillPage();">
|
||||
<body>
|
||||
<h1>Permanode</h1>
|
||||
<form>
|
||||
<p>Name: <input type="inputName" size="30" value="(loading)" disabled="true" />
|
||||
|
|
|
@ -36,3 +36,10 @@ function getPermanodeParam() {
|
|||
var blobRef = getQueryParam('p');
|
||||
return (blobRef && isPlausibleBlobRef(blobRef)) ? blobRef : null;
|
||||
}
|
||||
|
||||
window.addEventListener("load", function (e) {
|
||||
var permanode = getPermanodeParam();
|
||||
if (permanode) {
|
||||
document.getElementById('permanode').innerText = permanode;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Camlistored UI</title>
|
||||
<script src="ui.js"></script>
|
||||
<script src="camli.js"></script>
|
||||
<script src="?camli.mode=config&cb=onConfiguration"></script>
|
||||
<script src="search.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Camlistored UI</title>
|
||||
<script src="ui.js"></script>
|
||||
<script src="camli.js"></script>
|
||||
<script src="sigdebug.js"></script>
|
||||
<script src="./?camli.mode=config&cb=onConfiguration"></script>
|
||||
</head>
|
||||
|
|
Loading…
Reference in New Issue