Sha256: d2d98af638c8a239a55e717089ef3733df89db9886951b12ad70e4c3ced168ef

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

'use strict';

jQuery(function($) {
  var reportPage = {
    selectTab: function(id) {
      $('#report .tabs .active, #sources.active, #events.active').removeClass('active');
      $(id).addClass('active');
      $('[href="' + id + '"]').addClass('active');
    },

    selectLine: function(id) {
      $('.source-line.focus').removeClass('focus');
      var fid = id.slice(6);
      var line = $('#line-' + fid);
      line.addClass('focus');
      reportPage.selectFile('#' + line.parents('.source').attr('id'));

      var offset = line.offset();
      var codeView = $('#source-code');
      codeView.scrollTop(offset.top - (codeView.height() / 2));

      reportPage.selectTab('#sources');
    },

    selectFile: function(id) {
      $('#source-code').scrollTop(0);
      $('#source-code .source').hide();
      $('.source-link.focus').removeClass('focus');

      $('.source-link a[href="' + id + '"]').parent().addClass('focus');
      $(id).show();
    }
  };

  $('#report .tabs a').on('click', function(e) {
    e.preventDefault();

    var href = $(this).attr('href');
    reportPage.selectTab(href);
  });

  $('#source-list a, #source-code .source .filename a').on('click', function(e) {
    e.preventDefault();

    var href = $(this).attr('href');
    reportPage.selectFile(href);
  });

  $('#events .backtraces a, #sources .source .line-info a').on('click', function(e) {
    e.preventDefault();

    var href = $(this).attr('href');
    reportPage.selectLine(href);
  });

  $('#events .event .event-name a').on('click', function(e) {
    e.preventDefault();

    var id = $(this).attr('href');
    $(id).find('> .event-info .event-payload').slideToggle();
    $(id).find('> .event-info').toggleClass('closed');
  });

  if(location.hash.startsWith('#line-')) {
    reportPage.selectLine(location.hash);
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
speed_gun-2.0.1 lib/speed_gun/app/public/report.js
speed_gun-2.0.0 lib/speed_gun/app/public/report.js