Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny3050 committed Sep 14, 2016
1 parent 991d98e commit e8dbcef
Show file tree
Hide file tree
Showing 35 changed files with 3,053 additions and 37 deletions.
Binary file added .DS_Store
Binary file not shown.
37 changes: 0 additions & 37 deletions .gitignore

This file was deleted.

Binary file added .previews/.DS_Store
Binary file not shown.
Binary file added .previews/preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .previews/preview_minimal.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .previews/preview_strength.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/.DS_Store
Binary file not shown.
Binary file added images/strength_almost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/strength_full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/strength_half.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/strength_none.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions internet-monitor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#downloadSpeedGauge, #uploadSpeedGauge{
width:200px; height:160px;
display: inline-block;
margin: 1em;
}
204 changes: 204 additions & 0 deletions internet-monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/**
* Created by debayan on 7/24/16.
*/

Widget.register("internet-monitor",{

defaults : {
},
payload: [],

downloadBarState: 'not_started',
updating: false,

start : function(){
console.log("Internet-monitor module started!");
this.sendSocketNotification('Start',this.config);
// Schedule update timer.
var self = this;
if(this.config.updateInterval != 0)
{
setInterval(function() {
self.updating= true;
self.sendSocketNotification('Start',self.config);
}, this.config.updateInterval);
}
},

getScripts: function(){
return [this.file('justgage-1.2.2/justgage.js'),this.file('justgage-1.2.2/raphael-2.1.4.min.js'),this.file('jquery.js')]
},

getStyles: function(){
return ["internet-monitor.css"]
},

addScript: function(mode){
var script = document.createElement('script');
if(this.config.type == 'minimal'){
script.innerHTML = 'var download, upload;' +
'download = new JustGage({' +
'id: "downloadSpeedGauge",' +
'value: ' + 0 + ',' +
'min: 0,' +
'max: 100,' +
'title: "Download Speed",' +
'refreshAnimationType:"linear",' +
'gaugeWidthScale: "0.8",' +
'valueFontColor: "#fff",' +
'valueFontFamily: "Roboto Condensed",' +
'titleFontFamily: "Roboto Condensed",' +
'titleFontColor: "#aaa",' +
'hideMinMax: true,'+
'gaugeColor: "#000",'+
'levelColors: ["#fff"],'+
'hideInnerShadow: true,'+
'symbol: "Mbps"});' +
'upload = new JustGage({' +
'id: "uploadSpeedGauge",' +
'value: ' + 0 + ',' +
'min: 0,' +
'max: 100,' +
'title: "Upload Speed",' +
'refreshAnimationType:"linear",' +
'gaugeWidthScale: "0.8",' +
'valueFontColor: "#fff",' +
'valueFontFamily: "Roboto Condensed",' +
'titleFontFamily: "Roboto Condensed",' +
'titleFontColor: "#aaa",' +
'hideMinMax: true,'+
'gaugeColor: "#000",'+
'levelColors: ["#fff"],'+
'hideInnerShadow: true,'+
'symbol: "Mbps"});';

}
else{
script.innerHTML = 'var download, upload;' +
'download = new JustGage({' +
'id: "downloadSpeedGauge",' +
'value: ' + 0 + ',' +
'min: 0,' +
'max: 100,' +
'title: "Download Speed",' +
'refreshAnimationType:"linear",' +
'gaugeWidthScale: "0.8",' +
'valueFontColor: "#fff",' +
'valueFontFamily: "Roboto Condensed",' +
'titleFontFamily: "Roboto Condensed",' +
'titleFontColor: "#aaa",' +
'symbol: "Mbps"});' +
'upload = new JustGage({' +
'id: "uploadSpeedGauge",' +
'value: ' + 0 + ',' +
'min: 0,' +
'max: 100,' +
'title: "Upload Speed",' +
'refreshAnimationType:"linear",' +
'gaugeWidthScale: "0.8",' +
'valueFontColor: "#fff",' +
'valueFontFamily: "Roboto Condensed",' +
'titleFontFamily: "Roboto Condensed",' +
'titleFontColor: "#aaa",' +
'symbol: "Mbps"});';
}
$(script).appendTo('body');

},

socketNotificationReceived: function(notification, payload){


if(notification == 'downloadSpeedProgress')
{
if(this.config.displaySpeed) {
if (this.downloadBarState == 'not_started') {
this.addScript();
this.downloadBarState = 'started';
}
console.log('updating DOWNLOAD');
download.refresh(payload, 100);
}

}
if(notification == 'uploadSpeedProgress')
{
if(this.config.displaySpeed) {
console.log('updating UPLOAD');
upload.refresh(payload,100);
}
}
if(notification == 'data')
{
if(this.config.verbose)
{
if(!this.updating)
{
var d = document.createElement("div");
d.style = 'text-align: left; display:inline-block;';
$(d).appendTo('#internetData');
}
$('#internetData > div').html(
' Server: ' + payload.server.host).append('<br/>' +
' Location: ' + payload.server.location + ' (' + payload.server.country + ')').append('<br/>' +
' Distance: ' + payload.server.distance + ' km').append("</div>");
}
}
if(notification == 'ping'){
if(this.downloadBarState == 'not_started')
this.updateDom();
if(this.config.displayStrength){
var d = null;
if(this.downloadBarState == 'not_started')
{
d = document.createElement("div");
$(d).appendTo('#pingDiv');
}
else{
d = document.getElementById('#pingDiv');
}
if(payload < 70){
$(d).append('<img src="' + window.location.href + '/widgets/internet-monitor//images/' + 'strength_full.png" width=' + this.config.strengthIconSize +'height=' + this.config.strengthIconSize +'/>');
}
else if(payload >= 70 && payload < 100){
$(d).append('<img src="' + window.location.href + '/widgets/internet-monitor//images/' + 'strength_almost.png" width=' + this.config.strengthIconSize +' height=' + this.config.strengthIconSize + '/>');
}
else if(payload >= 100 && payload < 150){
$(d).append('<img src="' + window.location.href + '/widgets/internet-monitor//images/' + 'strength_half.png" width=' + this.config.strengthIconSize +' height=' + this.config.strengthIconSize + '/>');
}
else if(payload >= 150)
{
$(d).append('<img src="' + window.location.href + '/widgets/internet-monitor//images/' + 'strength_none.png" width=' + this.config.strengthIconSize +' height=' + this.config.strengthIconSize + '/>');
}
}
}
},

getDom: function(){
var wrapper = document.createElement("div");
wrapper.className = "small";
if(this.config.displayStrength)
{
var pingDiv = document.createElement("div");
pingDiv.id = "pingDiv";
wrapper.appendChild(pingDiv);
}
if(this.config.displaySpeed) {
var downloadSpeedGauge = document.createElement("div");
downloadSpeedGauge.id = 'downloadSpeedGauge';

var uploadSpeedGauge = document.createElement("div");
uploadSpeedGauge.id = 'uploadSpeedGauge';
wrapper.appendChild(downloadSpeedGauge);
wrapper.appendChild(uploadSpeedGauge);
}
if(this.config.verbose) {
var data = document.createElement("div");
data.id = 'internetData';
wrapper.appendChild(data);
}
return wrapper;
}


});
4 changes: 4 additions & 0 deletions jquery.js

Large diffs are not rendered by default.

Binary file added justgage-1.2.2/.DS_Store
Binary file not shown.
94 changes: 94 additions & 0 deletions justgage-1.2.2/examples/auto-adjust.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!doctype html>

<html>
<head>
<title>Auto-adjust</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body {
text-align: center;
}

#g1 {
width:400px; height:320px;
display: inline-block;
margin: 1em;
}

#g2, #g3, #g4 {
width:100px; height:80px;
display: inline-block;
margin: 1em;
}

p {
display: block;
width: 450px;
margin: 2em auto;
text-align: left;
}
</style>


</head>
<body>
<div id="g1"></div>
<div id="g2"></div>
<div id="g3"></div>
<div id="g4"></div>
<p>
JustGage auto-adjusts to the size of containing element. And to the screen zoom level. And screen density. Nice. This means you’ll get clean, sharp and nice looking gauge at all times. Try zooming the page to see the results.
</p>

<script src="../raphael-2.1.4.min.js"></script>
<script src="../justgage.js"></script>
<script>
var g1, g2, g3, g4;

window.onload = function(){
var g1 = new JustGage({
id: "g1",
value: getRandomInt(0, 100),
min: 0,
max: 100,
title: "Big Fella",
label: "pounds"
});

var g2 = new JustGage({
id: "g2",
value: getRandomInt(0, 100),
min: 0,
max: 100,
title: "Small Buddy",
label: "oz"
});

var g3 = new JustGage({
id: "g3",
value: getRandomInt(0, 100),
min: 0,
max: 100,
title: "Tiny Lad",
label: "oz"
});

var g4 = new JustGage({
id: "g4",
value: getRandomInt(0, 100),
min: 0,
max: 100,
title: "Little Pal",
label: "oz"
});

setInterval(function() {
g1.refresh(getRandomInt(50, 100));
g2.refresh(getRandomInt(50, 100));
g3.refresh(getRandomInt(0, 50));
g4.refresh(getRandomInt(0, 50));
}, 2500);
};
</script>
</body>
</html>
Loading

0 comments on commit e8dbcef

Please sign in to comment.