Files
YellowLabTools/app/node_views/launchTest.html
T

97 lines
3.4 KiB
HTML

<html>
<head>
<meta charset="utf-8">
<title>Yellow Lab Tools - Awaiting</title>
<link rel="icon" type="image/png" href="/public/img/favicon.png">
<link rel="stylesheet" type="text/css" href="/public/styles/main.css">
<link rel="stylesheet" type="text/css" href="/public/styles/launchTest.css">
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<h1>Yellow Lab <span class="icon-lab"></span> Tools</h1>
<div id="status"></div>
<div>%%TEST_URL%%</div>
<div class="footer">
<p><b>Yellow Lab Tools</b> is an open source project by <a href="http://www.gaelmetais.com" target="_blank">Gaël Métais</a>, based on <a href="https://github.com/macbre/phantomas" target="_blank">Phantomas</a>.<br>If you like it, <a href="https://github.com/gmetais/YellowLabTools" target="_blank" class="star">give it a <span>&#9733;</span> on GitHub</a>!</p>
</div>
<script>
var testId = '%%TEST_ID%%';
var statusElement = document.getElementById('status');
var socket = io();
function askStatus() {
socket.emit('waiting', testId);
}
socket.on('position', function(position) {
if (position === 0) {
statusElement.innerHTML = 'Test is running...';
} else {
statusElement.innerHTML = 'Waiting behind ' + (position) + ' other tests';
}
sendPositionInQueueToGA(position);
// Rotate the spinner
document.body.className = 'waiting';
});
socket.on('complete', function() {
statusElement.innerHTML = 'Test complete';
window.location.replace('/results/' + testId);
// Stop the spinner
document.body.className = '';
});
socket.on('failed', function() {
statusElement.innerHTML = 'Test failed';
window.location.replace('/results/' + testId);
// Stop the spinner
document.body.className = '';
});
socket.on('404', function() {
statusElement.innerHTML = 'Test not found';
// Stop the spinner
document.body.className = '';
});
socket.on('reconnect_error', function() {
statusElement.innerHTML = "Server reboot. Please start a new test."
// Stop the spinner
document.body.className = '';
});
askStatus();
var GA_ID = '%%GA_ID%%';
if (GA_ID.length > 0 && window.location.host === 'yellowlab.tools') {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', GA_ID, 'auto');
}
// Need stats on average queue position
var positionAlreadySent = false;
function sendPositionInQueueToGA(position) {
if (!positionAlreadySent && GA_ID.length > 0 && window.location.host === 'yellowlab.tools') {
ga('send', 'pageview', {
queuePosition: position
});
positionAlreadySent = true;
}
}
</script>
</body>
</html>