diff --git a/changelog.html b/changelog.html index df7b0dfe..708df40a 100644 --- a/changelog.html +++ b/changelog.html @@ -1,3 +1,18 @@ +
/reset
command which clears the current Top Cheer.There was an error fetching schedule data from the server.
'; + }; + + this.ws_send("get_schedule", channel_id, function(success, data) { + if ( ! success ) + return fail(); + else if ( ! document.body.contains(container) || container.dataset.key !== 'schedule' ) + return; + + loaded = true; + parse_schedule_dates(data); + + var scroller = utils.createElement('ol', 'scroller'); + container.innerHTML = ''; + container.appendChild(scroller); + + var runs = []; + for(var run_id in data) + runs.push([run_id, data[run_id]]); + + runs.sort(function(a,b) { + var ao = a[1].order, + bo = b[1].order; + + if ( ao < bo ) return -1; + if ( ao > bo ) return 1; + return 0; + }); + + var last_date; + for(var i=0; i < runs.length; i++) + last_date = FFZ.channel_metadata.schedule.draw_row.call(t, scroller, runs[i][0], runs[i][1], last_date); + + setTimeout(function() { + var current = scroller.querySelector('.ffz-current-item'); + current && current.scrollIntoViewIfNeeded(); + }); + }); + + setTimeout(fail, 5000); + }, + + draw_row: function(container, run_id, run, last_date) { + var el = utils.createElement('li', 'ffz-schedule-row'), + now = Date.now(), + is_current = run.starttime <= now && run.endtime >= now, + is_old = run.starttime < now, + current_date = run.starttime.toLocaleDateString(); + + if ( current_date !== last_date ) + container.appendChild(utils.createElement('div', 'ffz-schedule-row ffz-schedule-date', current_date)); + + el.classList.toggle('ffz-current-item', is_current); + el.classList.toggle('ffz-old-item', ! is_current && is_old); + el.dataset.id = run_id; + + var meta = [ + 'Length: ' + utils.sanitize(run.run_time) + ]; + + if ( run.setup_time ) + meta.push('Setup: ' + utils.sanitize(run.setup_time)); + + if ( run.coop ) + meta.push('Co-Op'); + + if ( run.console ) + meta.push('Console: ' + utils.sanitize(run.console)); + + el.innerHTML = '