sync/www/login.html

96 lines
3.6 KiB
HTML
Raw Normal View History

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CyTube - Login</title>
<link rel="stylesheet" href="assets/css/bootstrap.css">
2013-05-04 18:01:04 +00:00
<style type="text/css">
#username, #pw {
width: 95%;
}
2013-05-30 18:34:54 +00:00
.btn {
width: 45%;
2013-05-04 18:01:04 +00:00
}
</style>
</head>
<body>
<form class="form-horizontal" action="javascript:void(0)">
<div class="control-group">
<label class="control-label" for="username">Username</label>
<div class="controls">
<input type="text" id="username">
</div>
</div>
<div class="control-group">
<label class="control-label" for="pw">Password</label>
<div class="controls">
<input type="password" id="pw">
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="btn" id="login">Login</button>
2013-05-30 18:34:54 +00:00
<a class="btn" id="register" target="_blank" href="account.html">Register</a>
2013-05-04 18:01:04 +00:00
</div>
</div>
</form>
<script src="assets/js/jquery.js" type="text/javascript"></script>
<script src="assets/js/data.js" type="text/javascript"></script>
2013-04-26 04:57:46 +00:00
<script src="assets/js/iourl.js" type="text/javascript"></script>
<script type="text/javascript">
2013-08-18 19:21:42 +00:00
/*
So, it turns out that $.post causes Firefox to use a GET request
on cross-site requests. What the hell? I'd understand if they just
made it error instead, but why give me chicken tenders if I ordered a
cheeseburger and act like everything's peachy?
*/
function postJSON(url, data, callback) {
$.ajax(url, {
method: "POST",
crossDomain: true,
data: data,
success: function (data) {
try {
data = data.substring(data.indexOf("{"));
data = data.substring(0, data.lastIndexOf("}") + 1);
data = JSON.parse(data);
callback(data);
} catch(e) {
return;
}
},
dataType: "text"
});
}
var theme = USEROPTS.theme;
2013-05-14 22:07:55 +00:00
if(theme != "default") {
$("<link/>").attr("rel", "stylesheet")
.attr("type", "text/css")
.attr("id", "usertheme")
.attr("href", theme)
.appendTo($("head"));
}
var source;
var respond = function(e) {
if(e.data == "cytube-syn") {
source = e.source;
source.postMessage("cytube-ack", document.location);
}
}
window.addEventListener("message", respond, false);
$("#login").click(function() {
2013-08-12 03:10:55 +00:00
var data = {
name: $("#username").val(),
pw: $("#pw").val()
};
2013-08-18 19:21:42 +00:00
postJSON(WEB_URL+"/api/login", data, function (data) {
data.uname = $("#username").val();
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
2013-08-18 19:21:42 +00:00
});
});
</script>
</body>
</html>