<commit_before><link rel="import" href="/bower_components/polymer/polymer-element.html">
<link rel="import" href="/bower_components/polymer/lib/elements/dom-if.html">
<link rel="import" href="/bower_components/polymer/lib/elements/dom-repeat.html">

<link rel="import" href="/bower_components/iron-flex-layout/iron-flex-layout.html">

<link rel="import" href="yta-lesson-card.html">

<script src="/bower_components/moment/min/moment.min.js"></script>

<dom-module id="yta-overview-page">
  <template>
    <style>
      
      @media (min-width: 480px) and (max-width: 960px) and (orientation: landscape), (min-width: 0px) and (max-width: 600px) and (orientation: portrait) {
        
        #placeholder {
          @apply --layout-vertical;
        }
        
      }
      
      @media (min-width: 961px) and (orientation: landscape), (min-width: 601px) and (orientation: portrait) {
        
        #placeholder {
          @apply --layout-horizontal;
          @apply --layout-wrap;
          @apply --layout-center-justified;
          padding-top: 12px !important;
        }

        h2 {
          text-align: center;
        }
        
      }
      
      #placeholder {
         padding: 8px;
      }

      :host/* , #placeholder */ {
        position: relative;
        overflow: visible;
      }
      
      h2 {
        margin: 15px;
        opacity: var(--dark-primary-opacity);
        font-size: 24px;
        font-weight: 400;
        letter-spacing: -.01em;
        line-height: 40px;
        font-family: 'Roboto', 'Noto', sans-serif;
        -webkit-font-smoothing: antialiased;
      }
    
    </style>
    
    <div id="placeholder">
      <template is="dom-repeat" items="[[lessonsToday(data.timetable)]]">
        <yta-lesson-card i$="[[index]]"
                         name="[[item.name]]"
                         start-time="[[viewReadable(item.startTime)]]"
                         end-time="[[viewReadable(item.endTime)]]"
                         color="[[_pickLessonColor(item.name)]]"
                         classroom="[[item.classroom]]"
                         phone-layout="[[phoneLayout]]"
                         ></yta-lesson-card>
      </template>
      <template is="dom-if" if="[[phoneLayout]]">
        <yta-lesson-card blank phone-layout="[[phoneLayout]]"></yta-lesson-card>
      </template>
    </div>
  </template>
  
  <script>
    class OverviewPage extends Polymer.Element {
      static get is() { return 'yta-overview-page'; }
      static get properties() {
        return {
          
          // Inherited from Shell
          phoneLayout: {
            type: Boolean,
            notify: true,
            reflectToAttribute: true
          },
          
          // Inherited from MainView
          data: {
            type: Object,
            notify: true
          }
          
        };
      }
      
      constructor() {
        super();
      }
      
      connectedCallback() {
        super.connectedCallback();
        this._fire('OVERIVIEW-PAGE-loaded');
      }
      
      lessonsToday(tt) {
        if (tt == null) {
          this._fire('err-no-data');
          return [];
        } else {
          const timetable = tt;
          let day = moment().day(),
              showHeader = false,
              firstRun = true;
          while (true) {
            if (timetable[day] !== 0) {
              const minute = moment().minute(),
                    hour = moment().hour(),
                    time = moment().utcOffset(0).set({year: 1970, month: 0, date: 1, minute, hour}).format('x');
              if (!firstRun || timetable[day][timetable[day].length - 1].endTime > time) {
                if (!firstRun) this._showHeader(day);
                return timetable[day];
              }
            }
            day = day === 6 ? 0 : day + 1;
            firstRun = false;
          }
        }
      }
      
      viewReadable(time) {
        const ampm = this.data.settings.use12hoursClock;
        return moment(time).utcOffset(0)
          .format(`${ampm ? 'hh' : 'HH'}:mm${ampm ? ' a' : ''}`);
      }

      _showHeader(day) {
        const header = this.shadowRoot.querySelector('h2');
        if (header) {
          header.textContent = moment().day(day).format('dddd');
        } else {
          const el = document.createElement('h2');
          el.textContent = moment().day(day).format('dddd');
          this.shadowRoot.insertBefore(el, this.shadowRoot.firstChild);
        }
      }
      
      _pickLessonColor(name) {<commit_msg>Quick bug fix<commit_after><link rel="import" href="/bower_components/polymer/polymer-element.html">
<link rel="import" href="/bower_components/polymer/lib/elements/dom-if.html">
<link rel="import" href="/bower_components/polymer/lib/elements/dom-repeat.html">

<link rel="import" href="/bower_components/iron-flex-layout/iron-flex-layout.html">

<link rel="import" href="yta-lesson-card.html">

<script src="/bower_components/moment/min/moment.min.js"></script>

<dom-module id="yta-overview-page">
  <template>
    <style>
      
      @media (min-width: 480px) and (max-width: 960px) and (orientation: landscape), (min-width: 0px) and (max-width: 600px) and (orientation: portrait) {
        
        #placeholder {
          @apply --layout-vertical;
        }
        
      }
      
      @media (min-width: 961px) and (orientation: landscape), (min-width: 601px) and (orientation: portrait) {
        
        #placeholder {
          @apply --layout-horizontal;
          @apply --layout-wrap;
          @apply --layout-center-justified;
          padding-top: 12px !important;
        }

        h2 {
          text-align: center;
        }
        
      }
      
      #placeholder {
         padding: 8px;
      }

      :host/* , #placeholder */ {
        position: relative;
        overflow: visible;
      }
      
      h2 {
        margin: 15px;
        opacity: var(--dark-primary-opacity);
        font-size: 24px;
        font-weight: 400;
        letter-spacing: -.01em;
        line-height: 40px;
        font-family: 'Roboto', 'Noto', sans-serif;
        -webkit-font-smoothing: antialiased;
      }
    
    </style>
    
    <div id="placeholder">
      <template is="dom-repeat" items="[[lessonsToday(data.timetable)]]">
        <yta-lesson-card i$="[[index]]"
                         name="[[item.name]]"
                         start-time="[[viewReadable(item.startTime)]]"
                         end-time="[[viewReadable(item.endTime)]]"
                         color="[[_pickLessonColor(item.name)]]"
                         classroom="[[item.classroom]]"
                         phone-layout="[[phoneLayout]]"
                         ></yta-lesson-card>
      </template>
      <template is="dom-if" if="[[phoneLayout]]">
        <yta-lesson-card blank phone-layout="[[phoneLayout]]"></yta-lesson-card>
      </template>
    </div>
  </template>
  
  <script>
    class OverviewPage extends Polymer.Element {
      static get is() { return 'yta-overview-page'; }
      static get properties() {
        return {
          
          // Inherited from Shell
          phoneLayout: {
            type: Boolean,
            notify: true,
            reflectToAttribute: true
          },
          
          // Inherited from MainView
          data: {
            type: Object,
            notify: true
          }
          
        };
      }
      
      constructor() {
        super();
      }
      
      connectedCallback() {
        super.connectedCallback();
        this._fire('OVERIVIEW-PAGE-loaded');
      }
      
      lessonsToday(tt) {
        if (tt == null) {
          this._fire('err-no-data');
          return [];
        } else {
          const timetable = tt;
          let day = moment().day(),
              showHeader = false,
              firstRun = true;
          while (true) {
            if (timetable[day] !== 0) {
              const minute = moment().minute(),
                    hour = moment().hour(),
                    time = moment().utcOffset(0).set({year: 1970, month: 0, date: 1, minute, hour}).format('x');
              if (!firstRun || timetable[day][timetable[day].length - 1].endTime > time) {
                if (!firstRun) this._showHeader(day);
                return timetable[day];
              }
            }
            day = day === 6 ? 0 : day + 1;
            firstRun = false;
          }
        }
      }
      
      viewReadable(time) {
        const ampm = this.data.settings.use12hoursClock;
        return moment(time).utcOffset(0)
          .format(`${ampm ? 'hh' : 'HH'}:mm${ampm ? ' a' : ''}`);
      }

      _showHeader(day) {
        Polymer.RenderStatus.afterNextRender(this, () => {
          const header = this.shadowRoot.querySelector('h2');
          if (header) {
            header.textContent = moment().day(day).format('dddd');
          } else {
            const el = document.createElement('h2');
            el.textContent = moment().day(day).format('dddd');
            this.shadowRoot.insertBefore(el, this.shadowRoot.firstChild);
          }
        });
      }
      
      _pickLessonColor(name) {
{'fraction_non_alphanumeric': 0.14589003810560697, 'fraction_numerical': 0.010669569951007077, 'mean_word_length': 1.6170940170940171, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2988383', 'n_tokens_mistral': 2811, 'n_tokens_neox': 2650, 'n_words': 475}