forked from WING-NUS/SSID
-
Notifications
You must be signed in to change notification settings - Fork 0
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 sibinh/maintenance_mailer
- Loading branch information
Showing
59 changed files
with
1,014 additions
and
131 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
This file is part of SSID. | ||
SSID is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
SSID is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with SSID. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
(function () { | ||
window.Assignment || (window.Assignment = {}); | ||
|
||
Assignment.onLoad = function () { | ||
return $(function () { | ||
$("#assignment_file").on("change", function () { | ||
Assignment.onAssignmentFileInputChange(this); | ||
}); | ||
$("#assignment_mapfile").on("change", function () { | ||
Assignment.onAssignmentMapFileInputChange(this); | ||
}); | ||
}); | ||
} | ||
|
||
Assignment.onAssignmentFileInputChange = function (fileInput) { | ||
if (fileInput.files[0] == undefined) { | ||
return; | ||
} | ||
let reader = new FileReader(); | ||
reader.onload = (ev) => { | ||
JSZip.loadAsync(ev.target.result) | ||
.then(function (zip) { | ||
var zipObjectNames = Object.keys(zip.files); | ||
var fileNames = zipObjectNames.filter( | ||
(x) => x.charAt(x.length - 1) != "/" | ||
); | ||
|
||
// Reset existing file list | ||
$("#student_submissions_zip_files_list").empty(); | ||
|
||
// Set label of the file list | ||
if (fileNames.length > 10) { | ||
$("#student_submissions_zip_files_list_label").text("Files inside (showing first 10):"); | ||
} else if (fileNames.length == 0) { | ||
$("#student_submissions_zip_files_list_label").text("The zip file is empty."); | ||
} else { | ||
$("#student_submissions_zip_files_list_label").text("Files inside:"); | ||
} | ||
|
||
// Display the first ten files | ||
for (let i = 0; i < Math.min(10, fileNames.length); i++) { | ||
let fileName = fileNames[i]; | ||
$("#student_submissions_zip_files_list").append( | ||
"<li><a href=# id=preview_file_" + i + ">" + fileName + "</a></li>" | ||
); | ||
|
||
let handleClick = function () { | ||
zip | ||
.file(fileName) | ||
.async("string") | ||
.then((fileContent) => { | ||
Assignment.previewRawFile(fileName, fileContent); | ||
return false; | ||
}); | ||
}; | ||
|
||
$("#preview_file_" + i).click(handleClick); | ||
} | ||
|
||
// Indicate that there are more files if there are > 10 files | ||
if (fileNames.length > 10) { | ||
$("#student_submissions_zip_files_list").append("<li>...</li>"); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error("Error trying to unzip and process", filename); | ||
console.error(err); | ||
}); | ||
}; | ||
reader.onerror = (err) => { | ||
console.error("Error trying to read file", err); | ||
}; | ||
reader.readAsArrayBuffer(fileInput.files[0]); | ||
} | ||
|
||
Assignment.onAssignmentMapFileInputChange = function (fileInput) { | ||
if (fileInput.files[0] == undefined) { | ||
return; | ||
} | ||
|
||
let fileName = fileInput.files[0].name; | ||
let reader = new FileReader(); | ||
|
||
// Reset existing file list | ||
$("#map_files_list").empty(); | ||
|
||
// Show newly chosen file | ||
$("#map_files_list").prepend("<br>"); | ||
|
||
$("#map_files_list").append( | ||
"<li><a href=# id=preview_map_file>" + fileName + "</a></li>" | ||
); | ||
|
||
reader.readAsText(fileInput.files[0]); | ||
|
||
reader.onerror = (err) => { | ||
console.error("Error trying to read file", err); | ||
}; | ||
|
||
let handleClick = () => Assignment.previewRawFile(fileName, reader.result); | ||
|
||
$("#preview_map_file").click(handleClick); | ||
} | ||
|
||
Assignment.previewRawFile = function (fileName, fileContent) { | ||
let newWindow = window.open("about:blank"); | ||
newWindow.document.write("<title>" + fileName + "</title>"); | ||
newWindow.document.write("<pre>" + fileContent + "</pre>"); | ||
} | ||
|
||
}).call(this); |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ | ||
|
||
window.PasswordReset ||= {} | ||
|
||
PasswordReset.validatePassword = -> | ||
$("form#reset-password").submit (event) -> | ||
if ($("div.new-password > input").val().length == 0) | ||
$("div.new-password > p").text("New password cannot be blank").show(); | ||
event.preventDefault(); | ||
else if ($("div.new-password > input").val().length < 8) | ||
$("div.new-password > p").text("New password must be at least 8 characters long").show(); | ||
event.preventDefault(); | ||
else if ($("div.new-password > input").val().match(/[a-z]+/) == null) | ||
$("div.new-password > p").text("New password must contain at least 1 lower case character").show(); | ||
event.preventDefault(); | ||
else if ($("div.new-password > input").val().match(/[A-Z]+/) == null) | ||
$("div.new-password > p").text("New password must contain at least 1 upper case character").show(); | ||
event.preventDefault(); | ||
else if ($("div.new-password > input").val().match(/[0-9~!@#$%^&*()+=|]+/) == null) | ||
$("div.new-password > p").text("New password must contain at least 1 digit or special character").show(); | ||
event.preventDefault(); | ||
|
||
if ($("div.new-password > input").val() != $("div.confirm-new-password > input").val()) | ||
$("div.confirm-new-password > p").text("The password confirmation does not match").show(); | ||
event.preventDefault(); | ||
return | ||
return | ||
|
||
PasswordReset.resetForm = -> | ||
$("div.new-password > input").keyup (event) -> | ||
$("input.submit").removeAttr('disabled'); | ||
$("div.new-password > p").hide(); | ||
$("div.confirm-new-password > p").hide(); | ||
|
||
$("div.confirm-new-password > input").keyup (event) -> | ||
$("input.submit").removeAttr('disabled'); | ||
$("div.new-password > p").hide(); | ||
$("div.confirm-new-password > p").hide(); | ||
return | ||
|
||
$(document).ready -> | ||
$ -> | ||
PasswordReset.validatePassword() | ||
PasswordReset.resetForm() | ||
return |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Place all the styles related to the PasswordResets controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: https://sass-lang.com/ | ||
|
||
// This file is part of SSID. | ||
// | ||
// SSID is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// SSID is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with SSID. If not, see <http://www.gnu.org/licenses/>. | ||
@import "bootstrap_custom"; | ||
|
||
body.password_resets { | ||
.site { | ||
@extend .text-center; | ||
width: 60%; | ||
margin: auto; | ||
} | ||
|
||
.forget-password-helper-text { | ||
@extend .mt-3; | ||
@extend .mb-3; | ||
} | ||
|
||
.site_copyright { | ||
@extend .mt-5; | ||
@extend .mb-3; | ||
@extend .text-muted; | ||
} | ||
|
||
.site-password-reset-link { | ||
@extend .w-100; | ||
@extend .btn; | ||
@extend .btn-primary; | ||
} | ||
|
||
form#reset-password { | ||
label { | ||
margin-top: $spacer * 0.5; | ||
} | ||
} | ||
|
||
.send-password-reset-link { | ||
h5 { | ||
margin-bottom: $spacer; | ||
} | ||
|
||
div { | ||
p { | ||
margin-bottom: $spacer * 0.5; | ||
} | ||
} | ||
} | ||
|
||
.reset-password { | ||
h5 { | ||
margin-bottom: $spacer; | ||
} | ||
} | ||
|
||
.error-explanation { | ||
color: var(--bs-danger); | ||
display: none; | ||
} | ||
} | ||
|
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.