Created
November 3, 2015 03:37
-
-
Save ibolmo/9b1c577d7e81f72dac89 to your computer and use it in GitHub Desktop.
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
| var getDate = function(el){ | |
| var date = el.querySelector('._5p0a').innerText; | |
| var result = null; | |
| var match = null; | |
| var today = new Date().getDay(); | |
| if (~date.indexOf('Tomorrow')){ | |
| result = new Date(Date.now() + 86400); | |
| if (~(result + '').indexOf('Invalid')) console.error('tomorrow', date); | |
| return result; | |
| } | |
| var regex = /(January|February|March|April|May|June|July|August|September|October|November|December) [0-9]{1,2}/i; | |
| if (match = date.match(regex)){ | |
| result = new Date(match[0] + ', 201' + ((/November|December/i).test(date) ? '5' : '6')); | |
| console.log(result); | |
| return result; | |
| } | |
| var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; | |
| if (match = date.match(new RegExp('(' + days.join('|') + ')'))){ | |
| result = new Date(Date.now() + ((days.indexOf(match[0]) + 1) * 86400)); | |
| if (~(result + '').indexOf('Invalid')) console.error('day of week', date); | |
| return result; | |
| } | |
| console.error(date); | |
| }; | |
| var container = $('events_dashboard_suggestion'); | |
| $$('._4cbb').sort(function(el1, el2){ | |
| return (getDate(el1) * 1 < getDate(el2) * 1) ? -1 : 1; | |
| }).forEach(function(el){ | |
| container.appendChild(el); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment