-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLines.red
175 lines (158 loc) · 3.46 KB
/
Lines.red
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Red [
title: "Lines Clone"
author: "Wesley Hill"
version: 0.1
needs: 'View
]
; JSON
#include %JSON.red
; Font Name
; Should be Johnston or NJFont, I know. But if you want Johnston,
; Install NJFont and change this name.
; TODO: Add Change font feature.
tube_font: "Gill Sans"
; Setup Window
win: [title "Lines (TFL Checker)"
; All black backdrop
backdrop black
below left
base 0x0 black
origin 0x0
space 0x0
]
tube_colors: make map! [
"dlr" 0.193.183
"overground" 255.91.0
"tram-tram" 46.107.217
"circle" 255.210.36
"district" 0.138.68
"bakerloo" 184.89.6
"central" 254.0.0
"hammersmithandcity" 255.120.156
"jubilee" 103.110.114
"metropolitan" 158.33.173
"northern" 0.0.0
"piccadilly" 46.107.217
"victoria" 38.160.226
"waterlooandcity" 78.198.209
]
do [
fetch-data: read http://app.getlin.es/status/current.json [
GET [
Accept: "*/*"
User-Agent: "Lines/2.7 (iPhone; iOS 9.0.2; Scale/2.00)"
Accept-Language: "en-GB;q=1"
Connection: "close"
]
]
data: json/decode fetch-data
data: data/lines
append win [across]
foreach d data [
name: d/name
id: d/id
color: select tube_colors id
message: d/message
status: d/icon
; "Change colors for special cells"
either any [
d/id == "hammersmithandcity"
d/id == "circle"
d/id == "waterlooandcity"
]
[
append win compose/deep [
panel (color) 250x45 [below text (name) font [size: 14 color: 0.33.147 name: tube_font]]
cursor hand on-down [
view [title (name)
backdrop (color)
below
a: area 400x400 no-border (color) font [name: tube_font size: 11 color: 0.33.147]
do [
a/text: (d/message)
]
]
]
]
]
[
append win compose/deep [
panel (color) 250x45 [below text (name) font [size: 14 color: white name: tube_font]]
cursor hand on-down [
view [title (name)
backdrop (color)
below
a: area 400x400 no-border (color) font [name: tube_font size: 12 color: white]
do [
a/text: (d/message)
]
]
]
]
]
; "Change colors for cells that have alerts or icons."
switch d/icon [
"alert" [
either any [
d/id == "hammersmithandcity"
d/id == "circle"
d/id == "waterlooandcity"
] [
append win compose/deep [
panel (color) [size 45x45] draw [
fill-pen 0.33.147 line-width 0 circle 22x22 12
pen 0.33.147
fill-pen (color)
box 21x24 23x15
fill-pen (color) line-width 0 circle 22x28 2
] return
]
]
[
append win compose/deep [
panel (color) [size 45x45] draw [
fill-pen white line-width 0 circle 22x22 12
pen (color)
fill-pen (color)
box 21x24 23x15
fill-pen (color) line-width 0 circle 22x28 2
] return
]
]
]
"check" [
either any [
d/id == "hammersmithandcity"
d/id == "circle"
d/id == "waterlooandcity"
] [
append win compose/deep [
panel (color) [size 45x45] draw [
pen 0.33.147 line-width 2 circle 22x22 12
pen 0.33.147
fill-pen 0.33.147
pen 0.33.147
polygon 16x23 16x23 16x23 20x27
polygon 28x18 28x18 28x18 19x27
] return
]
]
[
append win compose/deep [
panel (color) [size 45x45] draw [
pen white line-width 2 circle 22x22 12
pen white
fill-pen white
pen white
polygon 16x23 16x23 16x23 20x27
polygon 28x18 28x18 28x18 19x27
] return
]
]
]
]
append win [below]
append win [across]
]
]
view/flags win [no-min]