Skip to content

Commit

Permalink
Merge pull request #6438 from claudiux/daus_1.6.6
Browse files Browse the repository at this point in the history
[download-and-upload-speed@cardsurf] v1.6.6 - Binary or decimal units can now be selected
  • Loading branch information
claudiux committed Sep 24, 2024
2 parents f67ed09 + 0bffc1f commit b3652bd
Show file tree
Hide file tree
Showing 20 changed files with 2,706 additions and 1,192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ MyApplet.prototype = {
for(let [binding, property_name, callback] of [
[Settings.BindingDirection.IN, "display_mode", null],
[Settings.BindingDirection.IN, "unit_type", null],
[Settings.BindingDirection.IN, "is_binary", null],
[Settings.BindingDirection.IN, "update_every", null],
[Settings.BindingDirection.IN, "update_available_interfaces_every", null],
[Settings.BindingDirection.IN, "launch_terminal", null],
Expand Down Expand Up @@ -790,37 +791,67 @@ MyApplet.prototype = {
},

convert_bytes_to_readable_unit: function (bytes) {
if (this.is_binary === true) {
if(bytes >= Math.pow(2, 40)) {
return [bytes/Math.pow(2, 40), _("TiB")];
}
if(bytes >= Math.pow(2, 30)) {
return [bytes/Math.pow(2, 30), _("GiB")];
}
if(bytes >= Math.pow(2, 20)) {
return [bytes/Math.pow(2, 20), _("MiB")];
}
if(bytes >= Math.pow(2, 10)) {
return [bytes/Math.pow(2, 10), _("kiB")];
}
return [bytes, _("B")];
}
if(bytes >= 1000000000000) {
return [bytes/1000000000000, "TB"];
return [bytes/1000000000000, _("TB")];
}
if(bytes >= 1000000000) {
return [bytes/1000000000, "GB"];
return [bytes/1000000000, _("GB")];
}
if(bytes >= 1000000) {
return [bytes/1000000, "MB"];
return [bytes/1000000, _("MB")];
}
if(bytes >= 1000) {
return [bytes/1000, "kB"];
return [bytes/1000, _("kB")];
}
return [bytes, "B"];
return [bytes, _("B")];
},

convert_to_bits: function (bytes) {
return bytes * 8;
},

convert_bits_to_readable_unit: function (bits) {
if (this.is_binary === true) {
if(bits >= Math.pow(2, 40)) {
return [bits/Math.pow(2, 40), _("Tib")];
}
if(bits >= Math.pow(2, 30)) {
return [bits/Math.pow(2, 30), _("Gib")];
}
if(bits >= Math.pow(2, 20)) {
return [bits/Math.pow(2, 20), _("Mib")];
}
if(bits >= Math.pow(2, 10)) {
return [bits/Math.pow(2, 10), _("kib")];
}
return [bits, _("b")];
}
if(bits >= 1000000000000) {
return [bits/1000000000000, "Tb"];
return [bits/1000000000000, _("Tb")];
}
if(bits >= 1000000000) {
return [bits/1000000000, "Gb"];
return [bits/1000000000, _("Gb")];
}
if(bits >= 1000000) {
return [bits/1000000, "Mb"];
return [bits/1000000, _("Mb")];
}
if(bits >= 1000) {
return [bits/1000, "kb"];
return [bits/1000, _("kb")];
}
return [bits, _("b")];
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Shows usage of a network interface",
"version": "1.6.5",
"version": "1.6.6",
"uuid": "download-and-upload-speed@cardsurf",
"name": "Download and upload speed"
"name": "Download and upload speed",
"author": "cardsurf"
}
Loading

0 comments on commit b3652bd

Please sign in to comment.