Skip to content
Snippets Groups Projects

Add jsDoc on the coopstarter.js file.

Merged Alice Poggioli requested to merge Set-JsDoc into master
1 file
+ 102
39
Compare changes
  • Side-by-side
  • Inline
+ 102
39
@@ -3,6 +3,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@@ -3,6 +3,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX FUNCTIONS XXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
 
/**
 
* Manage classic tabs.
 
* @param {string} pageName - Id of the tab content
 
* @param {HTMLElement} elmnt - Accordion element
 
*/
function openTab(pageName, elmnt) {
function openTab(pageName, elmnt) {
// Hide all elements with class="tabcontent" by default */
// Hide all elements with class="tabcontent" by default */
var i, tabcontent, tablinks;
var i, tabcontent, tablinks;
@@ -19,8 +24,10 @@ function openTab(pageName, elmnt) {
@@ -19,8 +24,10 @@ function openTab(pageName, elmnt) {
elmnt.classList.add("active");
elmnt.classList.add("active");
}
}
/**
//Manage the visual of the fake tabs in entrepreneur dashboard.
* Manage the visual of the fake tabs in entrepreneur dashboard.
 
* @param {HTMLElement} elmnt - Active fake tab.
 
*/
function openFakeTab(elmnt) {
function openFakeTab(elmnt) {
// Hide all elements with class="tabcontent" by default */
// Hide all elements with class="tabcontent" by default */
var i, tablinks;
var i, tablinks;
@@ -29,26 +36,40 @@ function openFakeTab(elmnt) {
@@ -29,26 +36,40 @@ function openFakeTab(elmnt) {
for (i = 0; i < tablinks.length; i++) {
for (i = 0; i < tablinks.length; i++) {
tablinks[i].classList.remove("active");
tablinks[i].classList.remove("active");
}
}
 
 
// Show the specific tab content
elmnt.classList.add("active");
elmnt.classList.add("active");
}
}
/**
 
* Set a preview image on load.
 
* @param {event} event - On file loading.
 
*/
function loadFile(event) {
function loadFile(event) {
 
//Création of the preview
var elt = document.createElement("img");
var elt = document.createElement("img");
elt.src = URL.createObjectURL(event.target.files[0]);
elt.src = URL.createObjectURL(event.target.files[0]);
 
//Remove the default useless image.
var labeltag = event.target.closest("label");
var labeltag = event.target.closest("label");
labeltag.querySelector("input[name='preview_image']").style.display = "none";
labeltag.querySelector("input[name='preview_image']").style.display = "none";
 
//If there is already a image previewed, remove it.
if (labeltag.querySelector("img")) {
if (labeltag.querySelector("img")) {
var oldImage = labeltag.querySelector("img");
var oldImage = labeltag.querySelector("img");
labeltag.removeChild(oldImage);
labeltag.removeChild(oldImage);
}
}
 
//Add the previewimage
labeltag.insertAdjacentElement("afterbegin", elt);
labeltag.insertAdjacentElement("afterbegin", elt);
}
}
/**
 
* Fill datas to a form.
 
* @param {HTMLElment} detail - Element with the datas to retrieve.
 
* @param {string} targetFormName - Id of the form to fill.
 
* @param {string} inputName - Name of the input to fill.
 
*/
function linkDatasetToField(detail, targetFormName, inputName) {
function linkDatasetToField(detail, targetFormName, inputName) {
let targetForm = document.getElementById(targetFormName);
let targetForm = document.getElementById(targetFormName);
targetForm.addEventListener("populate", event => {
targetForm.addEventListener("populate", event => {
@@ -63,8 +84,11 @@ function linkDatasetToField(detail, targetFormName, inputName) {
@@ -63,8 +84,11 @@ function linkDatasetToField(detail, targetFormName, inputName) {
});
});
}
}
/**
//Refresh information after a form submission
* Refresh information after a form submission
 
* @param {String} formId - Id of the sumitted form
 
* @param {String} listId - Id of the list to refresh
 
*/
function refreshList(formId, listId) {
function refreshList(formId, listId) {
let form = document.getElementById(formId);
let form = document.getElementById(formId);
form.addEventListener("save", event => {
form.addEventListener("save", event => {
@@ -73,8 +97,9 @@ function refreshList(formId, listId) {
@@ -73,8 +97,9 @@ function refreshList(formId, listId) {
});
});
}
}
/**
//Remove pagination when there is no resource in a step group
* Remove pagination when there is no resource in a step group.
 
*/
function refreshPagination() {
function refreshPagination() {
var resources_containers = document.querySelectorAll(
var resources_containers = document.querySelectorAll(
".resource_by_step sib-form+div"
".resource_by_step sib-form+div"
@@ -88,13 +113,22 @@ function refreshPagination() {
@@ -88,13 +113,22 @@ function refreshPagination() {
.textContent == 1)
.textContent == 1)
) {
) {
resources_container.nextSibling.setAttribute("style", "display:none");
resources_container.nextSibling.setAttribute("style", "display:none");
} else if (resources_container.nextSibling && resources_container.closest(".step").querySelector('.accordion:not(.active)')) {
} else if (
 
resources_container.nextSibling &&
 
resources_container
 
.closest(".step")
 
.querySelector(".accordion:not(.active)")
 
) {
resources_container.nextSibling.setAttribute("hidden", "hidden");
resources_container.nextSibling.setAttribute("hidden", "hidden");
}
}
}
}
}
}
//Manage select hidden to fullfill them with more "more criterias" selection
/**
 
* Manage select hidden to fullfill them with more "more criterias" selection
 
* @param {HTMLElement} select_hidden - Hidden select to fullfill.
 
* @param {HTMLElement} option_selected - Option selcted to set in hidden select.
 
*/
function selectHiddenManagement(select_hidden, option_selected) {
function selectHiddenManagement(select_hidden, option_selected) {
options_hidden = select_hidden.getElementsByTagName("option");
options_hidden = select_hidden.getElementsByTagName("option");
for (let option_hidden of options_hidden) {
for (let option_hidden of options_hidden) {
@@ -114,7 +148,11 @@ function selectHiddenManagement(select_hidden, option_selected) {
@@ -114,7 +148,11 @@ function selectHiddenManagement(select_hidden, option_selected) {
refreshPagination();
refreshPagination();
}
}
//Manage input hidden field to fullfill them with more "more criterias" selection
/**
 
* Manage input hidden field to fullfill them with more "more criterias" selection
 
* @param {HTMLElement} field - Hidden field to fullfill.
 
* @param {HTMLElement} field_search - Field with the value wanted by the user.
 
*/
function inputHiddenManagement(field, field_search) {
function inputHiddenManagement(field, field_search) {
field.setAttribute("value", field_search.value);
field.setAttribute("value", field_search.value);
let parent_form = field.closest("sib-form");
let parent_form = field.closest("sib-form");
@@ -122,7 +160,11 @@ function inputHiddenManagement(field, field_search) {
@@ -122,7 +160,11 @@ function inputHiddenManagement(field, field_search) {
refreshPagination();
refreshPagination();
}
}
//Manage select hidden for type to fullfill them with more "more criterias" selection
/**
 
* Manage select hidden for type to fullfill them with more "more criterias" selection
 
* @param {HTMLElement} tab - Selected type tabs.
 
* @param {HTMLElement} form - Hidden form to fullfill.
 
*/
function selectHiddenManagementForType(tab, form) {
function selectHiddenManagementForType(tab, form) {
let type_hidden_field = form.querySelectorAll(
let type_hidden_field = form.querySelectorAll(
'hidden-widget[name="more_criterias_hidden"] select[name="type"]'
'hidden-widget[name="more_criterias_hidden"] select[name="type"]'
@@ -153,7 +195,9 @@ function selectHiddenManagementForType(tab, form) {
@@ -153,7 +195,9 @@ function selectHiddenManagementForType(tab, form) {
}
}
}
}
//Manage the report broken links hidden form
/**
 
* Manage the report broken links hidden form
 
*/
function fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink) {
function fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink) {
formBrokenLink.querySelector(
formBrokenLink.querySelector(
"input[name='resource']"
"input[name='resource']"
@@ -164,22 +208,28 @@ function fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink) {
@@ -164,22 +208,28 @@ function fillReportBrokenLinkForm(event, userWhoSubmitReport, formBrokenLink) {
).value = JSON.stringify({ "@id": userWhoSubmitReport });
).value = JSON.stringify({ "@id": userWhoSubmitReport });
}
}
//Manage the accordion for step in entrepreneur dashboard
/**
 
* Manage the accordion for step in entrepreneur dashboard
 
*/
function manageAccordionByStep(){
function manageAccordionByStep(){
var acc = document.getElementsByClassName("accordion");
var acc = document.getElementsByClassName("accordion");
var i;
var i;
for (i = 0; i < acc.length; i++) {
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
acc[i].addEventListener("click", function() {
if (this.classList.contains("active") == true){
if (this.classList.contains("active") == true) {
this.classList.remove("active")
this.classList.remove("active");
this.nextElementSibling.querySelector("sib-form + div").style.maxHeight = "0px";
this.nextElementSibling.querySelector(
}else{
"sib-form + div"
this.classList.add("active")
).style.maxHeight = "0px";
 
} else {
 
this.classList.add("active");
}
}
this.closest(".step").querySelector('nav').removeAttribute("hidden");
this.closest(".step")
refreshPagination()
.querySelector("nav")
 
.removeAttribute("hidden");
 
refreshPagination();
var panel = this.nextElementSibling.querySelector("sib-form + div");
var panel = this.nextElementSibling.querySelector("sib-form + div");
@@ -188,13 +238,14 @@ function manageAccordionByStep(){
@@ -188,13 +238,14 @@ function manageAccordionByStep(){
} else {
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
});
});
}
}
}
}
//Manage the accordion for requested resources in the mentor dashboard
/**
function manageAccordionForRequest(){
* Manage the accordion for requested resources in the mentor dashboard
 
*/
 
function manageAccordionForRequest() {
var accRequest = document.querySelectorAll(
var accRequest = document.querySelectorAll(
"#requests accordion-request-resource"
"#requests accordion-request-resource"
);
);
@@ -217,8 +268,10 @@ function manageAccordionForRequest(){
@@ -217,8 +268,10 @@ function manageAccordionForRequest(){
}
}
}
}
//Manage the action of the logout button
/**
function manageLogoutButton(){
* Manage the action of the logout button
 
*/
 
function manageLogoutButton() {
const logoutButtons = document.getElementsByClassName("logout-button");
const logoutButtons = document.getElementsByClassName("logout-button");
for (var i = 0; i < logoutButtons.length; i++) {
for (var i = 0; i < logoutButtons.length; i++) {
logoutButtons[i].addEventListener("click", function() {
logoutButtons[i].addEventListener("click", function() {
@@ -235,6 +288,11 @@ function manageLogoutButton(){
@@ -235,6 +288,11 @@ function manageLogoutButton(){
}
}
}
}
 
/**
 
* For entrepreneur dashboard only :
 
* As we cannot have multiple imbricated filtering with the native sib-display, we manage it manually.
 
* @param {String} targetId - Id of the element to update
 
*/
function addProperFilterToSearchComponents(targetId) {
function addProperFilterToSearchComponents(targetId) {
var baseElement = document.getElementById(targetId);
var baseElement = document.getElementById(targetId);
var forms = baseElement.querySelectorAll(".resource_by_step");
var forms = baseElement.querySelectorAll(".resource_by_step");
@@ -246,7 +304,7 @@ function addProperFilterToSearchComponents(targetId) {
@@ -246,7 +304,7 @@ function addProperFilterToSearchComponents(targetId) {
selectHiddenManagementForType(tab, form);
selectHiddenManagementForType(tab, form);
}
}
//On load in dashbord Entrepreneur
//Manage the pagination
refreshPagination();
refreshPagination();
//SEARCH BY KEYWORD
//SEARCH BY KEYWORD
@@ -408,10 +466,12 @@ function addProperFilterToSearchComponents(targetId) {
@@ -408,10 +466,12 @@ function addProperFilterToSearchComponents(targetId) {
});
});
});
});
}
}
 
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX ON LOAD XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXX ON LOAD XXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
 
jQuery(document).ready(function($) {
jQuery(document).ready(function($) {
//Refresh pagination
//Refresh pagination
refreshPagination();
refreshPagination();
@@ -419,12 +479,16 @@ jQuery(document).ready(function($) {
@@ -419,12 +479,16 @@ jQuery(document).ready(function($) {
// Get the element with id="defaultOpen" and click on it
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
document.getElementById("defaultOpen").click();
 
//Retrieve the current user
let userAccountDataSrc = document.getElementById("user-account-picture");
let userAccountDataSrc = document.getElementById("user-account-picture");
 
 
//Add the current user as reviewer.
linkDatasetToField(userAccountDataSrc, "validation-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "validation-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "improvement-dialog-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "improvement-dialog-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "refusal-dialog-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "refusal-dialog-form", "reviewer");
linkDatasetToField(userAccountDataSrc, "change_status_request", "reviewer");
linkDatasetToField(userAccountDataSrc, "change_status_request", "reviewer");
 
//On form submission, we sometime have to refresh a list.
refreshList("resource-creation-form", "resources-history");
refreshList("resource-creation-form", "resources-history");
refreshList("validation-form", "pending-resources");
refreshList("validation-form", "pending-resources");
refreshList("refusal-dialog-form", "pending-resources");
refreshList("refusal-dialog-form", "pending-resources");
@@ -461,12 +525,12 @@ jQuery(document).ready(function($) {
@@ -461,12 +525,12 @@ jQuery(document).ready(function($) {
}
}
//Manage the logout action
//Manage the logout action
manageLogoutButton()
manageLogoutButton();
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXX MENTOR DASHBOARD XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXX MENTOR DASHBOARD XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
window.setTimeout(() => {
window.setTimeout(() => {
//Manage the form to report broken link.
//Manage the form to report broken link.
let detailsMentor = document.getElementById("detail-mentor");
let detailsMentor = document.getElementById("detail-mentor");
@@ -524,16 +588,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
@@ -524,16 +588,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
}, 3000);
}, 3000);
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX ENTREPRENEUR DASHBOARD XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX ENTREPRENEUR DASHBOARD XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
window.setTimeout(() => {
window.setTimeout(() => {
//Manage accordion by step
//Manage accordion by step
manageAccordionByStep()
manageAccordionByStep();
refreshPagination()
refreshPagination();
}, 2000);
}, 2000);
//In the entrepreneur dashboard, we set data from the display form to the hidden ones.
//In the entrepreneur dashboard, we set data from the display form to the hidden ones.
Loading