NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

let classList = document.querySelector(".class-list");
let performanceList = document.querySelector(".performance-list");

const fetchDropdownApi = async (url)=>{
try{
let res = await fetch(url);
let data = await res.json();
let classDropdown = data.classDropdown;
classDropdown.map((element)=>{
let option = document.createElement("option")
let value = element.split(" ");
option.value = value[1];
option.appendChild( document.createTextNode(element));
classList.appendChild(option)
})
let performanceLevel = data.performanceLevel;
performanceLevel.map((element)=>{
let option = document.createElement("option")
option.value = element;
option.appendChild( document.createTextNode(element));
performanceList.appendChild(option)
})
}
catch(err){
console.log(err);
}
}

fetchDropdownApi("https://jsonblob.com/api/jsonBlob/922837073522868224");

const fetchClasses= async (url)=>{
try{
let res = await fetch(url);
let data = await res.json();
let classes = data.classes;
let getReportBtn = document.querySelector(".getReportBtn");
getReportBtn.addEventListener("click", () => getReportDetails(classes));
return classes;
}
catch(err){
console.log(err);
}
}
fetchClasses("https://jsonblob.com/api/jsonBlob/922847334786940928");



function getReportDetails(classes){
let selectedClass = classes.filter((ele) => ele.className == classList.value);
if(selectedClass.length != 0){
let filteredStudents = selectedClass[0].studentresults.filter((studentObj) => studentObj.peformanceLevel == performanceList.value);
if(filteredStudents.length != 0){
displayTable(filteredStudents);
}else{
displayTable(selectedClass[0].studentresults);
}
}
else{
let tableBody = document.querySelector(".table_body");
tableBody.innerHTML="";
}

}

const callingSorting = async () => {
let classes = await fetchClasses("https://jsonblob.com/api/jsonBlob/922847334786940928");
let selectedClass = classes.filter((ele) => ele.className == classList.value);
if(selectedClass.length != 0){
let filteredStudents = selectedClass[0].studentresults.filter((studentObj) => studentObj.peformanceLevel == performanceList.value);
if(filteredStudents.length != 0){
sortByname(filteredStudents)
}else{
sortByname(selectedClass[0].studentresults);
}

}
}

document.getElementById("studentName").addEventListener("click", callingSorting)



const displayTable = (tabelData)=>{
let tableBody = document.querySelector(".table_body");
tableBody.innerHTML="";


tabelData.map((tableObj)=>{
let tr = document.createElement("tr");
for(let ele in tableObj){
if(ele != "completedPercent"){
if(ele == "peformanceLevel"){
let td = document.createElement("td");
td.appendChild( document.createTextNode(tableObj.completedPercent));
let icon = document.createElement("span");
icon.innerHTML=`<i class="fas fa-circle"></i>`;
if(tableObj[ele] == "Below-Level"){
icon.className=("text-danger");
}else if(tableObj[ele] == "On-Level"){
icon.className=("text-warning ");
}else{
icon.className=("text-success");
}

td.appendChild(icon);
td.appendChild( document.createTextNode(tableObj[ele]));
tr.appendChild(td);
}
else{
let td = document.createElement("td");
td.innerHTML = `${tableObj[ele]}`;
if(ele == "finalscore"){
td.classList.add("visibility");
}
if(ele == "rank"){
td.classList.add("invisibility");
}
tr.appendChild(td);
}
}
tableBody.appendChild(tr)
}

})

}

//sorting table
let ascending = true;
function sortByname(tableValues){
let icon = document.querySelector(`.studentName-icon`);
if(ascending){
tableValues.sort((a, b) => {
icon.innerHTML=`<i class="fas fa-arrow-up"></i>`;
let fa = a.studentName.toLowerCase();
let fb = b.studentName.toLowerCase();
return(fa <= fb ? -1 : 1)
});

displayTable(tableValues);
ascending = false;
}
else{
tableValues.sort((a, b) => {
icon.innerHTML=`<i class="fas fa-arrow-down"></i>`;
let fa = a.studentName.toLowerCase();
let fb = b.studentName.toLowerCase();
return(fa < fb ? 1 : -1)
});
displayTable(tableValues);
ascending = true;
}
}


const mediaQuery = window.matchMedia('(max-width: 768px)')
function handleTabletChange(e) {
if (e.matches) {
let visible = document.querySelectorAll(".visibility")
for(let i=0; i< visible.length;i++){
visible[i].style.display = "none";
}
document.querySelector(".midscreen-icon").innerHTML = `<i class="fas fa-chevron-left tab-left-btn ms-3 bg-primary" style="cursor:pointer;" ></i> <i class="fas fa-chevron-right tab-right-btn ms-3 bg-primary" style="cursor:pointer;"></i>`;
document.querySelector(".tab-right-btn").addEventListener("click", handleResponsivenessRight);


document.querySelector(".tab-left-btn").addEventListener("click", handleResponsivenessLeft);
}else{
let visible = document.querySelectorAll(".visibility")
for(let i=0; i< visible.length;i++){
visible[i].style.display = "block"
}
document.querySelector(".midscreen-icon").innerHTML = "";
}
}
let visible = true;
function handleResponsivenessRight(){
let visible = document.querySelectorAll(".visibility")
for(let i=0; i< visible.length;i++){
visible[i].style.display = "block";
}
let invisible = document.querySelectorAll(".invisibility")
for(let i=0; i< invisible.length;i++){
invisible[i].style.display = "none";
}
}

function handleResponsivenessLeft(){
let visible = document.querySelectorAll(".visibility")
for(let i=0; i< visible.length;i++){
visible[i].style.display = "none";
}
let invisible = document.querySelectorAll(".invisibility")
for(let i=0; i< invisible.length;i++){
invisible[i].style.display = "block";
}
}

mediaQuery.addListener(handleTabletChange)

handleTabletChange(mediaQuery)

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.