Home | History | Annotate | Download | only in ui
      1 <!--
      2 Copyright 2014 The Chromium Authors. All rights reserved.
      3 Use of this source code is governed by a BSD-style license that can be
      4 found in the LICENSE file.
      5 -->
      6 
      7 <polymer-element name="ct-last-updated" attributes="date">
      8   <template>
      9     <template if="{{ date }}">
     10       <style>
     11         .stale_5minutes {
     12           color: orange;
     13         }
     14         .stale_10minutes {
     15           color: red;
     16         }
     17         .stale_20minutes {
     18           background-color: red;
     19           color: black;
     20         }
     21       </style>
     22       <span class="{{ date | _style }}">Updated @ {{ date | _hours }}:{{ date | _minutes }}</div>
     23     </template>
     24   </template>
     25   <script>
     26   (function() {
     27     Polymer({
     28       date: null,
     29       _style: function(date) {
     30         var staleness = date.minutesAgo();
     31         if (staleness >= 20)
     32           return "stale_20minutes";
     33         if (staleness >= 10)
     34           return "stale_10minutes";
     35         if (staleness >= 5)
     36           return "stale_5minutes";
     37         return "";
     38       },
     39 
     40       _hours: function(date) {
     41         return date.getHours();
     42       },
     43       _minutes: function(date) {
     44         return date.getMinutes().toString().padLeft(2, '0');
     45       },
     46     });
     47   })();
     48 
     49   </script>
     50 </polymer-element>
     51