91 lines
2.5 KiB
HTML
91 lines
2.5 KiB
HTML
<%inherit file="main.html" />
|
|
|
|
<a href="/t/courseinfo.html">Course</a>
|
|
<a class="modal" href="#login">Log In</a>
|
|
|
|
<div style="display:none">
|
|
<div id="login"><%include file="login.html" /></div>
|
|
</div>
|
|
|
|
<div style="display:none">
|
|
<div id="pwd_reset"><%include file="password_reset_form.html" /></div>
|
|
</div>
|
|
|
|
<div style="display:none">
|
|
<div id="reset_done"></div>
|
|
</div>
|
|
|
|
|
|
<script>
|
|
$(function() {
|
|
/* Set up FancyBox pop-ups */
|
|
|
|
// TODO: Clean up as per http://stackoverflow.com/questions/169506/obtain-form-input-fields-using-jquery
|
|
|
|
/* Handles when the user hits 'enroll'. Grabs form data. Does AJAX.
|
|
Either shows error, or shows success. */
|
|
|
|
$('#create_account_button').click(function() {
|
|
var submit_data={};
|
|
$.each($("[id^=ca_]"), function(index,value){
|
|
submit_data[value.name]=value.value;
|
|
});
|
|
$.each($("[id^=cb_]"), function(index,value){
|
|
submit_data[value.name]=value.checked;
|
|
});
|
|
|
|
postJSON('/create_account',
|
|
submit_data,
|
|
function(json) {
|
|
if(json.success) {
|
|
$('#enroll').html(json.value);
|
|
} else {
|
|
$('#enroll_error').html(json.value);
|
|
}
|
|
}
|
|
);
|
|
});
|
|
|
|
/* Handles when the user tries to log in. Grabs form data. Does AJAX.
|
|
Either shows error, or redirects. */
|
|
$('#login_button').click(function() {
|
|
var submit_data={};
|
|
$.each($("[id^=li_]"), function(index,value){
|
|
submit_data[value.name]=value.value;
|
|
});
|
|
submit_data["remember"] = ($('#remember').attr("checked")? true : false);
|
|
|
|
postJSON('/login',
|
|
submit_data,
|
|
function(json) {
|
|
if(json.success) {
|
|
location.href="/courseware";
|
|
} else {
|
|
$('#login_error').html("Invalid Login");
|
|
}
|
|
}
|
|
);
|
|
});
|
|
|
|
$('#pwd_reset_button').click(function() {
|
|
$.post('/password_reset/',{ "csrfmiddlewaretoken" : "${ csrf }",
|
|
"email" : $('#id_email').val()}, function(data){
|
|
$('#pwd_reset').html(data);
|
|
});
|
|
});
|
|
|
|
/* Activate stupid spinner drop-downs in enrollment form */
|
|
var spinner_array=$("[id^=spinner_]");
|
|
spinner_array.each(function(i) {
|
|
var s=spinner_array[i];
|
|
$("#"+s.id).click(function(){
|
|
$("#sregion"+s.id.substring(7)).toggle();
|
|
});
|
|
})
|
|
|
|
|
|
/*$("sregion"+$("[id^=spinner_]")[1].id.substring(7)) */
|
|
});
|
|
|
|
</script>
|