Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "Add class to current day script": {
- "prefix": "current-day-script",
- "body": [
- " ",
- " (function () {",
- " var days = [",
- " ['Sunday', 'Sun'],",
- " ['Monday', 'Mon'],",
- " ['Tuesday', 'Tue'],",
- " ['Wednesday', 'Wed'],",
- " ['Thursday', 'Thu'],",
- " ['Friday', 'Fri'],",
- " ['Saturday', 'Sat']",
- " ];",
- " var openingTimesContainer = document.getElementsByClassName('open-times')[0];",
- " var openingTimesLi = openingTimesContainer.getElementsByTagName('li');",
- " var todaysWeekDay = days[((new Date()).getDay())];",
- "",
- " for (var li in openingTimesLi) {",
- " if (openingTimesLi.hasOwnProperty(li)) {",
- " var currentLi = openingTimesLi[li];",
- "",
- " if (currentLi.getElementsByClassName('open-day')[0].innerHTML.indexOf(todaysWeekDay[0]) > -1 || currentLi.getElementsByClassName('open-day')[0].innerHTML.indexOf(todaysWeekDay[1]) > -1) {",
- " currentLi.classList.add('current-day');",
- " }",
- " }",
- " }",
- "",
- " var footerOpeningTimesContainer = document.getElementsByClassName('footer__open-times')[0];",
- " var footerOpeningTimesLi = footerOpeningTimesContainer.getElementsByTagName('li');",
- "",
- " for (var footerLi in footerOpeningTimesLi) {",
- " if (footerOpeningTimesLi.hasOwnProperty(footerLi)) {",
- " var footerCurrentLi = footerOpeningTimesLi[footerLi];",
- "",
- " if (footerCurrentLi.getElementsByClassName('open-day')[0].innerHTML.indexOf(todaysWeekDay[0]) > -1 || footerCurrentLi.getElementsByClassName('open-day')[0].innerHTML.indexOf(todaysWeekDay[1]) > -1) {",
- " footerCurrentLi.classList.add('current-day');",
- " }",
- " }",
- " }",
- " })();"
- ],
- "description": "Add class to current day script"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement