Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DayClick(dayNum, obj) {
- if ($(obj).hasClass('selected') && ($('#Schedule tbody tr td.d' + dayNum + ' div.selected').length)) {
- $('#Schedule tbody tr td.d' + dayNum + ' div').removeClass('selected');
- $(obj).removeClass('selected');
- }
- else {
- $('#Schedule tbody tr td.d' + dayNum + ' div').addClass('selected');
- $(obj).addClass('selected');
- };
- }
- $(document).ready(function() {
- $('#Schedule tbody tr .d0').hover(
- function() { $('#Schedule thead tr td.d0').addClass('hovered') },
- function() { $('#Schedule thead tr td.d0').removeClass('hovered') });
- $('#Schedule thead tr .d0').hover(
- function() { $('#Schedule td.d0').addClass('hovered') },
- function() { $('#Schedule td.d0').removeClass('hovered') })
- .click(function() { DayClick('0', this) });
- $('#Schedule tbody tr .d1').hover(
- function() { $('#Schedule thead tr td.d1').addClass('hovered') },
- function() { $('#Schedule thead tr td.d1').removeClass('hovered') });
- $('#Schedule thead tr .d1').hover(
- function() { $('#Schedule td.d1').addClass('hovered') },
- function() { $('#Schedule td.d1').removeClass('hovered') })
- .click(function() { DayClick('1', this) });
- $('#Schedule tbody tr .d2').hover(
- function() { $('#Schedule thead tr td.d2').addClass('hovered') },
- function() { $('#Schedule thead tr td.d2').removeClass('hovered') });
- $('#Schedule thead tr .d2').hover(
- function() { $('#Schedule td.d2').addClass('hovered') },
- function() { $('#Schedule td.d2').removeClass('hovered') })
- .click(function() { DayClick('2', this) });
- $('#Schedule tbody tr .d3').hover(
- function() { $('#Schedule thead tr td.d3').addClass('hovered') },
- function() { $('#Schedule thead tr td.d3').removeClass('hovered') });
- $('#Schedule thead tr .d3').hover(
- function() { $('#Schedule td.d3').addClass('hovered') },
- function() { $('#Schedule td.d3').removeClass('hovered') })
- .click(function() { DayClick('3', this) });
- $('#Schedule tbody tr .d4').hover(
- function() { $('#Schedule thead tr td.d4').addClass('hovered') },
- function() { $('#Schedule thead tr td.d4').removeClass('hovered') });
- $('#Schedule thead tr .d4').hover(
- function() { $('#Schedule td.d4').addClass('hovered') },
- function() { $('#Schedule td.d4').removeClass('hovered') })
- .click(function() { DayClick('4', this) });
- $('#Schedule tbody tr .d5').hover(
- function() { $('#Schedule thead tr td.d5').addClass('hovered') },
- function() { $('#Schedule thead tr td.d5').removeClass('hovered') });
- $('#Schedule thead tr .d5').hover(
- function() { $('#Schedule td.d5').addClass('hovered') },
- function() { $('#Schedule td.d5').removeClass('hovered') })
- .click(function() { DayClick('5', this) });
- $('#Schedule tbody tr .d6').hover(
- function() { $('#Schedule thead tr td.d6').addClass('hovered') },
- function() { $('#Schedule thead tr td.d6').removeClass('hovered') });
- $('#Schedule thead tr .d6').hover(
- function() { $('#Schedule td.d6').addClass('hovered') },
- function() { $('#Schedule td.d6').removeClass('hovered') })
- .click(function() { DayClick('6', this) });
- $('#Schedule tr').hover(
- function() { $(this).addClass('hovered') },
- function() { $(this).removeClass('hovered') });
- $('#Schedule tbody tr td div').click(
- function() { $(this).toggleClass('selected') });
- });
- $(function(){
- const table = document.querySelector('#Schedule');
- const cells = document.querySelectorAll('.cell');
- document.querySelector("#btn").addEventListener('click', sendHandler);
- function sendHandler(e) {
- let resultArray = [];
- cells.forEach(cell => {
- let {day, month, year, time} = cell.dataset;
- let employees = cell.querySelectorAll('.employee');
- let employeesIDs = [...employees].map(employeeElement => employeeElement.dataset.employeeId);
- resultArray.push({day, month, year, time, employeesIDs});
- });
- resultJson = JSON.stringify(resultArray);
- console.log(resultJson);
- }
- });
Add Comment
Please, Sign In to add comment