better tools for playing with template code

This commit is contained in:
ansuz 2016-12-22 11:03:44 +01:00
parent 86cda4357b
commit 84d5e4b35d
2 changed files with 19 additions and 4 deletions

View file

@ -30,6 +30,9 @@ pre {
<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>
<hr />
<textarea id="putter" type="text"></textarea>
<button id="put">put</button>
<button id="open">open</button>

View file

@ -9,8 +9,8 @@ define([
var useDoc = function (err, doc) {
if (err) { return console.error(err); }
console.log(doc);
$dest.text(doc);
//console.log(doc);
$('#putter').val(doc);
};
$('#get').click(function () {
@ -19,5 +19,17 @@ define([
Crypt.get(val, useDoc);
});
$('#put').click(function () {
var hash = $target.val().trim();
Crypt.put(hash, $('#putter').val(), function (e) {
if (e) { console.error(e); }
$('#get').click();
});
});
$('#open').click(function () {
window.open('/code/#' + $target.val());
});
if (window.location.hash) { Crypt.get(void 0, useDoc); }
});