Skip to content

Commit

Permalink
Added a multi-waterfall view to the filmstrip results where the water…
Browse files Browse the repository at this point in the history
…falls are overlaid with adjustable transparency.
  • Loading branch information
pmeenan committed Sep 3, 2013
1 parent f63275e commit 755a5bd
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 196 deletions.
16 changes: 8 additions & 8 deletions www/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,18 @@ if (strlen($id)) {
if (gz_is_file("$testPath/testinfo.json")) {
$test['testinfo'] = json_decode(gz_file_get_contents("$testPath/testinfo.json"), true);
if (isset($test['testinfo'])) {
if( isset($test['testinfo']['completed']))
if( array_key_exists('completed', $test['testinfo']))
$testDate = strftime('%x %X', (int)$test['testinfo']['completed'] + ($tz_offset * 60));
if (isset($test['testinfo']['owner']) && strlen($owner) && $owner == $test['testinfo']['owner'])
if (array_key_exists('owner', $test['testinfo']) && strlen($owner) && $owner == $test['testinfo']['owner'])
$isOwner = true;
elseif (isset($test['testinfo']['uid']) && strlen($uid) && $uid == $test['testinfo']['uid'])
elseif (array_key_exists('uid', $test['testinfo']) && strlen($uid) && $uid == $test['testinfo']['uid'])
$isOwner = true;

$url = htmlspecialchars($test['testinfo']['url']);
$dom = htmlspecialchars($test['testinfo']['domElement']);
$login = htmlspecialchars($test['testinfo']['login']);
$blockString = htmlspecialchars($test['testinfo']['block']);
$label = htmlspecialchars($test['testinfo']['label']);
$url = array_key_exists('url', $test['testinfo']) ? htmlspecialchars($test['testinfo']['url']) : null;
$dom = array_key_exists('domElement', $test['testinfo']) ? htmlspecialchars($test['testinfo']['domElement']) : null;
$login = array_key_exists('login', $test['testinfo']) ? htmlspecialchars($test['testinfo']['login']) : null;
$blockString = array_key_exists('block', $test['testinfo']) ? htmlspecialchars($test['testinfo']['block']) : null;
$label = array_key_exists('label', $test['testinfo']) ? htmlspecialchars($test['testinfo']['label']) : null;
}
}

Expand Down
14 changes: 11 additions & 3 deletions www/video/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,22 @@ function ScreenShotTable()
</div>
<?php
// display the waterfall if there is only one test
if( count($tests) == 1 )
{
if( count($tests) == 1 ) {
$data = loadPageRunData($tests[0]['path'], $tests[0]['run'], $tests[0]['cached']);
$secure = false;
$haveLocations = false;
$requests = getRequests($tests[0]['id'], $tests[0]['path'], $tests[0]['run'], $tests[0]['cached'], $secure, $haveLocations, true, true);
InsertWaterfall('', $requests, $tests[0]['id'], $tests[0]['run'], $tests[0]['cached'], $data, "&max=$filmstrip_end_time&mime=1&state=1&cpu=0&bw=0" );
echo '<br><br>';
} else {
$waterfalls = array();
foreach ($tests as &$test) {
$waterfalls[] = array('id' => $test['id'],
'label' => $test['name'],
'run' => $test['run'],
'cached' => $test['cached']);
}
InsertMultiWaterfall($waterfalls, "&max=$filmstrip_end_time&mime=1&state=1&cpu=0&bw=0");
}
?>

Expand All @@ -625,7 +634,6 @@ function ScreenShotTable()
<input id="advanced-ok" type=button class="simplemodal-close" value="OK">
</div>
<?php
echo '<br><br>';
} // EMBED
// scroll the table to show the first thumbnail change
$scrollPos = $firstFrame * ($thumbSize + 8);
Expand Down
41 changes: 41 additions & 0 deletions www/waterfall.inc
Original file line number Diff line number Diff line change
Expand Up @@ -986,4 +986,45 @@ function InsertWaterfall($url, &$requests, $id, $run, $cached, &$page_data, $wat
echo "</script>";
}

function InsertMultiWaterfall(&$waterfalls, $waterfall_options) {
require_once('./object_detail.inc');
$opacity = number_format(1.0 / count($waterfalls), 2, '.', '');
echo '<div class="waterfall-container" style="text-align: left;margin-top:10em;">';
echo 'Waterfall Opacity (adjust sliders to adjust the transparency of the given waterfall):<br>';
echo '<table>';
$row_count = 0;
foreach($waterfalls as $index => &$waterfall) {
$o = $index ? $opacity : '1.0';
echo '<tr>';
echo "<td>{$waterfall['label']}</td><td><input type=\"range\" class=\"waterfall-transparency\" name=\"waterfall-$index\" min=\"0.0\" max=\"1.0\" step=\"0.01\" value=\"$o\"></td>";
echo '</tr>';
$test_path = null;
$requests = getRequests($waterfall['id'], $test_path, $waterfall['run'], $waterfall['cached'], $has_secure_requests, $has_locations, false, false);
if (isset($requests) && is_array($requests)) {
$count = count($requests);
if ($count > $row_count)
$row_count = $count;
}
}
echo '</table>';
echo '</div>';

$height_style = '';
if ($row_count) {
$row_height = imagefontheight(2) + 4;
$data_header_height = intval($row_height * 3 / 2);
$data_footer_height = $row_height;
$height = ($data_header_height + ($row_height * $row_count) +
$data_footer_height + 2);
$height += (2 * $row_height) + 2;
$height_style = "height:{$height}px;";
}
echo "<div style=\"background-color: #fff;$height_style\" class=\"waterfall-container\">";
foreach($waterfalls as $index => &$waterfall) {
$o = $index ? $opacity : '1.0';
echo "<img style=\"display:block;opacity:$o;position:absolute;top:0;left:0;\" class=\"waterfall-image\" alt=\"\" id=\"waterfall-$index\" src=\"/waterfall.php?test={$waterfall['id']}&run={$waterfall['run']}&cached={$waterfall['cached']}$waterfall_options\">";
}
echo '<div id="marker"></div>';
echo '</div>';
}
?>
Loading

0 comments on commit 755a5bd

Please sign in to comment.