(function(w, d) { 'use strict'; var addInteraction = function($, $table) { if(typeof $ === 'undefined' || !$table.find('.inside').length) return waiting(); var $tableParent = $table.parent(), $inside = $table.find('.inside'), $nav = $inside.find('.nav'), $top = $table.find('.top'), $timeline = $top.find('.timeline'), $div = $inside.find('div'), $dt = $inside.find('dt'), tableWidth; tableWidth = getTableWidth($table, $div); addTitles($dt); $inside.addClass('hidden'); //Hiding content from tabs, but first $div.css('width', tableWidth - 10).addClass('hidden').end() .find('div:first').removeClass('hidden'); $nav.find('li:first-child').addClass('active'); //Tabs clicks listener $nav.on('click', 'a', tabsListener); //Middle click to open url $top.find('td.url').find('div > a').click(middleClickListener); //Toggle request click $top.click(requestClickListener); totalStartTime($top); applyTooltip($top, $timeline, $tableParent); applyPopover($timeline, $tableParent, $('.sh-table').length > 1); stupidtable($table); $('.sh-loader').hide(); }, waiting = function() { if(typeof jQuery === 'undefined' || !jQuery('.inside').length) return setTimeout(waiting, 500); jQuery(function() { jQuery('.sh-table').each(function() { addInteraction(jQuery, jQuery(this)); }); }); }, getTableWidth = function($table, $div) { $div.hide(); var width = $table.width(); $div.show(); return width; }, //Adding title attribute to large descriptions addTitles = function($dt) { var i = 0, ilen = $dt.length, _$dt, text; for(;i 18) _$dt.attr('title', text); } }, applyTooltip = function($top, $timeline, $container) { var tooltipOpt = { placement:'right', trigger: 'hover', html:true, container:$container }; $top.find('td.size') .add($timeline.find('span.domloaded, span.renderstarted')) .tooltip(tooltipOpt); tooltipOpt.placement = 'left'; $top.find('td.status, td.type') .add($timeline.find('span.windowloaded')) .tooltip(tooltipOpt); }, applyPopover = function($timeline, $container, topBottom) { var i = 0, ilen = $timeline.length; if(ilen > 15 || topBottom) { for(ilen=Math.floor($timeline.length/2);i 80 || (widthPct > 80 && spacePct > 20)) $startTime.css('right', (100.5 - spacePct) + '%'); else if(widthPct > 80) $startTime.css({left:'5px', fontWeight:'bold'}); else $startTime.css('left', (widthPct + 0.5) + '%'); } }, stupidtable = function($table) { if($table.stupidtable) { $table.stupidtable({ url:function(a, b) { a = a.split('\n')[5].replace(/^\s*/g, '').split('?')[0].split('#')[0]; b = b.split('\n')[5].replace(/^\s*/g, '').split('?')[0].split('#')[0]; if(a < b) return -1; else if(a > b) return 1; else return 0; }, timeline:function(a, b) { a = parseInt(a.split('\n')[3].replace(/^\s*/g, ''),10); b = parseInt(b.split('\n')[3].replace(/^\s*/g, ''),10); return b - a; } }); $table.bind('beforetablesort', function() { jQuery('tr.top.opened').click(); jQuery('.sh-loader').show(); }); $table.bind('aftertablesort', function() { jQuery('.sh-loader').hide(); }); } }; if(!d.getElementById('harParser')) { var div = d.createElement('div'); div.className = 'sh-loader'; d.body.appendChild(div); } w.addInteraction = addInteraction; $('.sh-loader').show(); $('.sh-container').hide(); $( window ).load(function() { $('.sh-loader').hide(); $('.sh-container').show(); jQuery(function() { jQuery('.sh-table').each(function() { addInteraction(jQuery, jQuery(this)); }); }); }); })(window, document);