function run(val) {
$('form#dataform').attr("action", "/priv/"+val).submit();
}
$('input#person').keyup(function(event){
if ( event.which == 13 ) {
event.stopPropagation();
findPerson();
return false;
}
});
function upload_pic(pid) {
// Add a division with a file upload button, post the picture and
// the person id number in an ajax call. Make the ajax function
// attempt to determine the date the photo was taken and if that
// isn't available, use today.
var html = '
Select the picture file to upload
';
html += '';
$('div#ajax-form').html(html);
}
function fetch_spix(pid) {
// Attempt to load the spic for this student
ajax_call('fetch_spix', {pid:pid}, (args) => {
findPerson(); // force reload
})
}
//
function do_upload_pic(pid) {
var data = new FormData($('form#ajaxform')[0]);
var args = {'pid': pid, 'data': data };
$.ajax('ajax/upload_pic/', {
type: "POST",
beforeSend: function(xhr) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
},
data: data,
enctype: 'multipart/form-data',
processData: false, // tell jQuery not to process the data
contentType: false // tell jQuery not to set contentType
}).done(function( data ) {
findPerson();
});
$('div#ajax-form').html("");
return false;
/* var files = document.getElementById('ajax-file').files;
for (var i=0; i < files.length; i++) {
var f = files[i];
var dic = {filename: f.name, size: f.size, type: f.type};
dic.contentsb64 = btoa(f.contents);
args.files.push(dic);
}
*/
}
function add_item(pid, item) {
document.location.href = '/admin/people/student/' + pid + '/'
}
function login(odat, next){
if (odat.indexOf("") != 0) {
return false;
}
document.location.href = "/priv/";
return true;
}
function loadPerson(objs) {
resetDivs();
if ('html' in objs) {
$('div#person').html(objs.html);
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"research_area"]);
setupEditors();
} else {
$('textarea').val(objs.text);
}
}
function loadPersonID(id){
if (id == null) return;
ajax_call('person', {id: id}, loadPerson);
}
function findPerson() {
ajax_call('person', {person_text: $('input#person').val()},
function(objs) {
resetDivs();
if ('html' in objs) {
$('div#person').html( objs.html );
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"research_area"]);
setupEditors();
} else {
$('textarea').val( objs.text );
}
}
)
}
function ShowMsg(idnum) {
$('div#mm-' + idnum).attr('style', '').toggleClass("hidden");
return false;
}
function ShowMMMsg(idnum) {
$('div#mmm-' + idnum).attr('style', '').toggleClass("hidden");
return false;
}
function composeMail() {
$('textarea#message').width(450).height(150);
$('div#mailer').toggleClass('hidden');
}
function composeChallengeMessage() {
if ($('div#mailer').hasClass('hidden')) {
composeMail(); // make sure to display the editing box
}
var pid = $('input#pid')[0].value;
ajax_call('challenge_message', {pid: pid},
function (objs) {
if ('text' in objs) {
$('textarea#message').html(objs.text);
$('input#subject').val("Results of the Mechanics Challenge Exam");
}
});
}
function sendMail(target_id) {
ajax_call('mail',
{ subject: $('input#subject').val(),
message: $('textarea#message').val(),
to: target_id
}, function(objs){
resetDivs();
findPerson();
})
}
// changeTheCourse selects a course for which we have data, fetches
// the years for which we have records, updating the list of assessments
function changeTheCourse(selector) {
changeCourse(selector.value);
}
function changeCourse(id) {
ajax_call('course_year', {course: id},
function(objs) {
var assess = objs.assessments;
var years = objs.courserecs;
// We need to display a menu of possible choices for the course record
var txt='Box Plot ';
txt += options;
txt += ' Means