<?php
/**
* Title: JavaScript Bandwidth Tester Demo
* WiseLoop JavaScript Bandwidth Tester Sample<br/>
*/
$theme = isset($_POST['theme']) ? $_POST['theme'] : 'default';
$mu = isset($_POST['mu']) ? $_POST['mu'] : 'Kbps';
$comparison = isset($_POST['comparison']) ? $_POST['comparison'] : true;
$ping = isset($_POST['ping']) ? $_POST['ping'] : true;
$download = isset($_POST['download']) ? $_POST['download'] : true;
$cost = isset($_POST['cost']) ? $_POST['cost'] : true;
$animate = isset($_POST['animate']) ? $_POST['animate'] : true;
$upload = isset($_POST['upload']) ? $_POST['upload'] : true;
$dialog = isset($_POST['dialog']) ? $_POST['dialog'] : false;
?>
<div class="row">
<div class="col-sm-6">
<div class="well well-sm">
<form action="" id="form" method="POST" enctype="multipart/form-data" role="form">
<h3>Plugin Options</h3>
<div class="checkbox">
<input type="hidden" name="ping"/>
<label><input type="checkbox" id="ping" name="ping" <?php echo $ping ? 'checked' : ''; ?>/> Ping Time measurement</label>
</div>
<div class="checkbox">
<input type="hidden" name="download"/>
<label><input type="checkbox" id="download" name="download" <?php echo $download ? 'checked' : ''; ?>/> Test Download Speed</label>
</div>
<div class="checkbox">
<input type="hidden" name="upload"/>
<label><input type="checkbox" id="upload" name="upload" <?php echo $upload ? 'checked' : ''; ?>/> Test Upload Speed</label>
</div>
<div class="checkbox">
<input type="hidden" name="comparison"/>
<label><input type="checkbox" id="comparison" name="comparison" <?php echo $comparison ? 'checked' : ''; ?>/> Show comparison chart</label>
</div>
<div class="checkbox">
<input type="hidden" name="cost"/>
<label><input type="checkbox" id="cost" name="cost" <?php echo $cost ? 'checked' : ''; ?>/> Show internet cost</label>
</div>
<div class="checkbox">
<input type="hidden" name="animate"/>
<label><input type="checkbox" id="animate" name="animate" <?php echo $animate ? 'checked' : ''; ?>/> Animate</label>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-3">
<label for="theme">Theme:</label>
</div>
<div class="col-sm-7">
<select id="theme" name="theme" class="form-control">
<?php
$dh = @opendir(dirname(__FILE__) . '/../javascript-bandwidth-tester/bins/css');
if ($dh) {
while (false !== ($file = readdir($dh))) {
if ($file !== '.' && $file !== '..' && substr($file, -4) === '.css') {
$file1 = str_replace('.css', '', $file);
echo '<option ' . ($theme == $file1 ? 'selected' : '') . ' value="' . $file1 . '">' . $file1 . '</option>';
}
}
@closedir($dh);
}
?>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-3">
<label for="mu">Measure unit:</label>
</div>
<div class="col-sm-7">
<select id="mu" name="mu" class="form-control">
<option value="bps" <?php echo $mu == 'bps' ? 'selected' : ''; ?>>bps</option>
<option value="Bps" <?php echo $mu == 'Bps' ? 'selected' : ''; ?>>Bps</option>
<option value="Kbps" <?php echo $mu == 'Kbps' ? 'selected' : ''; ?>>Kbps</option>
<option value="KBps" <?php echo $mu == 'KBps' ? 'selected' : ''; ?>>KBps</option>
<option value="Mbps" <?php echo $mu == 'Mbps' ? 'selected' : ''; ?>>Mbps</option>
<option value="MBps" <?php echo $mu == 'MBps' ? 'selected' : ''; ?>>MBps</option>
<option value="Gbps" <?php echo $mu == 'Gbps' ? 'selected' : ''; ?>>Gbps</option>
<option value="GBps" <?php echo $mu == 'GBps' ? 'selected' : ''; ?>>GBps</option>
</select>
</div>
</div>
</div>
<input type="hidden" name="dialog"/>
<div class="checkbox">
<label><input type="checkbox" id="dialog" name="dialog" <?php echo $dialog ? 'checked' : ''; ?>/> Show Results in a Dialog</label>
</div>
<button id="button-start" onclick="this.form.submit();" class="btn btn-primary btn-block">Start the Bandwidth Test</button>
</form>
</div>
</div>
<div class="col-sm-6">
<div class="well well-sm">
<div id="wl-bwt"></div>
<?php echo wlDemoUtils::renderModal('myModal', 'WiseLoop JavaScript Bandwidth Test jQuery Plugin', '<div id="wl-bwt-modal" class="wl-bwt"></div>', '');?>
</div>
</div>
</div>
<script type="text/javascript" src="/../php-javascript-obfuscator/bin/jso.php?rjs=wl-javascript-bandwidth-tester/jQuery.wlBWT.js"></script>
<script type="text/javascript">
$(document).ready( function(){
var modal = '<?php echo $dialog; ?>';
var domElement = '#wl-bwt';
if(modal=='on') {
domElement = '#wl-bwt-modal';
$('#myModal').modal();
}
$(domElement).wlBWt({
BinPath: '<?php echo $packageUrl . '/bins'; ?>',
Theme: '<?php echo $theme; ?>',
ShowComparison: '<?php echo $comparison; ?>',
TestPing: '<?php echo $ping; ?>',
TestDownload: '<?php echo $download; ?>',
TestUpload: '<?php echo $upload; ?>',
ShowCost: '<?php echo $cost; ?>',
SpeedMU: '<?php echo $mu; ?>',
AnimationDuration: <?php echo $animate ? '400' : '0'; ?>
});
});
</script>