MCPcopy Create free account
hub / github.com/Necriso/ScriptableWidgets / createWidget

Function createWidget

guenstigsteTankstelle.js:82–148  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

80}
81
82async function createWidget(data) {
83 let list = createList(data);
84 list.refreshAfterDate = new Date(Date.now() + 300000);
85
86 const attr = data.stations.filter(station => station.isOpen == true)
87
88 for (let i = 0; i < 3; i++) {
89 if (attr[i]) {
90 if (i === 0) {
91 let stationPrice = list.addText(formatValue(attr[i].price))
92 stationPrice.font = new Font('Menlo', 25)
93 stationPrice.centerAlignText()
94 stationPrice.textColor = textColor
95
96 let stationName = list.addText(attr[i]['brand'])
97 stationName.font = Font.boldSystemFont(12)
98 stationName.textColor = textColor
99 stationName.centerAlignText()
100
101 let station = list.addText(attr[i].street + " " + attr[i].houseNumber)
102 station.font = Font.lightSystemFont(12)
103 station.centerAlignText()
104 station.textColor = textColor
105
106 list.addSpacer(7)
107 } else if (i === 1) {
108 let stationStack1 = list.addStack()
109 let price1 = stationStack1.addText(formatValue(attr[i].price))
110 price1.font = new Font('Menlo', 10)
111 price1.textColor = greyTextColor
112
113 stationStack1.addSpacer(3)
114 let addressStack1 = stationStack1.addStack()
115 addressStack1.layoutVertically()
116
117 let station1 = addressStack1.addText(attr[i]['brand'])
118 station1.font = Font.regularSystemFont(10)
119 station1.textColor = greyTextColor
120
121 let address1 = addressStack1.addText(attr[i].street + " " + attr[i].houseNumber)
122 address1.font = Font.regularSystemFont(10)
123 address1.textColor = greyTextColor
124
125 list.addSpacer(2)
126 } else if (i === 2) {
127 let stationStack2 = list.addStack()
128 let price2 = stationStack2.addText(formatValue(attr[i].price))
129 price2.font = new Font('Menlo', 10)
130 price2.textColor = greyTextColor
131
132 stationStack2.addSpacer(3)
133
134 let addressStack2 = stationStack2.addStack()
135 addressStack2.layoutVertically()
136
137 let station2 = addressStack2.addText(attr[i]['brand'])
138 station2.font = Font.regularSystemFont(10)
139 station2.textColor = greyTextColor

Callers 1

Calls 2

createListFunction · 0.70
formatValueFunction · 0.70

Tested by

no test coverage detected