Passed
Push — master ( 589cc4...8de2f9 )
by Corey
03:11
created

$(document).ready   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
(function($, Chart) {
2
  $(document).ready(function() {
3
    var past_checkin_dates = JSON.parse(document.getElementById('past-checkin-dates').innerHTML)
4
      .map(function(date) {
5
      return new Date(date)
6
    })
7
8
9
    var pie_data = JSON.parse(document.getElementById('pie-chart-data').innerHTML)
10
    if(pie_data.labels.length) {
11
      Chart.defaults.global.responsive = true
12
      Chart.defaults.global.scaleBeginAtZero = true
13
      var pie_ctx = document.getElementById('category-pie-chart').getContext('2d')
14
      var pieChart = new Chart(pie_ctx, {
0 ignored issues
show
Unused Code introduced by
The variable pieChart seems to be never used. Consider removing it.
Loading history...
15
        type: 'pie',
16
        data: pie_data,
17
        options: {
18
          legend: {
19
            display: false
20
          }
21
        }
22
      })
23
    }
24
25
    $( '#datepicker' ).click(function() {
26
      $(this).pickadate({
27
28
        // The title label to use for the month nav buttons
29
        labelMonthNext: 'Next month',
30
        labelMonthPrev: 'Previous month',
31
32
        // The title label to use for the dropdown selectors
33
        labelMonthSelect: 'Select a month',
34
        labelYearSelect: 'Select a year',
35
36
        // Months and weekdays
37
        monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
38
        monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
39
        weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
40
        weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
41
42
        // Today and clear
43
        today: 'Today',
44
        clear: 'Clear',
45
        close: 'Close',
46
47
        // Close on a user action
48
        closeOnSelect: true,
49
        closeOnClear: true,
50
51
        // The format to show on the `input` element
52
        format: 'yyyy-mm-dd',
53
        formatSubmit: 'yyyy-mm-dd',
54
        hiddenName: true,
55
56
        onSet: function(obj) {
57
          // we only want to redirect them if they've selected a date
58
          if(obj.hasOwnProperty('select')) {
59
            location.href = "/checkin/view/"+this.get()
60
          }
61
        },
62
63
        // only show specific dates
64
        disable: [
65
          true // disable all except the following
66
        ].concat(past_checkin_dates, [new Date()])
67
68
      })
69
    })
70
  })
71
})(jQuery, Chart)
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
72