-
Notifications
You must be signed in to change notification settings - Fork 0
/
SitesIndex.fs
executable file
·252 lines (196 loc) · 8.19 KB
/
SitesIndex.fs
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
cr Marker SitesIndex.fs .latest \ Creates a master index
\ You need to adapt this file for your sites.
needs sitelinks.fs
-1 value (pm25) -1 value (Time_pm25)
: +pm25 ( - )
(Time_pm25) 100 /mod mh>mh$ +html
+HTML| pm2.5: | (pm25) s>f 100e f/ (f.2) +html ;
: (+.Inside) ( - ) GetTemperature +HTML| Inside: | (n.1) +html +HTML| <br> | ;
defer (+.Outside) ' noop is (+.Outside)
[UNDEFINED] (+.Nightmode) [IF]
: (+.Nightmode) ( - ) ;
[THEN]
ALSO HTML
0 [if] If needed, change downloaded SVG files from https://www.svgrepo.com/ as follows:
Insert: the width and height before viewBox=".....
So it could looks like: width="150" height="150" viewBox=".....
[then]
: svg-link ( page$ cnt #server - ) \ '</svg>' should be the latest added string in the htmlpage$ buffer
htmlpage$ lcount dup 20 - /string s" </svg>" capssearch
if nip negate htmlpage$ +!
else 2drop cr ." </SVG> tag missing"
then
Tophref=" <pagelink +HTML
+HTML| <rect x="0" y="0" width="100%" height="100%" style="fill:currentcolor;fill-opacity:0.0;stroke-opacity:0.5"|
s" /> " pagelink> +HTML| </svg> | ;
: NoteInputBox ( - )
+HTML| <td colspan="2" width="100%" align="center"> |
<form>
+HTML| <textarea maxlength="254" name="textarea" style="width:275px;height:90px;">|
s" note.txt" +hfile +HTML| </textarea>|
2<BR>
+HTML| <INPUT type="submit" class="btn" value="Save"> <INPUT type="reset" class="btn" value="Reset">|
</form> </td>
;
true value SavedNote
: +Novalue<br-space> ( - ) +HTML| | <br-space> ;
create ShowActivity$ 12 allot s" Pc" ShowActivity$ place
0 value LightsDB
0e fvalue HumidityIncrease
: OnHumIncrease ( recv-pkt$ cnt -- recv-pkt$ cnt )
2dup [char] _ bl ExtractNumber?
if d>f fdup 0e f>
if 100e f/ log" Rain?"
else 0e
then
else 0e
then
to HumidityIncrease ;
: +HumidityIncrease ( - )
HumidityIncrease 0e f>
if <br> +HTML| <font style="background-color:#0000FF" color = "#FFFFFF"> |
<strong> .HtmlSpace +HTML| 🌧 +| HumidityIncrease (f.2) +html
+HTML| %| .HtmlSpace </strong> </font>
else <br-space>
then ;
: <fieldset-style> ( - ) +HTML| <fieldset style=" border: 1px #6C7780 solid;border-radius: 3px;">| ;
: 0<<td-legend>> ( legend$ cnt - ) <td> <fieldset-style> <<legend>> ;
: <<td-legend>> ( legend$ cnt - ) <td> <fieldset-style>
HTML| <font size="2">| pad place
s" <strong>" pad +place
pad +place s" </strong>" pad +place s" </font>" pad +place pad count <<legend>> ;
: <</td-legend>> ( - ) </fieldset> </td> ;
s" Documents/LinksSitesIndex.fs" file-status nip 0= [IF]
NEEDS Documents/LinksSitesIndex.fs \ To load your own links for Links-first-row and Links-second-row
[ELSE]
: .SoundSystem ( - )
\ File-SVG-pictogram Points to page ServerId link
s" Home theater" <<td-legend>>
s" sound-system-svgrepo-com.svg" +hfile s" /home" 0 svg-link
<br> ShowActivity$ count +HTML <br> (PM25) 0>
if +pm25
else .HtmlSpace
then
<</td-legend>> ;
: .History ( - )
s" History" <<td-legend>>
s" thermometer-svgrepo-com.svg" +hfile s" /home" FindOwnId svg-link
(+.Inside) (+.Outside)
<</td-legend>> ;
: .CentralHeating ( - )
s" Central heating" <<td-legend>>
s" thermostat-svgrepo-com.svg" +hfile s" /CV%20menu" FindOwnId svg-link
(+.Nightmode)
<</td-legend>> ;
: .on/off-html ( flag - )
if +HTML| On|
else +HTML| Off|
then <br>
;
: .ControlLights ( - )
s" Lights" <<td-legend>>
s" light-bulb-svgrepo-com.svg" +hfile s" /LightsControl" FindOwnId svg-link
[DEFINED] ControlLights [IF]
eval-light-net i_lights_automatic bInput@
if .on/off-html +HTML| Automatic|
else .on/off-html +HTML| Manual|
then
[ELSE] +HTML| Off| <br> +HTML| Manual| <br> .HtmlSpace
[THEN]
<</td-legend>> ;
: .ControlWindow ( - )
s" Window" <<td-legend>>
s" window-svgrepo-com.svg" +hfile s" /WindowControl" FindOwnId svg-link
[DEFINED] ControlLights [IF]
i_window_Automatic bInput@
if eval-wnd-net
if +HTML| Open|
else +HTML| Close|
then <br> +HTML| Automatic|
else +HTML| Manual| <br> .HtmlSpace
then
( +HumidityIncrease )
[ELSE] +HTML| Off| <br> +HTML| Manual| <br> .HtmlSpace
[THEN]
<</td-legend>> ;
: Links-first-row ( - )
\ A page with links to an option or device.
\ It uses ServerId's that are created in autogen_ip_table.fs
\ To see a list try: .servers
\ Each link uses one cell in a html-table consisting of:
\ 1) A SVG-pictogram with a link to the page of the option/device.
\ 2) 2 lines of additional text.
.SoundSystem
.History
[defined] CentralHeating [if] .CentralHeating [then]
[defined] ControlLights [if] .ControlLights [then]
[defined] ControlWindow [if] .ControlWindow [then] ;
: .Linux ( - )
s" Linux" <<td-legend>> \ A linux PC
s" linux-svgrepo-com.svg" +hfile s" /home" 9 svg-link
<</td-legend>> ;
: .Administration ( - )
s" Rpi Administration" <<td-legend>>
s" administrator-work-svgrepo-com.svg" +hfile s" /Admin" FindOwnId svg-link
<</td-legend>> ;
0
: .Editnote ( - )
s" Edit note" <<td-legend>>
s" document-svgrepo-com.svg" +hfile s" /ModifyNote" FindOwnId svg-link
<</td-legend>> ;
: .SavedNote ( - )
SavedNote
if 2 <#tdC> s" note.txt" +hfile <br>
</td>
else NoteInputBox
then ;
: Links-second-row ( - )
.Linux
.Administration
.Editnote
.SavedNote ;
[THEN]
: Links-to-pages ( - ) \ Most visited pages. Should be adapted for your site.
+HTML| <table style=" border-spacing: 15px 0; border-collapse: separate;"|
+HTML| border="0" cellpadding="0" height="100%" width="100%" >|
Links-first-row
<tr> 4 <#tdL> .HtmlSpace <td> </tr> \ seperator
Links-second-row ;
: .SitesIndex ( - )
s" Main index " NearWhite 0 <HtmlLayout> \ Starts a table in a htmlpage with a legend
Links-to-pages
<tr> 4 <#tdL>
+HTML| Favorites: |
s" https://www.novabbs.com/devel/thread.php?group=comp.lang.forth" s" Clf" <<TopLink>> .HtmlSpace
s" https://www.facebook.com/" s" Faceb." <<TopLink>> .HtmlSpace
s" https://github.com/Jos-Ven?tab=repositories" s" Git JV" <<TopLink>> .HtmlSpace
s" https://www.rosettacode.org/wiki/Category:Forth" s" Rosetta Forth" <<TopLink>> .HtmlSpace
s" https://www.taygeta.com/fsl/sciforth.html" s" SciForth" <<TopLink>>
<br> +Arplink s" /UpdateLinksIndex" Sitelinks
</td>
+HTML| <td align="right" valign="bottom">| .GforthDriven </td> </tr> </table>
<EndHtmlLayout> ;
: SaveNote ( adr n - )
254 min DecodeHtmlInput dup 0>
if s" note.txt" r/w create-file drop dup>r
write-file drop r> CloseFile true to SavedNote
else 2drop
then
;
s" note.txt" file-status nip
[if]
s" note.txt" r/w create-file drop
s" -" 2 pick write-file drop CloseFile
[then]
PREVIOUS
' (SitesIndex) is SitesIndex \ Makes the index link visible
TCP/IP DEFINITIONS
: /SitesIndex ( - ) ['] .SitesIndex set-page ;
' /SitesIndex alias /UpdateLinksIndex
: /ModifyNote ( - ) SavedNote not to SavedNote /SitesIndex ;
: textarea ( <HtmlTxt>- ) parse-name SaveNote /SitesIndex ;
: Gforth::HumIncrease ( - ) udpin$ lcount OnHumIncrease Ignore-remainder ;
: Gforth::LightsON ( - ) udpin$ lcount SendConfirmation true to LightsDB Ignore-remainder ;
: Gforth::LightsOFF ( - ) udpin$ lcount SendConfirmation false to LightsDB Ignore-remainder ;
FORTH DEFINITIONS
\s