Skip to content

Commit 7fb718c

Browse files
Comments and TODO added
1 parent 382b94e commit 7fb718c

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

js/jquery.speedtest.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
(function($) {
3+
// A simple speedtest plugin to check download speed in a network.
4+
//Author : Harsha Jagadish
5+
//Version : V 0.1
6+
// TODO: Add waiting message and waiting image
37
$.fn._speedTest = function(options) {
48

59
function foo(){
@@ -13,7 +17,7 @@
1317
}, options),
1418
duration, download, startTime, endTime, bitsLoaded,cacheBuster,speedMbps,speedKbps,speedBps,p;
1519

16-
20+
// TODO: add more types to handle for download
1721
if (stest.fileType == "text") {
1822
download = new Document();
1923
} else if (stest.fileType == "image") {
@@ -30,6 +34,7 @@
3034
cacheBuster = "?spdt=" + startTime;
3135
download.src = stest.fileUrl + cacheBuster;
3236
p = function see(){
37+
// TODO: change the calculation to handle the error managment
3338
endTime = (new Date()).getTime();
3439
duration = (endTime - startTime) / 1000;
3540
bitsLoaded = stest.fileSize * 8;
@@ -46,8 +51,10 @@
4651

4752

4853
return this.each(function() {
54+
//TODO: remove too many variable names
4955
var g = foo();
50-
$(this).text(g);
56+
// TODO: make the speed extension as a variable to fit user needs
57+
$(this).text(g).append("  Mbps");
5158
}); //end of for each function
5259

5360
}; //end of the main function

js/jquery.speedtest.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

speedTest.html

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<!DOCTYPE html>
2+
<!-- A sample HTML file to have call the speedtest plugin
3+
** Author: Harsha Jagadish
4+
**Website:www.harshajagadish.com
5+
**
6+
-->
27
<html lang="en">
38
<head>
49
<meta charset="utf-8">
@@ -13,17 +18,32 @@
1318
<script src="https://cdn.jsdelivr.net/html5shiv/3.7.2/html5shiv.min.js"></script>
1419
<script src="https://cdn.jsdelivr.net/respond/1.4.2/respond.min.js"></script>
1520
<![endif]-->
21+
<style>
22+
.speed_container{
23+
margin:5% 0 0 25%;
24+
}
25+
</style>
1626
</head>
1727
<body>
18-
<h2 id="t">should display here if no error </h2>
19-
<p></p>
28+
<div class="container">
29+
<div class="col-sm-5 text-center speed_container">
30+
<div class="panel panel-default">
31+
<div class="panel-heading text-center">
32+
<h1 class="panel-title">Network Speed</h1>
33+
</div>
34+
<div class="panel-body text-center">
35+
<h3></h3>
36+
</div>
37+
</div>
38+
</div>
39+
</div>
2040
<script src="https://cdn.jsdelivr.net/jquery/2.1.3/jquery.min.js"></script>
2141
<script src="https://cdn.jsdelivr.net/bootstrap/3.3.5/js/bootstrap.min.js"></script>
2242
<script src="js/jquery.speedtest.js"></script>
2343
<script>
24-
$('p')._speedTest({
25-
fileSize:12800,
26-
fileType:"image",
44+
$('h3')._speedTest({
45+
fileSize:1280, //size of the file in bytes
46+
fileType:"image",//type of the file to be downloaded
2747
fileUrl:"http://mobinius.com/wp-content/uploads/2012/02/silicon-India.png"
2848
});
2949
</script>

0 commit comments

Comments
 (0)