A Pen by Chase Harrison on CodePen.
Created
February 28, 2019 12:08
-
-
Save ChaseH88/1e873b9ed322c2ce3644f8924691dc0f to your computer and use it in GitHub Desktop.
Today's Office Hours
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="contentPortlet"> | |
| <h2 class="fa-clock-o">Office Hours</h2> | |
| <ul id="officeHours" class="sidePanelList"> | |
| <li class="monday"><span class="left">Monday</span><span class="right">9:00AM - 6:00PM</span></li> | |
| <li class="tuesday"><span class="left">Tuesday</span><span class="right">7:30AM - 4:00PM</span></li> | |
| <li class="wednesday"><span class="left">Wednesday</span><span class="right">9:00AM - 6:00PM</span></li> | |
| <li class="thursday"><span class="left">Thursday</span><span class="right">7:30AM - 4:00PM</span></li> | |
| <li class="friday"><span class="left">Friday</span><span class="right">9:00AM - 2:00PM</span></li> | |
| <li class="saturday"><span class="left">Saturday</span><span class="right">9:00AM - 12:00PM</span></li> | |
| <li class="sunday"><span class="left">Sunday</span><span class="right">CLOSED</span></li> | |
| </ul> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Adds a class to the day of the week for office hours | |
| $(window).bind("load", function() { | |
| //runs only on pages with widget on it | |
| if ($("#officeHours").length) { | |
| today = new Date(); | |
| dayIndex = today.getDay(); | |
| //Assign class to current day | |
| switch (dayIndex) { | |
| case 0: | |
| $("#officeHours .sunday").addClass("today"); | |
| break; | |
| case 1: | |
| $("#officeHours .monday").addClass("today"); | |
| break; | |
| case 2: | |
| $("#officeHours .tuesday").addClass("today"); | |
| break; | |
| case 3: | |
| $("#officeHours .wednesday").addClass("today"); | |
| break; | |
| case 4: | |
| $("#officeHours .thursday").addClass("today"); | |
| break; | |
| case 5: | |
| $("#officeHours .friday").addClass("today"); | |
| break; | |
| case 6: | |
| $("#officeHours .saturday").addClass("today"); | |
| break; | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .contentPortlet {max-width: 300px;} | |
| .left {float: left;} | |
| .right {float: right;} | |
| /*-------------------------------*/ | |
| .today span {font-weight: bold;} | |
| /* hides all but today's hours */ | |
| li:not(.today) {display: none;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment