Support Overview

Tutorials

Usage Examples

Upgrade Information

FAQ

New Release History

You are here:   Visualware >   MyConnection Server >   Support >   Usage Examples >   Using a timer for the test duration and hiding the applet

Using a timer for the test duration and hiding the applet

The example below shows a basic timer for the duration of the test and then shows the results once the test is complete. This process sets the applet size to 1x1 which essentially hides the applet from view.

NOTE: In the most recent Java release it is often necessary to "click" on an applet to permit its use. If the applet is hidden, like in this example, it may not load or run as expected. Click here to view the test applet so it can be allowed. Some browsers will show a ribbon near at the top of the page asking user to ALLOW. It shouldn't be necessary to click the link above if this occurs.

Minutes Seconds
0
0

Code Required

The code below just needs to be copied into a web page at the position the applet is to appear. The only change that will be needed is the codebase, highligted in red below. This should be changed to the address of your MyConnection Server installation.

NOTE: The last param tag has been truncated to fit this page, make sure this line is whole once pasted.

<div id="timer" style="display:block;">
<table cellspacing="5" cellpadding="0" align="center" width="300">
<tr>
<td style="font-size:30px;" align="center">Minutes</td>
<td style="font-size:30px;" align="center">Seconds</td>
</tr>
<tr>
<td align="center"><div id="minutes" style="font-size:50px;">0</div></td>
<td align="center"><div id="seconds" style="font-size:50px;">0</div></td>
</tr>
</Table>
</div>
<applet mayscript name="mcs" code="myspeedserver/applet/myspeed.class" archive="/myspeed/myspeed_s_8.jar,/myspeed/plugins_s_8.jar" codebase=""http://mcsiad.visualware.com/myspeed" width="1" height="1">
<param name="testspecid" value="-2">
<param name="permissions" value="all-permissions">
<param name="autostart" value="yes">
<param name="js" value="passResults($MSSID$,$DETAILLINK$,$SPEED.DSPEED$,$SPEED.USPEED$,$SPEED.QOS$,$SPEED.UQOS$,$SPEED.RTT$,
$SPEED.AVGRTT$,$SPEED.RTTCONSISTENCY$,$SPEED.MAXPAUSE$,$SPEED.BANDWIDTH$,$SPEED.ROUTESPEED$,$SPEED.FORCEDIDLE$)">
</APPLET>
<div id="results" style="display:none;"></div>


Copy and paste the entire code below into the opening <head></head> section of your page. This includes a basic timer function, a function that displays the results of the test in a table and lastly a function that adds commas to large numbers.

The URL in BLUE below will also require changing to the correct MyConnection Server installation.

<script type="text/javascript">
var testtimer;
var seconds = -1;
var minutes = 0;

function startTimer() {

if (seconds < 59 || seconds == -1) {
seconds = seconds+1;
}
else {
seconds = 0;
minutes = minutes+1;

}

document.getElementById('seconds').innerHTML = seconds;
document.getElementById('minutes').innerHTML = minutes;
window.testtimer = setTimeout(function(){startTimer()},1000);

}

// Function called when the test has completed
function passResults(mssid,detaillink,downspeed,upspeed,downqos,upqos,minrtt,avgrtt,rttconsistency,maxdelay,bandwidth,routespeed,forcedidle) {

clearTimeout(window.testtimer);
document.getElementById('timer').innerHTML = "<b>Test Complete</b>";

downToKbps = addCommas(Math.round(downspeed/1000));
upToKbps = addCommas(Math.round(upspeed/1000));
bwToKbps = addCommas(Math.round(bandwidth/1000));
rtToKbps = addCommas(Math.round(routespeed/1000));

// Creates the results text
var emailbody = "";

emailbody += "<b>Speed Test Results</b><br><br>";
emailbody += "MSSID:" + mssid + "<br>";
emailbody += "<a href='http://mcsiad.visualware.com/myspeed/db/report?id=" + mssid + "'>Database Report</a><br><br>";
emailbody += "Download Speed: " + downToKbps + " Kbps <br>";
emailbody += "Upload Speed: " + upToKbps + " Kbps <br>";
emailbody += "Download Consistency of Service: " + downqos + "% <br>";
emailbody += "Upload Consistency of Service: " + upqos + "% <br>";
emailbody += "Min RTT: " + minrtt + "ms <br>";
emailbody += "Avg RTT: " + avgrtt + "ms <br>";
emailbody += "RTT Consistency: " + rttconsistency + "% <br>";
emailbody += "Max Pause: " + maxdelay + "ms <br>";
emailbody += "Bandwidth: " + bwToKbps + " Kbps <br>";
emailbody += "Route Speed: " + rtToKbps + " Kbps <br>";
emailbody += "Forced Idle: " + forcedidle + "% <br>";

// Populates in innerHTML with results
document.getElementById("results").innerHTML = emailbody;

// Makes the DIV visible
document.getElementById("results").style.display = 'block';
}

// Function used to add commas
function addCommas(str){

var arr,int,dec;
str += '';

arr = str.split('.');
int = arr[0] + '';
dec = arr.length>1?'.'+arr[1]:'';

return int.replace(/(\d)(?=(\d{3})+$)/g,"$1,") + dec;
}
</script>


 

MyConnection Server

Home
Online Testing Portal
Download
Purchase
Resources
Support

Visualware Products

VisualRoute
eMailTrackerPro
Visual IP Trace

   

© Visualware Inc. 2014 - All Rights Reserved