Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions www/assets/js/country-list/country-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

((window) => {
class CountrySelector {
constructor(selector, subdivisionSelector, isoCompliantJsonBlob) {
constructor(selector, subdivisionSelector, isoCompliantJsonBlob, initialCountry, initialState) {
this.countryList = isoCompliantJsonBlob;
this.countries = Object.keys(this.countryList).map((code) => {
return {
Expand All @@ -22,9 +22,12 @@

this.countrySelector = selector;
this.subdivisionSelector = subdivisionSelector;
this.countrySelector.value = initialCountry;

// Fill in subdivisions
this.fillSubdivision(this.countries[0].code);
this.fillSubdivision(initialCountry ?? this.countries[0].code);

this.subdivisionSelector.value = initialState;

// Attach listener
this.countrySelector.addEventListener("change", (e) => {
Expand All @@ -47,6 +50,7 @@
}

fillSubdivision(countryCode) {
this.subdivisionSelector.value = undefined;
const divisions = this.getSubdivisions(countryCode);
const opts = Object.keys(divisions).map((key) => {
return new Option(divisions[key], key);
Expand All @@ -60,4 +64,4 @@
}

window.CountrySelector = CountrySelector;
})(window);
})(window);
2 changes: 1 addition & 1 deletion www/constants.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define('SETTINGS_PATH', realpath(WWW_PATH . '/settings/'));
define('TEMP_DIR', realpath(WWW_PATH . '/tmp/'));
define('OE_PATH', realpath(WWW_PATH . '/experiments/'));

define('WPT_SALT', '2502'); // used to force assets hash
define('WPT_SALT', '2503'); // used to force assets hash
define('VER_WEBPAGETEST', '21.07'); // webpagetest version
define('VER_TYPOGRAPHY_CSS', @md5_file(ASSETS_PATH . '/css/typography.css') . WPT_SALT); // version of the typography css file
define('VER_LAYOUT_CSS', @md5_file(ASSETS_PATH . '/css/layout.css') . WPT_SALT); // version of the layout css file
Expand Down
22 changes: 11 additions & 11 deletions www/jsonResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

if ($ret['statusCode'] == 200) {
$protocol = getUrlProtocol();
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$urlStart = "$protocol://$host$uri";

$testInfo = TestInfo::fromValues($id, $testPath, $test);
Expand Down Expand Up @@ -107,14 +107,14 @@
function getRequestInfoFlags()
{
$getFlags = array(
"average" => JsonResultGenerator::WITHOUT_AVERAGE,
"standard" => JsonResultGenerator::WITHOUT_STDDEV,
"median" => JsonResultGenerator::WITHOUT_MEDIAN,
"runs" => JsonResultGenerator::WITHOUT_RUNS,
"requests" => JsonResultGenerator::WITHOUT_REQUESTS,
"console" => JsonResultGenerator::WITHOUT_CONSOLE,
"lighthouse" => JsonResultGenerator::WITHOUT_LIGHTHOUSE,
"rv" => JsonResultGenerator::WITHOUT_REPEAT_VIEW
"average" => JsonResultGenerator::WITHOUT_AVERAGE,
"standard" => JsonResultGenerator::WITHOUT_STDDEV,
"median" => JsonResultGenerator::WITHOUT_MEDIAN,
"runs" => JsonResultGenerator::WITHOUT_RUNS,
"requests" => JsonResultGenerator::WITHOUT_REQUESTS,
"console" => JsonResultGenerator::WITHOUT_CONSOLE,
"lighthouse" => JsonResultGenerator::WITHOUT_LIGHTHOUSE,
"rv" => JsonResultGenerator::WITHOUT_REPEAT_VIEW
);

$infoFlags = array();
Expand All @@ -127,4 +127,4 @@ function getRequestInfoFlags()
$infoFlags[] = JsonResultGenerator::BASIC_INFO_ONLY;
}
return $infoFlags;
}
}
31 changes: 8 additions & 23 deletions www/templates/account/billing/update-payment-confirm-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
<label for="state">State</label>
<div>
<select autocomplete="off" name="state" data-country-selector="state-selector" required>

<?php foreach ($state_list as $state) : ?>
<option value="<?= $state['code'] ?>" <?php if ($state['code'] == $state_code) {
echo 'selected';
} ?>>
<?php foreach ($state_list as $state): ?>
<option value="<?= $state['code'] ?>">
<?= $state['name']; ?>
</option>
<?php endforeach; ?>
Expand All @@ -45,21 +42,8 @@
<div class="info-container country">
<label for="country">Country</label>
<select autocomplete="off" name="country" data-country-selector="selector" required>
<?php foreach ($country_list as $country) : ?>
<?php
$current_code = $country["code"];
$selected_country = false;
if (isset($country_code) && !is_null($country_code)) {
if ($current_code == $country_code) {
$selected_country = true;
}
} else {
if ($current_code == 'US') {
$selected_country = true;
}
}
?>
<option value="<?= $country["code"] ?>" <?= $selected_country ? 'selected' : '' ?>>
<?php foreach ($country_list as $country): ?>
<option value="<?= $country["code"] ?>">
<?= $country["name"]; ?>
</option>
<?php endforeach; ?>
Expand All @@ -83,18 +67,19 @@
<script>
(() => {
const countryList = <?= $country_list_json_blob ?>;
const initialCountry = "<?= $country_code ?>";
const initialState = "<?= $state_code ?>";
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", () => {
const countrySelectorEl = document.querySelector("[data-country-selector=selector]");
const divisionSelectorEl = document.querySelector("[data-country-selector=state-selector]");

new CountrySelector(countrySelectorEl, divisionSelectorEl, countryList);
new CountrySelector(countrySelectorEl, divisionSelectorEl, countryList, initialCountry, initialState);
});
} else {
const countrySelectorEl = document.querySelector("[data-country-selector=selector]");
const divisionSelectorEl = document.querySelector("[data-country-selector=state-selector]");

new CountrySelector(countrySelectorEl, divisionSelectorEl, countryList);
new CountrySelector(countrySelectorEl, divisionSelectorEl, countryList, initialCountry, initialState);
}
})();
</script>
Expand Down
2 changes: 1 addition & 1 deletion www/templates/account/includes/signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<tr>
<th scope="col">Locations</th>
<td>30</td>
<td>40 <sup><a href="#fn1" id="ref1">*</a></sup></td>
<td>35+<sup><a href="#fn1" id="ref1">*</a></sup></td>
</tr>

<tr>
Expand Down
4 changes: 2 additions & 2 deletions www/templates/account/plans/upgrade-plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
<tr>
<th scope="col">Locations</th>
<td>30</td>
<td>40<sup><a href="#fn1" id="ref2">*</a></sup></td>
<td>40<sup><a href="#fn1" id="ref1">*</a></sup></td>
<td>35+<sup><a href="#fn1" id="ref2">*</a></sup></td>
<td>35+<sup><a href="#fn1" id="ref1">*</a></sup></td>
</tr>

<tr>
Expand Down
4 changes: 2 additions & 2 deletions www/templates/account/signup/step-1.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
<tr>
<th scope="col">Locations</th>
<td>30</td>
<td>40<sup><a href="#fn1" id="ref2">*</a></sup></td>
<td>40<sup><a href="#fn1" id="ref1">*</a></sup></td>
<td>35+<sup><a href="#fn1" id="ref2">*</a></sup></td>
<td>35+<sup><a href="#fn1" id="ref1">*</a></sup></td>
</tr>

<tr>
Expand Down
68 changes: 37 additions & 31 deletions www/testStatus.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ $testQueue = array();
$testInfoJson = null;

/**
* Get the status of the given test ID (and return the info in an array)
*
*/
* Get the status of the given test ID (and return the info in an array)
*
*/
function GetTestStatus($id, $includePosition = true)
{
$testServer = GetServerForTest($id);
if (isset($testServer)) {
// Proxy the status through the server that actually owns the test
// Proxy the status through the server that actually owns the test
$pos = $includePosition ? '1' : '0';
$status = json_decode(http_fetch("{$testServer}testStatus.php?test=$id&pos=$pos"), true);
if (is_array($status) && isset($status['data'])) {
Expand All @@ -30,7 +30,7 @@ function GetTestStatus($id, $includePosition = true)
}
$testPath = './' . GetTestPath($id);

// Fast-path for pending tests when we don't need to know the queue position (avoid test and location locks)
// Fast-path for pending tests when we don't need to know the queue position (avoid test and location locks)
if (file_exists("$testPath/test.scheduled") && !file_exists("$testPath/.archived")) {
$ret = array('statusCode' => 101, 'statusText' => 'Test pending', 'id' => $id);
$status = GetSchedulerTestStatus($id);
Expand All @@ -47,10 +47,12 @@ function GetTestStatus($id, $includePosition = true)
$ret['statusText'] = "Waiting at the front of the queue...";
}
} else {
$ret = array('statusCode' => 100,
'statusText' => 'Test just started',
'startTime' => gmdate("m/d/y G:i:s"),
'id' => $id);
$ret = array(
'statusCode' => 100,
'statusText' => 'Test just started',
'startTime' => gmdate("m/d/y G:i:s"),
'id' => $id
);
}
}
return $ret;
Expand All @@ -71,10 +73,12 @@ function GetTestStatus($id, $includePosition = true)
@unlink("$testPath/test.requeued");
@unlink("$testPath/test.running");
} else {
$ret = array('statusCode' => 100,
'statusText' => 'Test just started',
'startTime' => gmdate("m/d/y G:i:s", filemtime("$testPath/test.running")),
'id' => $id);
$ret = array(
'statusCode' => 100,
'statusText' => 'Test just started',
'startTime' => gmdate("m/d/y G:i:s", filemtime("$testPath/test.running")),
'id' => $id
);
$testInfoJson = GetTestInfo($id);
PopulateTestInfoJson($ret, $testInfoJson);
if ($elapsed == 0) {
Expand All @@ -98,10 +102,12 @@ function GetTestStatus($id, $includePosition = true)
return $ret;
}
} elseif (is_file("$testPath/test.complete") || file_exists("$testPath/.archived")) {
$ret = array('statusCode' => 200,
'statusText' => 'Test Complete',
'id' => $id,
'completeTime' => gmdate("m/d/y G:i:s", filemtime("$testPath/test.complete")));
$ret = array(
'statusCode' => 200,
'statusText' => 'Test Complete',
'id' => $id,
'completeTime' => gmdate("m/d/y G:i:s", filemtime("$testPath/test.complete"))
);
$testInfoJson = GetTestInfo($id);
PopulateTestInfoJson($ret, $testInfoJson);
return $ret;
Expand Down Expand Up @@ -152,7 +158,7 @@ function GetTestStatus($id, $includePosition = true)
}
if (
(array_key_exists('started', $testInfoJson) &&
$testInfoJson['started']) ||
$testInfoJson['started']) ||
isset($test['test']['completeTime'])
) {
$ret['startTime'] = isset($test['test']['startTime']) ? $test['test']['startTime'] : $now;
Expand All @@ -174,9 +180,9 @@ function GetTestStatus($id, $includePosition = true)
} else {
$ret['statusCode'] = 100;
if ($elapsed == 0) {
$ret['statusText'] = "Test just started";
$ret['statusText'] = "Test just started";
} elseif ($elapsed == 1) {
$ret['statusText'] = "Test Started $elapsed second ago";
$ret['statusText'] = "Test Started $elapsed second ago";
} elseif ($elapsed < 60) {
$ret['statusText'] = "Test Started $elapsed seconds ago";
} else {
Expand Down Expand Up @@ -241,7 +247,7 @@ function GetTestStatus($id, $includePosition = true)
$rvRuns = 0;
for ($run = 1; $run <= $runs; $run++) {
if (gz_is_file("$testPath/{$run}_IEWPG.txt") || gz_is_file("$testPath/{$run}_devtools.json.txt")) {
$fvRuns++;
$fvRuns++;
}
if (gz_is_file("$testPath/{$run}_Cached_IEWPG.txt") || gz_is_file("$testPath/{$run}_Cached_devtools.json.txt")) {
$rvRuns++;
Expand All @@ -261,14 +267,14 @@ function GetTestStatus($id, $includePosition = true)
$ret['statusText'] = "Completed {$ret['testsCompleted']} of {$ret['testsExpected']} tests";
}

// TODO: Add actual summary-result information
// TODO: Add actual summary-result information
}
} else {
if ($includePosition && array_key_exists('workdir', $testInfoJson)) {
$count = FindJobPosition($testInfoJson['location'], $testInfoJson['workdir'], $id);
if ($count >= 0) {
$ret['statusCode'] = 101;
$ret['behindCount'] = $count;
$ret['statusCode'] = 101;
$ret['behindCount'] = $count;
if ($count > 1) {
$ret['statusText'] = "Waiting behind $count other tests...";
} elseif ($count == 1) {
Expand All @@ -286,7 +292,7 @@ function GetTestStatus($id, $includePosition = true)
$ret['statusCode'] = 401;
$ret['statusText'] = 'Test request not found';

// Force the test to end - something went Very Wrong (tm)
// Force the test to end - something went Very Wrong (tm)
$lock = LockTest($id);
if ($lock) {
$testInfoJson = GetTestInfo($id);
Expand All @@ -295,7 +301,7 @@ function GetTestStatus($id, $includePosition = true)
$test = file_get_contents("$testPath/testinfo.ini");
$date = gmdate("m/d/y G:i:s", $now);

// Update the completion time if it isn't already set
// Update the completion time if it isn't already set
if (!strpos($test, 'completeTime')) {
$complete = "[test]\r\ncompleteTime=$date";
$out = str_replace('[test]', $complete, $test);
Expand Down Expand Up @@ -334,10 +340,10 @@ function GetTestStatusText($id)
}

/**
* Check the status of a batch test
*
* @param mixed $status
*/
* Check the status of a batch test
*
* @param mixed $status
*/
function GetBatchStatus(&$status)
{
$dirty = false;
Expand Down Expand Up @@ -469,7 +475,7 @@ function array2xml($array, $xml = false)

foreach ($array as $key => $value) {
if (is_array($value)) {
//get children
//get children
array2xml($value, $xml->addChild($key));
} else {
$xml->addChild($key, $value);
Expand Down