-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into joeywildman-fix-pluralize
- Loading branch information
Showing
85 changed files
with
612 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,53 @@ | ||
function formvalidation(form){ | ||
function DoubleByte(str) { | ||
for (var i = 0, n = str.length; i < n; i++) { | ||
if (str.charCodeAt(i) > 127) { return true; } | ||
} | ||
return false; | ||
function DoubleByte(str) { | ||
for (var i = 0, n = str.length; i < n; i++) { | ||
if (str.charCodeAt(i) > 127) { return true; } | ||
} | ||
var nickname = document.getElementById('course_user_datum_nickname'); | ||
return false; | ||
} | ||
var nickname = document.getElementById('course_user_datum_nickname'); | ||
|
||
if (DoubleByte(nickname.value)){ | ||
nickname.setAttribute('style','background-color:#FFF352'); | ||
nickname.focus(); | ||
alert("Your nickname has non-ASCII characters"); | ||
} else { | ||
form.submit(); | ||
} | ||
if (DoubleByte(nickname.value)){ | ||
nickname.setAttribute('style','background-color:#FFF352'); | ||
nickname.focus(); | ||
alert("Your nickname has non-ASCII characters"); | ||
} else { | ||
form.submit(); | ||
} | ||
} | ||
|
||
function disable_dropped(){ | ||
$('#course_user_datum_dropped').prop("checked",false); | ||
$('#course_user_datum_dropped').prop("disabled",true); | ||
} | ||
// User can be at most one of the following: instructor, course assistant, or dropped (student) | ||
const $instructor_checkbox = $('#course_user_datum_instructor'); | ||
const $course_assistant_checkbox = $('#course_user_datum_course_assistant'); | ||
const $dropped_checkbox = $('#course_user_datum_dropped'); | ||
const mutually_exclusive_fields = [ | ||
$instructor_checkbox, $course_assistant_checkbox, $dropped_checkbox | ||
]; | ||
|
||
function enable_dropped(){ | ||
$('#course_user_datum_dropped').prop("disabled",false); | ||
} | ||
function mutual_exclusion() { | ||
const fields = mutually_exclusive_fields; // For brevity | ||
// Enable all fields | ||
fields.forEach((field) => field.prop('disabled', false)); | ||
|
||
function prevent_dropping_instructor_ca(){ | ||
if($('#course_user_datum_instructor').is(':checked') || | ||
$('#course_user_datum_course_assistant').is(':checked')){ | ||
disable_dropped(); | ||
} | ||
else{ | ||
enable_dropped(); | ||
// If any field is checked, disable the rest | ||
fields.forEach((field, idx) => { | ||
if (field.is(':checked')) { | ||
fields.forEach((field2, idx2) => { | ||
if (idx !== idx2) { | ||
field2.prop('disabled', true); | ||
field2.prop('checked', false); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
$(document).ready(prevent_dropping_instructor_ca); | ||
|
||
$('#course_user_datum_instructor').on( "click", | ||
prevent_dropping_instructor_ca); | ||
$(document).ready(function(){ | ||
$('#user_submit').on("click", function(e){ | ||
formvalidation(this.closest('form')); | ||
e.preventDefault(); | ||
}); | ||
|
||
$('#course_user_datum_course_assistant').on( "click", | ||
prevent_dropping_instructor_ca); | ||
mutual_exclusion(); | ||
mutually_exclusive_fields.forEach((field) => field.on("click", mutual_exclusion)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.