mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-06-07 05:57:41 +00:00
Update VodafoneDE.js
Unterstützung von unbegrenztem Datenvolumen.
This commit is contained in:
parent
f8288a4d63
commit
bb78020f8c
1 changed files with 45 additions and 16 deletions
|
@ -3,9 +3,11 @@
|
||||||
// icon-color: red; icon-glyph: broadcast-tower;
|
// icon-color: red; icon-glyph: broadcast-tower;
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
Version 2.3.0
|
Version 2.4.0
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
v2.4.0:
|
||||||
|
- added Support for flat tariff like "GigaMobil M mit unbegrenzten GB", "GigaMobil XL mit unbegrenzten GB" or other flat tariffs
|
||||||
v2.3.0:
|
v2.3.0:
|
||||||
- Support for lockscreen widgets added
|
- Support for lockscreen widgets added
|
||||||
v2.2.2:
|
v2.2.2:
|
||||||
|
@ -374,7 +376,7 @@ function creatProgress(total, havegone) {
|
||||||
return context.getImage()
|
return context.getImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDiagram(percentage) {
|
function getDiagram(percentage, isFlat) {
|
||||||
function drawArc(ctr, rad, w, deg) {
|
function drawArc(ctr, rad, w, deg) {
|
||||||
bgx = ctr.x - rad
|
bgx = ctr.x - rad
|
||||||
bgy = ctr.y - rad
|
bgy = ctr.y - rad
|
||||||
|
@ -427,7 +429,21 @@ function getDiagram(percentage) {
|
||||||
canvas.setTextAlignedCenter()
|
canvas.setTextAlignedCenter()
|
||||||
canvas.setTextColor(textColor)
|
canvas.setTextColor(textColor)
|
||||||
canvas.setFont(Font.boldSystemFont(canvTextSize))
|
canvas.setFont(Font.boldSystemFont(canvTextSize))
|
||||||
canvas.drawTextInRect(`${percentage}%`, canvTextRect)
|
if (isFlat === true) {
|
||||||
|
const infinitySize = canvSize / 2;
|
||||||
|
canvas.setFont(Font.boldSystemFont(infinitySize));
|
||||||
|
if (config.widgetFamily === "small" || "medium" || "large" || "extraLarge") {
|
||||||
|
const textRect = new Rect(0, infinitySize / 3, canvSize, canvSize);
|
||||||
|
canvas.drawTextInRect(`∞`, textRect);
|
||||||
|
} else {
|
||||||
|
const infinitySize = canvSize / 2;
|
||||||
|
canvas.setFont(Font.boldSystemFont(infinitySize));
|
||||||
|
const textRect = new Rect(0, infinitySize / 1, canvSize, canvSize);
|
||||||
|
canvas.drawTextInRect(`∞`, textRect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
canvas.drawTextInRect(`${percentage}%`, canvTextRect);
|
||||||
|
}
|
||||||
|
|
||||||
return canvas.getImage()
|
return canvas.getImage()
|
||||||
}
|
}
|
||||||
|
@ -450,15 +466,26 @@ function getTimeRemaining(endtime) {
|
||||||
|
|
||||||
function getTotalValues(v) {
|
function getTotalValues(v) {
|
||||||
let totalValues;
|
let totalValues;
|
||||||
if (v.unitOfMeasure !== 'MB') {
|
if (v.unitOfMeasure !== 'MB') {
|
||||||
totalValues = `${(showRemainingContingent ? v.remaining : v.used)} ${descriptionMapping[v.unitOfMeasure] !== undefined ? descriptionMapping[v.unitOfMeasure] : v.unitOfMeasure} von ${v.total} ${descriptionMapping[v.unitOfMeasure] !== undefined ? descriptionMapping[v.unitOfMeasure] : v.unitOfMeasure}`
|
totalValues = `${(showRemainingContingent ? v.remaining : v.used)} ${descriptionMapping[v.unitOfMeasure] !== undefined ? descriptionMapping[v.unitOfMeasure] : v.unitOfMeasure} von ${v.total} ${descriptionMapping[v.unitOfMeasure] !== undefined ? descriptionMapping[v.unitOfMeasure] : v.unitOfMeasure}`
|
||||||
} else if (parseInt(v.total) < 1000) {
|
} else if (parseInt(v.total) < 1000) {
|
||||||
totalValues = `${(showRemainingContingent ? v.remaining : v.used)} MB von ${v.total} MB`
|
totalValues = `${(showRemainingContingent ? v.remaining : v.used)} MB von ${v.total} MB`
|
||||||
|
} else if (parseInt(v.total) >= 100000000) {
|
||||||
|
if (showRemainingContingent === true) {
|
||||||
|
totalValues = `Flat`
|
||||||
} else {
|
} else {
|
||||||
let GB = ((showRemainingContingent ? v.remaining : v.used) / 1024).toFixed(2)
|
if (v.used <= 1024) {
|
||||||
let totalGB = (v.total / 1024).toFixed(2)
|
totalValues = `${v.used} MB verbraucht.`
|
||||||
totalValues = `${GB} GB von ${totalGB} GB`
|
} else {
|
||||||
|
let usedGB = (v.used / 1024).toFixed(2)
|
||||||
|
totalValues = `${usedGB} GB verbraucht.`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let GB = ((showRemainingContingent ? v.remaining : v.used) / 1024).toFixed(2)
|
||||||
|
let totalGB = (v.total / 1024).toFixed(2)
|
||||||
|
totalValues = `${GB} GB von ${totalGB} GB`
|
||||||
|
}
|
||||||
return totalValues
|
return totalValues
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,9 +699,10 @@ if (data !== undefined) {
|
||||||
let stack = widget.addStack()
|
let stack = widget.addStack()
|
||||||
stack.layoutHorizontally()
|
stack.layoutHorizontally()
|
||||||
let v = data.usage[0]
|
let v = data.usage[0]
|
||||||
if(config.widgetFamily !== "accessoryInline") {
|
if (config.widgetFamily !== "accessoryInline") {
|
||||||
const percentage = (100 / v.total * (showRemainingContingent ? v.remaining : v.used)).toFixed(0);
|
const percentage = v.total >= 100000000 ? '∞' : (100 / v.total * (showRemainingContingent ? v.remaining : v.used)).toFixed(0);
|
||||||
stack.addImage(getDiagram(percentage));
|
const isFlat = v.total >= 100000000
|
||||||
|
stack.addImage(getDiagram(percentage, isFlat));
|
||||||
}
|
}
|
||||||
if(config.widgetFamily === "accessoryRectangular"){
|
if(config.widgetFamily === "accessoryRectangular"){
|
||||||
stack.addSpacer(5)
|
stack.addSpacer(5)
|
||||||
|
@ -733,11 +761,12 @@ stack.addImage(getDiagram(percentage));
|
||||||
column.layoutVertically()
|
column.layoutVertically()
|
||||||
column.centerAlignContent()
|
column.centerAlignContent()
|
||||||
|
|
||||||
const percentage = (100 / v.total * (showRemainingContingent ? v.remaining : v.used)).toFixed(0);
|
const percentage = v.total > 100000000 ? 100 : (100 / v.total * (showRemainingContingent ? v.remaining : v.used)).toFixed(0);
|
||||||
|
const isFlat = v.total >= 100000000
|
||||||
const imageStack = column.addStack()
|
const imageStack = column.addStack()
|
||||||
imageStack.layoutHorizontally()
|
imageStack.layoutHorizontally()
|
||||||
imageStack.addSpacer()
|
imageStack.addSpacer()
|
||||||
imageStack.addImage(getDiagram(percentage));
|
imageStack.addImage(getDiagram(percentage, isFlat));
|
||||||
imageStack.addSpacer()
|
imageStack.addSpacer()
|
||||||
column.addSpacer(2)
|
column.addSpacer(2)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue