MCPcopy Index your code
hub / github.com/Necriso/ScriptableWidgets / createWidget

Function createWidget

openWebIf.js:32–96  ·  view source on GitHub ↗
(channel)

Source from the content-addressed store, hash-verified

30}
31
32async function createWidget(channel) {
33 let widget = new ListWidget()
34 widget.setPadding(5, 0, 0, 5)
35 // set gradient background
36 let startColor = new Color("#000")
37 let endColor = new Color("#111")
38 let gradient = new LinearGradient()
39 gradient.colors = [startColor, endColor]
40 gradient.locations = [0, 1]
41 widget.backgroundColor = new Color("#000")
42 widget.backgroundGradient = gradient
43
44 if (typeof channel !== "object") {
45 let nowText = widget.addText(channel)
46 nowText.font = Font.boldSystemFont(12)
47 nowText.textColor = Color.white()
48 nowText.centerAlignText()
49 nowText.textOpacity = 0.8
50 } else {
51 let nowChannelText = widget.addText(channel.now.sname)
52 nowChannelText.font = Font.boldSystemFont(12)
53 nowChannelText.textColor = Color.white()
54 nowChannelText.centerAlignText()
55 nowChannelText.textOpacity = 0.8
56
57 widget.addSpacer(5)
58
59 let nowText = widget.addText("JETZT")
60 nowText.font = Font.boldSystemFont(12)
61 nowText.textColor = Color.white()
62 nowText.centerAlignText()
63 nowText.textOpacity = 0.8
64
65 let nowTimeTxt = widget.addText(getTime(channel.now.begin_timestamp) + " Uhr")
66 nowTimeTxt.font = Font.semiboldSystemFont(12)
67 nowTimeTxt.textColor = Color.white()
68 nowTimeTxt.centerAlignText()
69
70 let nowTitleTxt = widget.addText(channel.now.title)
71 nowTitleTxt.font = Font.semiboldSystemFont(12)
72 nowTitleTxt.textColor = Color.white()
73 nowTitleTxt.centerAlignText()
74
75 widget.addSpacer(5)
76
77 let nextText = widget.addText("NÄCHSTE")
78 nextText.font = Font.boldSystemFont(12)
79 nextText.textColor = Color.white()
80 nextText.centerAlignText()
81 nextText.textOpacity = 0.8
82
83 let nextTimeTxt = widget.addText(getTime(channel.next.begin_timestamp) + " Uhr")
84 nextTimeTxt.font = Font.semiboldSystemFont(12)
85 nextTimeTxt.textColor = Color.white()
86 nextTimeTxt.centerAlignText()
87
88 let nextTitleTxt = widget.addText(channel.next.title)
89 nextTitleTxt.font = Font.semiboldSystemFont(12)

Callers 1

openWebIf.jsFile · 0.70

Calls 1

getTimeFunction · 0.85

Tested by

no test coverage detected