context = window @InLessonBroadcast = React.createClass({ displayName: 'In Lesson Broadcast' getTimeRemaining: (t) -> if t < 0 t = -t seconds = Math.floor( (t/1000) % 60 ); minutes = Math.floor( (t/1000/60) % 60 ); hours = Math.floor( (t/(1000*60*60)) % 24 ); days = Math.floor( t/(1000*60*60*24) ); return { 'total': t, 'days': days, 'hours': hours, 'minutes': minutes, 'seconds': seconds }; displayTime: () -> if @props.lessonSession.initialWindow # offset time by 10 minutes to get the 'you need to wait message' in untilTime = @getTimeRemaining(@props.lessonSession.until.total + (10 * 60 * 1000)) else untilTime = @props.lessonSession.until timeString = '' if untilTime.days != 0 timeString += "#{untilTime.days} days, " if untilTime.hours != 0 || timeString.length > 0 timeString += "#{untilTime.hours} hours, " if untilTime.minutes != 0 || timeString.length > 0 timeString += "#{untilTime.minutes} minutes, " if untilTime.seconds != 0 || timeString.length > 0 timeString += "#{untilTime.seconds} seconds" if timeString == '' 'now!' timeString render: () -> if @props.lessonSession.completed if @props.lessonSession.success content = `

This lesson is over.

` else content = `

This lesson is over, but will not be billed.

` else if @props.lessonSession.beforeSession content = `

This lesson will start in:

{this.displayTime()}

` else if @props.lessonSession.initialWindow content = `

You need to wait in this session for

{this.displayTime()}

to allow time for your teacher to join you. If you leave before this timer reaches zero, and your teacher joins this session, you will be marked absent and charged for the lesson.

` else if @props.lessonSession.teacherFault if @props.lessonSession.teacherPresent? content = `

Because your teacher was late, you may now leave the session. However, if you choose to stay in the session with the teacher, after 5 minutes together the session will be considered a success, and you will be billed.

If the two of you do not spend at least 5 minutes together in the session, your teacher will be marked absent and penalized for missing the lesson, and you will not be charged for this lesson.

` else content = `

You may now leave the session.

Your teacher will be marked absent and penalized for missing the lesson. You will not be charged for this lesson.

We apologize for your inconvenience, and we will work to remedy this situation.

` if content? `
{content}
` else null })