GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/Scheduler/Schedule/ |
Upload File : |
"use strict"; // Schedule/schedule8.js // KeydownDialog(evt) // Handle keystrokes when the dialog is open. function KeydownDialog(evt) { let DEBUG = DEBUG_ON; evt = (evt) ? evt : window.event; if ( DEBUG ) { console.group(`${PC}KeydownDialog[evt.target.id=${evt.target.id}]`,CG); }//Collapsed // Get the key. let theKey; if (evt) { theKey = evt.which; } else { theKey = window.event.keyCode; } let scheduleFormDialogOpen = false; let eDialogDiv; let fldScheduleFormFound; if ( DEBUG ) { console.log(`${PC}theKey=${theKey}`,CL); } switch ( theKey ) { case 27: // ESC if ( DEBUG ) { console.log(`${PC}Process ESC.`,CL); } // Close the dialog if no changes were made. eDialogDiv = document.getElementById('dialogDiv'); // See if the dialog is open. if ( DEBUG ) { console.log(`${PC}eDialogDiv.style.display=${eDialogDiv.style.display}`,CL); } if ( eDialogDiv.style.display !== 'none' ) { // Is the dialog open? // Check if this is a Schedule Form. fldScheduleFormFound = eDialogDiv.innerHTML.indexOf('fldScheduleForm'); if ( DEBUG ) { console.log(`${PC}fldScheduleFormFound=${fldScheduleFormFound}`,CL); } if ( fldScheduleFormFound !== -1 ) { // Is this a Schedule Form? // Yes, check if a change has been made. scheduleFormDialogOpen = true; CheckChangeInSCD(evt); } else { // Is this a Schedule Form? // No, nothing to do. scheduleFormDialogOpen = false; } // Is this a Schedule Form? } else { // Is the dialog open? // No, nothing to do. scheduleFormDialogOpen = false; } // Is the dialog open? if ( !scheduleFormDialogOpen ) { document.removeEventListener('keydown',KeydownDialog); } // No, remove event listener. break; default: } if ( DEBUG ) { console.groupEnd(); } } // END KeydownDialog. // IsChangeInSCD() // Determine if changes have been made on the Schedule Form. // Close the Schedule Form dialogDiv if there were no changes. // Inform the user if there were changes. function IsChangeInSCD() { var DEBUG = DEBUG_ON; //evt = (evt) ? evt : window.event; if ( DEBUG ) { console.group(`${PC}IsChangeInSCD[]`,CG); }//Collapsed let i, j, k, isChange; Element_Unhighlight(); let scId = parseInt(document.getElementById('hid_scheduleclassId').value); if ( DEBUG ) { console.log(`${PC}scId=${scId} (typeof scId)=${(typeof scId)}`,CI); } if ( DEBUG ) { console.log(`${PC}SCMold[${scId}]=${JSON.stringify(SCMold[scId])}`,CI); } let scheduleClassAtFirst = ''; // Calc scheduleClassAtFirst. if ( scId ) { if ( DEBUG ) { console.log(`${PC}SCMnow[${scId}]= ${JSON.stringify(SCMnow[scId])}`,CI); } if ( DEBUG ) { console.log(`${PC}SCMold[${scId}]= ${JSON.stringify(SCMold[scId])}`,CL); } scheduleClassAtFirst = {"Course":ScheduleClass[scId].Course, "courseId":ScheduleClass[scId].courseId, "Section":ScheduleClass[scId].Section, "StartDate":ScheduleClass[scId].StartDate, "EndDate":ScheduleClass[scId].EndDate, "Online":ScheduleClass[scId].Online, SCMnow:SCMold[scId], Active:[]}; if ( DEBUG ) { console.log(`${PC}scheduleClassAtFirst= ${JSON.stringify(scheduleClassAtFirst)}`,CS); } // Add ClassMeetings for ( i=0; i<SCMold[scId].length; i++ ) { // Loop thru meetings. if ( DEBUG ) { console.log(`${PC}SCMold[${scId}][${i}]=${JSON.stringify(SCMold[scId][i])}`,CD); } scheduleClassAtFirst.Active.push(SCMold[scId][i].scmId); } // Loop thru meetings. id_classmeeting_4210 if ( DEBUG ) { console.log(`${PC}scheduleClassAtFirst=${JSON.stringify(scheduleClassAtFirst)}`,CI); } } else { scheduleClassAtFirst = { "Course":"", "courseId":"", "Section":"", "StartDate":"", "EndDate":"", "Online":"0", "SCMnow":[{"scmId":"0", "sDate":"", "eDate":"", "arranged":false, "bTime":"", "eTime":"", "onCampus":"1", "rooms":[], "days":[], "instructors":[], "tdMinute":0}], "Active":[]} } let scheduleClassAtFirstJSON = JSON.stringify(scheduleClassAtFirst).replaceAll(',',', '); // NEED TO verify SC begin and end dates. let scheduleClassCurrent = ''; // Calc scheduleClassCurrent. let id; if ( DEBUG ) { console.log(`${PC}SCMnow[${scId}]= ${JSON.stringify(SCMnow[scId])}`,CI); } if ( DEBUG ) { console.log(`${PC}SCMold[${scId}]= ${JSON.stringify(SCMold[scId])}`,CL); } // BEGIN Get current info. // Get courseId and course. let courseId = document.getElementById('id_courseId').value; let course = ''; if (courseId) { course = Course[courseId].Dept + Course[courseId].Number; } let sectionNumber = document.getElementById('txt_scheduleclassSection').value; let startDate = document.getElementById('id_scheduleclassStartDate').value; let endDate = document.getElementById('id_scheduleclassEndDate').value; let scheduleclassOnline = document.getElementById('id_scheduleclassOnline'); let scheduleclassOnlineValue = '0'; if (scheduleclassOnline.checked) { scheduleclassOnlineValue = scheduleclassOnline.value; } scheduleClassCurrent = {Course:course, courseId:courseId, Section:sectionNumber, StartDate:startDate, EndDate:endDate, Online:scheduleclassOnlineValue, SCMnow:[], "Active":[]}; if ( DEBUG ) { console.log(`${PC}scheduleClassCurrent= ${JSON.stringify(scheduleClassCurrent)}`,CS); } // Highlight changed. if (scheduleClassCurrent.Online != scheduleClassAtFirst.Online) { // Online changed. id = 'id_scheduleclassOnline'; Element_Highlight(id, 'IsChangeInSCD 122'); } if (scheduleClassCurrent.courseId != scheduleClassAtFirst.courseId) { // Course changed. if (document.getElementById('id_courseId_name')) { id = 'id_courseId_name'; Element_Highlight(id, 'IsChangeInSCD 113'); } else { id = 'id_courseId'; Element_Highlight(id, 'IsChangeInSCD 116'); } } if (scheduleClassCurrent.Section != scheduleClassAtFirst.Section) { // Section changed. id = 'txt_scheduleclassSection'; Element_Highlight(id, 'IsChangeInSCD 122'); } if (scheduleClassCurrent.StartDate != scheduleClassAtFirst.StartDate) { // StartDate changed. id = 'id_scheduleclassStartDate'; Element_Highlight(id, 'IsChangeInSCD 127'); } if (scheduleClassCurrent.EndDate != scheduleClassAtFirst.EndDate) { // EndDate changed. id = 'id_scheduleclassEndDate'; Element_Highlight(id, 'IsChangeInSCD 132'); } let scmIds = document.getElementById('hid_scheduleclassmeetingIds').value.split(','); if ( DEBUG ) { console.log(`${PC}scmIds=${scmIds} .length=${scmIds.length} scmIds[0]=${scmIds[0]} typeof(scmIds[0]=${(typeof scmIds[0])})`,CL); } if ( scmIds[0] !== '' ) { for ( i=0; i<scmIds.length; i++ ) { // Loop thru scmIds. let scmId = scmIds[i]; // Get dates. id = `inp_scheduleclassmeetingStartDate_${scmId}`; if ( DEBUG ) { console.log(`${PC}id=${id}`,CI); } let sDate = document.getElementById(id).value; let eDate = document.getElementById(`inp_scheduleclassmeetingEndDate_${scmId}`).value; // Get arranged. id_scheduleclassmeetingArranged_4187 let arranged; if ( document.getElementById(`id_scheduleclassmeetingArranged_${scmId}`).checked ) { arranged = true; } else { arranged = false; } // Get times. let bTime = document.getElementById(`id_scheduleclassmeetingBeginTime_${scmId}`).value; if ( arranged ) { bTime = ''; } if ( bTime ) { bTime = ConvertMinutesToTime(ConvertTimeToMinutes(bTime)) + ':00'; } let eTime = document.getElementById(`id_scheduleclassmeetingEndTime_${scmId}`).value; if ( arranged ) { eTime = ''; } if ( eTime ) { eTime = ConvertMinutesToTime(ConvertTimeToMinutes(eTime)) + ':00'; } // Get OnCampus. let onCampus; if ( document.getElementById(`chkClassIsOffCampus_${scmId}`).checked ) { onCampus = '0'; } else { onCampus = '1'; } // Get rooms. let rooms = []; let roomIndex = 0; id = `selRoom_${scmId}_${roomIndex}`; let eRoom = document.getElementById(id); if ( DEBUG ) { console.log(`${PC}id=${id} eRoom=${eRoom}`,CI); } while (eRoom) { // Loop while there is a room element. let roomId = eRoom.value; if ( DEBUG ) { console.log(`${PC}roomId=${roomId} ${(typeof roomId)}`,CL); } roomId = parseInt(roomId); if ( DEBUG ) { console.log(`${PC}roomId=${roomId} ${(typeof roomId)}`,CL); } if ( isNaN(roomId) ) { roomId = false; } if ( roomId ) { // Was a room selected? // Get room name from roomId. // loop thru CollegeRoom to find Id and build name. for ( j=0; j<CollegeRoom.length; j++ ) { // Loop thru CollegeRooms. if ( CollegeRoom[j].roomId == roomId ) { // Is this the room? if ( DEBUG ) { console.log(`${PC}Found room ${CollegeRoom[j].Number}`,CI); } // Yes, create the room number text. let buildingId = CollegeRoom[j].buildingId; let roomNumber = CollegeRoom[j].Number; let buildingCode = 'UNKNOWN'; for ( k=0; k<CollegeBuilding.length; k++ ) { // Loop thru CollegeBuildings. if ( CollegeBuilding[k].buildingId === buildingId ) { if ( DEBUG ) { console.log(`${PC}Found building ${CollegeBuilding[k].Code}`,CI); } buildingCode = CollegeBuilding[k].Code; if ( buildingCode === 'MAINHU' ) { buildingCode = ''; } break; } } // Loop thru CollegeBuildings. rooms.push(buildingCode + roomNumber); break; } // Is this the room? } // Loop thru CollegeRooms. } // Was a room selected? roomIndex++; id = `selRoom_${scmId}_${roomIndex}`; eRoom = document.getElementById(id); if ( DEBUG ) { console.log(`${PC}id=${id} eRoom=${eRoom}`,CI); } } // Loop while there is a room element. if ( DEBUG ) { console.log(`${PC}rooms=${rooms}`,CD); } // Get days. let days = []; if ( !arranged ) { let dayCheckboxes = document.getElementsByName(`weekdayIds_${scmId}[]`); if ( DEBUG ) { console.log(`${PC}dayCheckboxes.length=${dayCheckboxes.length}`,CL); } for ( j=0; j<dayCheckboxes.length; j++ ) { let dayCheckbox = dayCheckboxes[j]; if ( DEBUG ) { console.log(`${PC}dayCheckbox.id=${dayCheckbox.id} .checked=${dayCheckbox.checked}`,CD); } if ( dayCheckbox.checked ) { days.push(Weekdays[j+1].weekdayD); } } } if ( DEBUG ) { console.log(`${PC}days=${days}`,CD); } // Get instructors. let instructors = []; let instructorIndex = 0; id = `selInstructor_${scmId}_${instructorIndex}`; let eInstructor = document.getElementById(id); if ( DEBUG ) { console.log(`${PC}id=${id} eInstructor=${eInstructor}`,CI); } while (eInstructor) { let instructorValue = eInstructor.value; if ( DEBUG ) { console.log(`${PC}instructorValue=${instructorValue}`,CL); } if ( instructorValue ) { instructors.push(instructorValue); } instructorIndex++; id = `selInstructor_${scmId}_${instructorIndex}`; eInstructor = document.getElementById(id); if ( DEBUG ) { console.log(`${PC}id=${id} eInstructor=${eInstructor}`,CI); } } // Get tdMinute. let tdMinute = 0; if ( bTime ) { tdMinute = ConvertTimeToMinutes(bTime); if ( DEBUG ) { console.log(`${PC}scmId=${scmId} bTime=${bTime} tdMinute=${tdMinute} ScheduleTimeBegin=${ScheduleTimeBegin}`,CD); } } if ( DEBUG ) { console.log(`${PC}days=${days} ${JSON.stringify(days)}`,CD); } scheduleClassCurrent.SCMnow.push({scmId:scmId, "sDate":sDate, "eDate":eDate, "arranged":arranged, "bTime":bTime, "eTime":eTime, "onCampus":onCampus, "rooms":rooms, "days":days, "instructors":instructors, "tdMinute":tdMinute}); } // Loop thru scmIds. } // Add ClassMeetings scheduleClassCurrent.Active = []; if (scId) { for ( i=0; i<SCMold[scId].length; i++ ) { // Loop thru meetings. if ( DEBUG ) { console.log(`${PC}SCMold[${scId}][${i}]=${JSON.stringify(SCMold[scId][i])}`,CD); } // Get active (meetings that have not been removed). let dId = 'id_classmeeting_'+SCMold[scId][i].scmId; if ( DEBUG ) { console.log(`${PC}dId=${dId}`,CI); } let e_classmeeting = document.getElementById(dId); //console.dir(e_classmeeting); if ( e_classmeeting ) { scheduleClassCurrent.Active.push(SCMold[scId][i].scmId); } } // Loop thru meetings. id_classmeeting_4210 } // END Get current info. // Check for a change. let scheduleClassCurrentJSON = JSON.stringify(scheduleClassCurrent).replaceAll(',',', '); if ( DEBUG ) { console.log(`${PC}scheduleClassAtFirst=${JSON.stringify(scheduleClassAtFirst).replaceAll(',',', ')}`,CA); } if ( DEBUG ) { console.log(`${PC}scheduleClassCurrent=${JSON.stringify(scheduleClassCurrent).replaceAll(',',', ')}`,CA); } if ( scheduleClassAtFirstJSON !== scheduleClassCurrentJSON ) { // Were there changes made? // Yes, highlight them. // Highlight differences. if ( DEBUG ) { console.log(`${PC}scheduleClassAtFirstJSON=${scheduleClassAtFirstJSON}`,CI); } if ( DEBUG ) { console.log(`${PC}scheduleClassCurrentJSON=${scheduleClassCurrentJSON}`,CI); } if ( DEBUG ) { console.log(`${PC}scheduleClassCurrent=${JSON.stringify(scheduleClassCurrent).replaceAll(',',', ')}`,CL); } for ( i=0; i<scheduleClassCurrent.SCMnow.length; i++ ) { // Loop thru current class meetings. let thisCurrentMeeting = scheduleClassCurrent.SCMnow[i]; if ( typeof scheduleClassAtFirst.SCMnow[i] !== 'undefined' ) { // Does AtFirst have this meeting? // Yes, check meeting details for changes. let thisAtFirstMeeting = scheduleClassAtFirst.SCMnow[i]; if ( thisCurrentMeeting.sDate !== thisAtFirstMeeting.sDate ) { // sDate changed. id = 'inp_scheduleclassmeetingStartDate_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 245'); } if ( thisCurrentMeeting.eDate !== thisAtFirstMeeting.eDate ) { // eDate changed. id = 'inp_scheduleclassmeetingEndDate_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 250'); } if ( thisCurrentMeeting.arranged !== thisAtFirstMeeting.arranged ) { // arranged changed. id = 'id_scheduleclassmeetingArranged_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 255'); } if ( JSON.stringify(thisCurrentMeeting.days) !== JSON.stringify(thisAtFirstMeeting.days) ) { // Is there a days change? // days changed. if ( DEBUG ) { console.log(`${PC}There is a days change Original=${JSON.stringify(thisAtFirstMeeting.days)} Current=${JSON.stringify(thisCurrentMeeting.days)}`,CI); } // Get different days let daysAtFirst = [0]; let daysOriginal = [0]; for ( k in Weekdays ){if(Weekdays.hasOwnProperty(k)){ daysOriginal[k] = 0; daysAtFirst[k] = 0; }} for ( j=0; j<thisCurrentMeeting.days.length; j++ ) { daysAtFirst[WeekdayD[thisCurrentMeeting.days[j]]] = WeekdayD[thisCurrentMeeting.days[j]]; } for ( j=0; j<thisAtFirstMeeting.days.length; j++ ) { daysOriginal[WeekdayD[thisAtFirstMeeting.days[j]]] = WeekdayD[thisAtFirstMeeting.days[j]]; } if ( DEBUG ) { console.log(`${PC}daysOriginal=${daysOriginal} daysAtFirst=${daysAtFirst}`,CL); } for ( k=0; k<daysOriginal.length; k++ ) { if ( DEBUG ) { console.log(`${PC}daysOriginal[${k}]=${daysOriginal[k]} daysAtFirst[${k}]=${daysAtFirst[k]}`,CL); } if ( daysOriginal[k] !== daysAtFirst[k] ) { if ( DEBUG ) { console.log(`${PC}Difference.`,CD); } let j = daysOriginal[k]; if ( j === 0 ) { j = daysAtFirst[k]; } id = 'chk_Weekday_'+thisCurrentMeeting.scmId+'_'+j; Element_Highlight(id, 'IsChangeInSCD 281'); } } } // Is there a days change? if ( thisCurrentMeeting.bTime !== thisAtFirstMeeting.bTime ) { // bTime changed. id = 'id_scheduleclassmeetingBeginTime_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 288'); } if ( thisCurrentMeeting.eTime !== thisAtFirstMeeting.eTime ) { // eTime changed. id = 'id_scheduleclassmeetingEndTime_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 293'); } if ( thisCurrentMeeting.onCampus !== thisAtFirstMeeting.onCampus ) { // onCampus changed. id = 'chkClassIsOffCampus_'+thisCurrentMeeting.scmId; Element_Highlight(id, 'IsChangeInSCD 298'); } // Need to check and highlight rooms and instructors let roomCountAtFirst = thisAtFirstMeeting.rooms.length; let roomCountCurrent = thisCurrentMeeting.rooms.length; if ( DEBUG ) { console.log(`${PC}roomCountAtFirst=${roomCountAtFirst} ${PC}roomCountCurrent=${roomCountCurrent}`,CS,CD); } let roomAtFirst; let roomCurrent; let roomNotFound; for (j=0; j<roomCountAtFirst; j++) { // Loop thru AtFirst rooms. roomAtFirst = thisAtFirstMeeting.rooms[j]; roomNotFound = true; for (k=0; k<roomCountCurrent; k++) { // Loop thru Current rooms. roomCurrent = thisCurrentMeeting.rooms[k]; if ( DEBUG ) { console.log(`${PC}scmId=${thisAtFirstMeeting.scmId} roomAtFirst=${roomAtFirst} roomCurrent=${roomCurrent}`,CL); } if (roomAtFirst == roomCurrent) { roomNotFound = false; } } // Loop thru Current rooms. if (roomNotFound) { let id = `selRoom_${thisAtFirstMeeting.scmId}_${j}`; Element_Highlight(id, 'IsChangeInSCD 373'); } } // Loop thru AtFirst rooms. for (j=0; j<roomCountCurrent; j++) { // Loop thru Current rooms. roomCurrent = thisCurrentMeeting.rooms[j]; roomNotFound = true; for (k=0; k<roomCountAtFirst; k++) { // Loop thru AtFirst rooms. roomAtFirst = thisAtFirstMeeting.rooms[k]; if ( DEBUG ) { console.log(`${PC}scmId=${thisCurrentMeeting.scmId} roomCurrent=${roomCurrent} roomAtFirst=${roomAtFirst}`,CI); } if (roomAtFirst == roomCurrent) { roomNotFound = false; } } // Loop thru Current rooms. if (roomNotFound) { let id = `selRoom_${thisCurrentMeeting.scmId}_${j}`; Element_Highlight(id, 'IsChangeInSCD 390'); } } // Loop thru AtFirst rooms. // room changed. } else { // Does original have this meeting? // No, the entire Current meeting is a change. } // Does original have this meeting? } // Loop thru current class meetings. isChange = true; } else { // Were there changes made? // No, close the dialog. isChange = false; } // Were there changes made? if ( DEBUG ) { console.log(`${PC}isChange=${isChange}`,CS); } if ( DEBUG ) { console.groupEnd(); } return isChange; } // END IsChangeInSCD. function CheckChangeInSCD(evt) { var DEBUG = DEBUG_ON; if ( DEBUG ) { console.group(`${PC}CheckChangeInSCD[id=${evt.target.id}]`,CG); }//Collapsed let isChange = IsChangeInSCD(); if (isChange) { OpenTextbox(evt, 'Discard changes', 'You have made changes to the class.<br>Do you want to discard the changed and close anyway?', ['yes','no'], 'IsChangeInSCDTextbox', 'id_scheduleclassOnline'); } else { // No, close the dialog. document.removeEventListener('keydown',KeydownDialog); CloseDialog(); // Close the dialog by hitting the ESC key. evt.preventDefault(); } if ( DEBUG ) { console.groupEnd(); } } // END CheckChangeInSCD function IsChangeInSCDTextbox(value) { CloseTextbox(); if ( value === 0 ) { CloseDialog(); } }