mirror of
https://github.com/amark/gun.git
synced 2026-03-21 23:53:35 +00:00
85 lines
2.3 KiB
HTML
85 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
</head>
|
|
<body>
|
|
<h1>Social Network</h1>
|
|
<form name="sign">
|
|
<input name="email" placeholder="email">
|
|
<input name="password" type="password" placeholder="password">
|
|
<input type="submit" name="it" value="sign in or up">
|
|
</form>
|
|
<script src="../../deps/jquery.js"></script>
|
|
<script src="../../../as/as.js"></script>
|
|
<script src="../../gun2.js"></script>
|
|
<script>
|
|
$(function(){
|
|
$.as($.as('sign'));
|
|
var social = {};
|
|
social.server = 'http://localhost:8888/';
|
|
gun = Gun(social.server + 'gun');
|
|
$.as('sign.email').on('keyup', function(e){
|
|
e.val = $(this).val();
|
|
if(!e || !e.val || $(this).data('val') == e.val){ return }
|
|
$(this).data('val', e.val);
|
|
$.post(social.server + 'sign', JSON.stringify({email: e.val}), function(reply){
|
|
console.log(reply);
|
|
if(!reply){ return }
|
|
$.as('sign.it').val(reply.err || reply.ok);
|
|
},'json');
|
|
});
|
|
$('form').on('submit', function(e){
|
|
e.preventDefault(); e.stopPropagation();
|
|
var auth = {
|
|
email: $.as('sign.email').val()
|
|
,password: $.as('sign.password').val()
|
|
}
|
|
if(!auth.email){
|
|
return $.as('sign.email').val("No email!");
|
|
}
|
|
if(!auth.password){
|
|
return $.as('sign.password').val("No password!");
|
|
}
|
|
$.post(social.server + 'sign', JSON.stringify(auth), function(reply){
|
|
if(!reply){ return }
|
|
$.as('sign.it').val(reply.err || reply.ok);
|
|
},'json');
|
|
return false;
|
|
})
|
|
});
|
|
</script>
|
|
<script>
|
|
var load = function(b,c){
|
|
var d = document,
|
|
j = "script",
|
|
s = d.createElement(j)
|
|
;
|
|
var e = 2166136261,
|
|
g = b.length,
|
|
h = c,
|
|
i = /=\?/,
|
|
w = window.setTimeout,
|
|
x,
|
|
y,
|
|
a = function(z){
|
|
document.body && (z=z||x) && s && document.body[z]? document.body[y=z](s) : w(a,0);
|
|
};
|
|
if(i.test(b)){
|
|
for(;g--;) e = e * 16777619 ^ b.charCodeAt(g);
|
|
window[j+=e<0?-e:e] = function(){
|
|
h.apply(h,arguments);
|
|
delete window[j]};
|
|
b = b.replace(i,"="+j);
|
|
c = 0
|
|
};
|
|
s.onload = s.onreadystatechange = function(){
|
|
if(y&&/de|m/.test(s.readyState||"m")){
|
|
c&&c();a(x='removeChild');try{for(c in s)delete s[c]}catch(b){}
|
|
}
|
|
};
|
|
s.src = b; c && a(x='appendChild');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |