Update dates in CreatorPro
function replaceDates() {
var oldString = /<p>Module available from.+<\/p>/igm;
// var oldString = /<p>Module available from.+<\/p>|<p>.+Module available from.+<\/p>/igm;
var newString = '';
var cpCalendarDates = document.querySelectorAll('.generic_table.cke_show_border tbody tr > td:first-child');
console.log(cpCalendarDates);
for(let date of cpCalendarDates) {
console.log(date.innerHTML);
if(date.innerHTML.toLowerCase().includes('week 2')) {
console.log('week 2 added');
newString = '<p>Module available from Wednesday, 8/30 through Tuesday, 9/5</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 3')) {
console.log('week 3 added');
newString = '<p>Module available from Wednesday, 9/6 through Tuesday, 9/12</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 4')) {
console.log('week 4 added');
newString = '<p>Module available from Wednesday, 9/13 through Tuesday, 9/19</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 5')) {
console.log('week 5 added');
newString = '<p>Module available from Wednesday, 9/20 through Tuesday, 9/26</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 6')) {
console.log('week 6 added');
newString = '<p>Module available from Wednesday, 9/27 through Tuesday, 10/3</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 7')) {
console.log('week 7 added');
newString = '<p>Module available from Wednesday, 10/4 through Tuesday, 10/10</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 8')) {
console.log('week 8 added');
newString = '<p>Module available from Wednesday, 10/11 through Tuesday, 10/17</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 9')) {
console.log('week 9 added');
newString = '<p>Module available from Wednesday, 10/18 through Tuesday, 10/24</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 10')) {
console.log('week 10 added');
newString = '<p>Module available from Wednesday, 10/25 through Tuesday, 10/31</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 11')) {
console.log('week 11 added');
newString = '<p>Module available from Wednesday, 11/1 through Tuesday, 11/7</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 12')) {
console.log('week 12 added');
newString = '<p>Module available from Wednesday, 11/8 through Tuesday, 11/14</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 13')) {
console.log('week 13 added');
newString = '<p>Module available from Wednesday, 11/15 through Tuesday, 11/21</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 14')) {
console.log('week 14 added');
newString = '<p>Module available from Wednesday, 11/22 through Tuesday, 11/28</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 15')) {
console.log('week 15 added');
newString = '<p>Module available from Wednesday, 11/29 through Saturday, 12/9</p>';
}
else if(date.innerHTML.toLowerCase().includes('week 1')) {
console.log('week 1 dates added');
newString = '<p>Module available from Monday, 8/21 through Tuesday, 8/29</p>';
}
updateString(date, oldString, newString);
}
}
function updateString(target, oldString, newString) {
let updatedContent = target.innerHTML.replace(oldString, newString);
console.log(updatedContent);
target.innerHTML = updatedContent;
}
replaceDates();