-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
3,053 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
}); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.