GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Code Duplication    Length = 1-65 lines in 2 locations

sugarloaf/static/js/index.js 1 location

@@ 189-253 (lines=65) @@
186
    return count;
187
}
188
189
function buildSummaryChart(summary) {
190
    sugarloaf.dates = summaryToDates(summary),
191
        width = 800 - MARGINS.left - MARGINS.right,
192
        height = 200 - MARGINS.top - MARGINS.bottom;
193
    sugarloaf.dataset = datesToDataset(sugarloaf.dates);
194
    
195
    sugarloaf.summary_x = d3.time.scale()
196
        .range([0, width])
197
        .domain(d3.extent(sugarloaf.dates.map(function(d) {
198
            return d.datetime;
199
        })));
200
    
201
    sugarloaf.summary_y = d3.scale.linear()
202
        .rangeRound([height, 0])
203
        .domain([0, d3.max(sugarloaf.dates, function(d) { return countDate(d)})]);
204
    
205
    sugarloaf.summary_stack = d3.layout.stack();
206
    
207
    sugarloaf.summary_stack_layers = sugarloaf.summary_stack(sugarloaf.dataset);
208
    
209
    sugarloaf.summary_area = d3.svg.area()
210
        .interpolate('cardinal')
211
        .x(function(d) { return sugarloaf.summary_x(d.x)})
212
        .y0(function(d) { return sugarloaf.summary_y(d.y0)})
213
        .y1(function(d) { return sugarloaf.summary_y(d.y0 + d.y)});
214
    
215
    sugarloaf.summary_color = d3.scale.ordinal()
216
        //     green,      blue,     black, double-black, terrain-park closed
217
        .range(['#00A64B', '#2D2D94', '#6D6D6D', '#000', '#F6AE3B', '#FFF'])
218
        .domain(['green', 'blue', 'black', 'double-black', 'terrain-park', 'closed']);
219
220
    sugarloaf.summary_xAxis = d3.svg.axis()
221
        .scale(sugarloaf.summary_x)
222
        .orient('bottom')
223
        //.ticks(d3.time.sundays, 1)
224
        .ticks(10)
225
        //.tickSubdivide(true)
226
        .tickFormat(d3.time.format("%b %e"));
227
    
228
    sugarloaf.summary_yAxis = d3.svg.axis()
229
        .scale(sugarloaf.summary_y)
230
        .orient('left');
231
232
    var svg = d3.select('#chart-summary').append('svg')
233
        .attr('width', width + MARGINS.left + MARGINS.right)
234
        .attr('height', height + MARGINS.top + MARGINS.bottom)
235
      .append('g')
236
        .attr('transform', 'translate(' + MARGINS.left + ',' + MARGINS.top +')');
237
    
238
    var selection = svg.selectAll('.series')
239
        .data(sugarloaf.summary_stack_layers)
240
      .enter().append('path')
241
          .attr('class', 'layer')
242
          .attr('d', function(d) { return sugarloaf.summary_area(d);})
243
          .style('fill', function(d, i) { return sugarloaf.summary_color(Object.keys(sugarloaf.difficulty_order)[i]) });
244
    
245
    svg.append('g')
246
        .attr('class', 'x axis')
247
        .attr('transform', 'translate(0,' + height + ')')
248
        .call(sugarloaf.summary_xAxis);
249
    
250
    svg.append('g')
251
        .attr('class', 'y axis')
252
        .call(sugarloaf.summary_yAxis);
253
}
254
255
d3.json(filename_status, function(data) {
256
    sugarloaf.data = data;

sugarloaf/static/js/index-min.js 1 location

@@ 1-1 (lines=1) @@
1
function buildCharts(){sugarloaf.ndx=crossfilter(sugarloaf.data.trails),sugarloaf.openDim=sugarloaf.ndx.dimension(function(a){return a.open?"Open":"Closed"}),sugarloaf.openGroup=sugarloaf.openDim.group().reduceCount(function(a){return a.open}),sugarloaf.openChart=dc.rowChart("#chart-row-open"),sugarloaf.openChart.width(WIDTH).height(HEIGHT/2).margins(MARGINS).dimension(sugarloaf.openDim).group(sugarloaf.openGroup).elasticX(!0),sugarloaf.groomedDim=sugarloaf.ndx.dimension(function(a){return a.groomed?"Groomed":"Ungroomed"}),sugarloaf.groomedGroup=sugarloaf.groomedDim.group().reduceCount(function(a){return a.groomed}),sugarloaf.groomedChart=dc.rowChart("#chart-row-groomed"),sugarloaf.groomedChart.width(WIDTH).height(HEIGHT/2).margins(MARGINS).dimension(sugarloaf.groomedDim).group(sugarloaf.groomedGroup).elasticX(!0),sugarloaf.snowmakingDim=sugarloaf.ndx.dimension(function(a){return a.snowmaking?"Snowmaking in progress":"Not snowmaking"}),sugarloaf.snowmakingGroup=sugarloaf.snowmakingDim.group().reduceCount(function(a){return a.snowmaking}),sugarloaf.snowmakingChart=dc.rowChart("#chart-row-snowmaking"),sugarloaf.snowmakingChart.width(WIDTH).height(HEIGHT/2).margins(MARGINS).dimension(sugarloaf.snowmakingDim).group(sugarloaf.snowmakingGroup).elasticX(!0),sugarloaf.difficultyDim=sugarloaf.ndx.dimension(function(a){return a.difficulty}),sugarloaf.difficultyGroup=sugarloaf.difficultyDim.group().reduceCount(function(a){return a.difficulty}),sugarloaf.difficultyChart=dc.rowChart("#chart-row-difficulty"),sugarloaf.difficultyChart.width(WIDTH).height(HEIGHT).margins(MARGINS).dimension(sugarloaf.difficultyDim).group(sugarloaf.difficultyGroup).ordering(function(a){return sugarloaf.difficulty_order[a.key]}).elasticX(!0),sugarloaf.areaDim=sugarloaf.ndx.dimension(function(a){return a.area}),sugarloaf.areaGroup=sugarloaf.areaDim.group().reduceCount(function(a){return a.area}),sugarloaf.areaChart=dc.rowChart("#chart-row-area"),sugarloaf.areaChart.width(WIDTH).height(2*HEIGHT).margins(MARGINS).dimension(sugarloaf.areaDim).group(sugarloaf.areaGroup).elasticX(!0),dc.renderAll()}function summaryToDates(a){var r={};a.conditions.forEach(function(a){void 0===r[a.datetime]&&(r[a.datetime]={}),a.open&&void 0===r[a.datetime][a.difficulty]?r[a.datetime][a.difficulty]=a.trail_count:a.open?r[a.datetime][a.difficulty]+=a.trail_count:void 0===r[a.datetime].closed?r[a.datetime].closed=a.trail_count:r[a.datetime].closed+=a.trail_count});var o=[];return Object.keys(r).forEach(function(a){var t=r[a];t.datetime=sugarloaf.parseDate.parse(a),o.push(t)}),o.sort(function(a,r){return a.datetime<r.datetime?-1:1}),o}function datesToDataset(a){var r=[];return Object.keys(sugarloaf.difficulty_order).forEach(function(o){var t=[];a.forEach(function(a){var r={x:a.datetime};void 0===a[o]?r.y=0:r.y=a[o],t.push(r)}),r.push(t)}),r}function countDate(a){var r=0;for(var o in a)a.hasOwnProperty(o)&&"datetime"!==o&&(r+=a[o]);return r}function buildSummaryChart(a){sugarloaf.dates=summaryToDates(a),width=800-MARGINS.left-MARGINS.right,height=200-MARGINS.top-MARGINS.bottom,sugarloaf.dataset=datesToDataset(sugarloaf.dates),sugarloaf.summary_x=d3.time.scale().range([0,width]).domain(d3.extent(sugarloaf.dates.map(function(a){return a.datetime}))),sugarloaf.summary_y=d3.scale.linear().rangeRound([height,0]).domain([0,d3.max(sugarloaf.dates,function(a){return countDate(a)})]),sugarloaf.summary_stack=d3.layout.stack(),sugarloaf.summary_stack_layers=sugarloaf.summary_stack(sugarloaf.dataset),sugarloaf.summary_area=d3.svg.area().interpolate("cardinal").x(function(a){return sugarloaf.summary_x(a.x)}).y0(function(a){return sugarloaf.summary_y(a.y0)}).y1(function(a){return sugarloaf.summary_y(a.y0+a.y)}),sugarloaf.summary_color=d3.scale.ordinal().range(["#00A64B","#2D2D94","#6D6D6D","#000","#F6AE3B","#FFF"]).domain(["green","blue","black","double-black","terrain-park","closed"]),sugarloaf.summary_xAxis=d3.svg.axis().scale(sugarloaf.summary_x).orient("bottom").ticks(10).tickFormat(d3.time.format("%b %e")),sugarloaf.summary_yAxis=d3.svg.axis().scale(sugarloaf.summary_y).orient("left");var r=d3.select("#chart-summary").append("svg").attr("width",width+MARGINS.left+MARGINS.right).attr("height",height+MARGINS.top+MARGINS.bottom).append("g").attr("transform","translate("+MARGINS.left+","+MARGINS.top+")"),o=r.selectAll(".series").data(sugarloaf.summary_stack_layers).enter().append("path").attr("class","layer").attr("d",function(a){return sugarloaf.summary_area(a)}).style("fill",function(a,r){return sugarloaf.summary_color(Object.keys(sugarloaf.difficulty_order)[r])});r.append("g").attr("class","x axis").attr("transform","translate(0,"+height+")").call(sugarloaf.summary_xAxis),r.append("g").attr("class","y axis").call(sugarloaf.summary_yAxis)}var filename_status="/api/current",filename_summary="/api/summary",WIDTH=300,HEIGHT=200,MARGINS={top:10,left:30,right:20,bottom:20},sugarloaf={};sugarloaf.difficulty_order={beginner:1,intermediate:2,black:3,"double-black":4,"terrain-park":5},sugarloaf.parseDate=d3.time.format("%Y-%m-%dT%H:%M:%S"),d3.json(filename_status,function(a){sugarloaf.data=a,buildCharts()}),d3.json(filename_summary,function(a){sugarloaf.summary=a,buildSummaryChart(sugarloaf.summary)});