add example usage for cryptget.js

This commit is contained in:
ansuz 2016-12-19 12:25:36 +01:00
parent df9f408823
commit 2a624a0b60
2 changed files with 58 additions and 0 deletions

35
www/read/index.html Normal file
View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script data-main="main" src="/bower_components/requirejs/require.js"></script>
<script>
require.config({
waitSeconds: 60,
});
</script>
<link rel="icon" type="image/png"
href="/customize/main-favicon.png"
data-main-favicon="/customize/main-favicon.png"
data-alt-favicon="/customize/alt-favicon.png"
id="favicon" />
<style>
input {
width: 50vw;
padding: 15px;
}
pre {
max-width: 90vw;
overflow: auto;
}
</style>
</head>
<body>
<input id="target" type="text" value="/1/edit/xvhI6k6n7qYEtNL8cAv5zw/a4KKGGDY0S8GDj6m9iumX5E4"></input>
<button id="get">get</button>
<!-- <p>/1/edit/xvhI6k6n7qYEtNL8cAv5zw/a4KKGGDY0S8GDj6m9iumX5E4</p> -->
<pre id="dest"></pre>

23
www/read/main.js Normal file
View file

@ -0,0 +1,23 @@
define([
'/common/cryptget.js',
'/bower_components/jquery/dist/jquery.min.js',
], function (Crypt) {
var $ = window.jQuery;
var $target = $('#target');
var $dest = $('#dest');
var useDoc = function (err, doc) {
if (err) { return console.error(err); }
console.log(doc);
$dest.text(doc);
};
$('#get').click(function () {
var val = $target.val();
if (!val.trim()) { return; }
Crypt.get(val, useDoc);
});
if (window.location.hash) { Crypt.get(void 0, useDoc); }
});