Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefry-nolastname authored Mar 16, 2022
1 parent d71da68 commit 0fd7013
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"dotenv": "^16.0.0",
"express": "~4.16.1",
"hbs": "~4.0.4",
"http-errors": "~1.6.3",
Expand Down
9 changes: 8 additions & 1 deletion public/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ exampleModal.addEventListener('show.bs.modal', function (event) {
Files = [];
$("input").val("");
$("#uploadedFile").empty();

$("#formCreate").submit((event)=>{
event.preventDefault();
console.log($(event.target).serializeArray());
});

$("#formFile").change( (event) => {
if(event.target.files.length>0){
for(var i=0;i<event.target.files.length;i++){
Expand All @@ -26,6 +32,7 @@ exampleModal.addEventListener('show.bs.modal', function (event) {
$(event.target).val("");
}
});

$("#join-form").change(async (event)=>{
const file = event.target.files[0];
const data = await file.arrayBuffer();
Expand All @@ -36,4 +43,4 @@ exampleModal.addEventListener('show.bs.modal', function (event) {
var container = document.getElementById('participantCounter');
container.innerHTML = `${aoa.length} Participant(s)`;
});
})
})
2 changes: 0 additions & 2 deletions util/handlebars_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ hbs.registerHelper("check_selected", function (value, options) {

hbs.registerHelper("selected", function (option, value) {
if (option === value) {
console.log(true);
return " selected";
} else {
console.log(false);
return "";
}
});
Expand Down
19 changes: 10 additions & 9 deletions views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,48 +58,49 @@
<h5 class="modal-title" id="exampleModalLabel">Start New Topic</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form class="row g-3" id="formCreate">
<div class="modal-body">
<form class="row g-3">
<div class="col-auto">
<label for="contributor" class="col-form-label">Name :</label>
<input type="text" class="form-control" id="contributor">
<input name="Name" type="text" class="form-control" id="contributor">
</div>
<div class="col-auto">
<label for="division" class="col-form-label">Division :</label>
<select class="form-select" aria-label="Default select example">
<select name="division" class="form-select" aria-label="Default select example">
<option value="">Please select your division</option>
<option value="ict">ICT</option>
</select>
</div>
<div class="mb-1">
<label for="recipient-name" class="col-form-label">Title :</label>
<input type="text" class="form-control" id="recipient-name">
<input name="Title" type="text" class="form-control" id="recipient-name">
</div>
<div class="mb-1">
<label for="message-text" class="col-form-label">Description :</label>
<textarea class="form-control" id="message-text"></textarea>
<textarea name="Description" class="form-control" id="message-text"></textarea>
</div>
<div class="mb-1">
<label for="join-form" class="col-form-label">Join Form Excel File:</label>
<input class="form-control" type="file" id="join-form" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">
<small id="participantCounter"></small>
<input type="hidden" name="Participant"/>
</div>
<div class="mb-1">
<label for="video-link" class="col-form-label">Youtube Link :</label>
<input type="text" class="form-control" id="video-link">
<input name="Video" class="form-control" type="file" id="formFile" multiple="multiple" accept="video/*">
</div>
<div class="mb-1">
<label for="formFile" class="form-label">Upload Thumbnails</label>
<input class="form-control" type="file" id="formFile" multiple="multiple" accept="image/*">
<input name="Images" class="form-control" type="file" id="formFile" multiple="multiple" accept="image/*">
<ul id="uploadedFile">
</ul>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
</div>
</div>
</div>
Expand Down

0 comments on commit 0fd7013

Please sign in to comment.