});
} else {
// If no school is found, display an appropriate error.
- sendJson(res, {status: 'error', message: 'Invalid school specified!'} );
+ sendJson(res, {status: 'not_found', message: 'Invalid school specified!'} );
}
});
}
});
} else {
// If no course is found, display an appropriate error.
- sendJson(res, {status: 'error', message: 'Invalid course specified!'} );
+ sendJson(res, {status: 'not_found', message: 'Invalid course specified!'} );
}
});
}
});
} else {
// If no lecture is found, display an appropriate error.
- sendJson(res, {status: 'error', message: 'Invalid lecture specified!'} );
+ sendJson(res, {status: 'not_found', message: 'Invalid lecture specified!'} );
}
});
}
<div class="masthead">
<div class="logbar">
- <div class="loginstatus"><div id="login_status"><div id="PROTO_login_info">Currently logged in as <span class="username">__name__</span></div></div></div>
+ <div class="loginstatus"><div id="login_status" style="display:none;">Currently logged in as <span class="username"></span></div></div>
</div>
<div class="navbar">
<table>
</div>
</div>
<div>
- <span class="sub_menu">
- <a href="" id="new_course" style="display:none;">New Course</a>
+ <span class="sub_menu" style="display:none;">
+ <a href="" id="new_course">New Course</a>
</span>
<form method="POST" id="form_course" style="display:none;">
<h1>Create New Course</h1>
</div>
</div>
<div>
- <span class="sub_menu">
- <a href="" id="new_lecture" style="display:none;">New Lecture</a>
+ <span class="sub_menu" style="display:none;">
+ <a href="" id="new_lecture">New Lecture</a>
</span>
<form method="POST" id="form_lecture" style="display:none;">
<h1>Create New Lecture</h1>
</div>
</div>
<div>
- <span class="sub_menu">
- <a href="" id="new_note" style="display:none;">New Note Pad</a>
+ <span class="sub_menu" style="display:none;">
+ <a href="" id="new_note">New Note Pad</a>
</span>
<form method="POST" id="form_note" style="display:none;">
<h1>Create New Note Pad</h1>
<div class="field">
<button class="major">Login</button>
<span class="reglink">
- <a href="/resetpw">Forgot password?</a>
+ <a href="/resetpass">Forgot password?</a>
</span>
</div>
</div>
function render(pageId, response) {
if (user.name) {
- ProtoDiv.inject("PROTO_login_info", user)
+ $('.username').text(user.name);
$("#login_status").show();
$('#login_link').text('Logout').attr('href', '/logout');
$('#register_link').hide();
$('#profile_link').show();
} else {
- ProtoDiv.reset("PROTO_login_info");
+ $('.username').text('');
$("#login_status").hide();
$('#login_link').text('Login').attr('href', '/login');
$('#register_link').show();
if (response) {
if (response instanceof Array) {
$.each(response, function() {
- console.log(this.id, this.data)
ProtoDiv.reset("PROTO_" + this.id)
ProtoDiv.replicate("PROTO_" + this.id, this.data)
})
// go to the page that lists the courses for a specific school
router.add('school', function(data, cb) {
- $('#new_course').hide().unbind();
+ $('.sub_menu').hide();
+ $('#new_course').unbind();
$('#form_course').hide().unbind();
var response = {
id: 'course',
$("#school_name").html(data.school.name);
if (data.school.authorized) {
- $('#new_course').show();
+ $('.sub_menu').show();
$('#new_course').click(function(e) {
e.preventDefault();
// go to the page that lists the lectures for a specific course
router.add('course', function(data, cb) {
- $('#new_lecture').hide().unbind();
+ $('.sub_menu').hide();
+ $('#new_lecture').unbind();
$('#form_lecture').hide().unbind();;
var response = [];
}
if (data.course.authorized) {
- $('#new_lecture').show();
+ $('.sub_menu').show();
$('#new_lecture').click(function(e) {
e.preventDefault();
// go to the page that lists the note taking sessions for a specific lecture
router.add('lecture', function(data, cb) {
- $('#new_note').hide().unbind();
+ $('.sub_menu').hide();
+ $('#new_note').unbind();
$('#form_note').hide().unbind();;
var response = [];
}
if (data.lecture.authorized) {
- $('#new_note').show();
+ $('.sub_menu').show();
$('#new_note').click(function(e) {
e.preventDefault();
$('#form_register').submit(function(e) {
e.preventDefault();
- console.log('register')
var form = $(this);
$.post(window.location.pathname, form.serialize(), function(data) {
form.find('.email').text(user.email);
form.find('input[name=name]').val(user.name);
form.submit(function(e) {
- console.log('test')
e.preventDefault();
$.post(window.location.pathname, form.serialize(), function(data) {
}
}
-ProtoDiv.substitute = function(s, obj, i) {
- if(i !== undefined)
- s = s.replace(/__i__/g, i);
- for(var key in obj) {
+ProtoDiv.substitute = function(s, obj) {
+ for(key in obj) {
re = new RegExp("__"+key+"__", "g")
s = s.replace(re, obj[key])
}
return s
}
-ProtoDiv.inject = function(id, obj, n) {
+ProtoDiv.inject = function(id, obj) {
var proto = ProtoDiv.elem(id)
+ var i
- proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj, n)
+ proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj)
- for(var i = 0; i < proto.attributes.length; i++) {
- var a = proto.attributes[i]
- a.textContent = ProtoDiv.substitute(a.textContent, obj, n)
+ for(i = 0; i < proto.attributes.length; i++) {
+ a = proto.attributes[i]
+ var x = a.textContent ? 'textContent' : 'value';
+ a[x] = ProtoDiv.substitute(a[x], obj)
}
- for(var key in obj) {
- var c = key.substring(1)
- var list = []
+ for(key in obj) {
+ c = key.substring(1)
+ list = []
switch(key.substring(0,1)) {
case "#":
ProtoDiv.map(proto, list, function(e) {
proto.origDisplay = proto.style.display
}
- for(var i = 0; i < l; i++) {
+ for(i = 0; i < l; i++) {
obj = arr[i]
- var e = proto.cloneNode(true)
+ e = proto.cloneNode(true)
delete e.id
mom.insertBefore(e, sib)
- ProtoDiv.inject(e, obj, i)
- if(ProtoDiv.each)
- ProtoDiv.each(e, i, obj, mom)
+ ProtoDiv.inject(e, obj)
}
if(!keep)
}
return proto
}
-
-