Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgcalendar_ics.pls
More file actions
409 lines (348 loc) · 13.4 KB
/
gcalendar_ics.pls
File metadata and controls
409 lines (348 loc) · 13.4 KB
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
*---------------------------------------------------------------
.
. Program Name: gcalender_ics.pls
. Description: Sample google calendar support
. Product a ICS file
.
. Revision History:
.
. Revision History:
.
. Date: 10/20/2025
. Original code
.
. Note:
.
. The html file named gcalendar_sup.html must be updated with a
. Google <iframe> embed code from the "Integrate calendar" section
.
. Step 1: Get the embed code from Google Calendar
. Open Google Calendar on your computer.
. Click the Settings menu (the gear icon) in the top right corner, then select Settings.
. In the left-hand menu, click on the name of the calendar you wish to embed.
. Scroll down to the "Integrate calendar" section and copy the <iframe> code that is provided.
. To customize the calendar's appearance, click Customize before copying the code. You can
. choose the default view, color, and size options.
.
. Step 2: Add the embed code to the gcalendar_sup.html file
.
INCLUDE plbequ.inc
INCLUDE plbmeth.inc
INCLUDE plbstdlib.inc
CIFNDEF $CLI_STATE_CORDOVA
$CLI_STATE_CORDOVA EQU 2
$CLI_STATE_BOOTSTRAP5 EQU 16
CENDIF
// Runtime status variables
isGui BOOLEAN
isWebSrv BOOLEAN
isPlbSrv BOOLEAN
isWebview BOOLEAN
isWebCliApp BOOLEAN
isSmallScreen BOOLEAN
// Global data
mainForm PLFORM gcalendar_ics.plf
Client CLIENT
icsFile FILE
seq FORM "-1"
.................................................
.
. Format of ICS file
.
. BEGIN:VCALENDAR
. VERSION:2.0
. PRODID:-//PLB Calendar Event//EN
. BEGIN:VEVENT
. UID:aee8f239-c76a-4f50-8a02-c0bacd738441
. DTSTAMP:20250724T194258Z
. DTSTART:20250810T120000
. DTEND:20250810T140000
. SUMMARY:Museum Trip
. LOCATION:Big Museum
. DESCRIPTION:Lunch will be provided
. END:VEVENT
. END:VCALENDAR
.
eventRecord RECORD
isValid BOOLEAN
UID DIM 36 // UID
timeStamp DIM 16 // DTSTAMP
startTime DIM 16 // DTSTART
endTime DIM 16 // DTEND
summary DIM 40 // SUMMARY
location DIM 80 // LOCATION
description DIM 40 // DESCRIPTION
RECORDEND
*---------------------------------------------------------------
// <program wide variables>
*................................................................
.
. Code start
.
CALL Main
LOOP
EVENTWAIT
REPEAT
STOP
*................................................................
.
. Check what type of runtime support we have
.
CheckStatus LFUNCTION
ENTRY
runtimeData DIM 50
runtimeVersion DIM 5
unused DIM 1
plbRuntime DIM 9
WidthData DIM 5
checkWidth FORM 5
.
. Check for character mode runtime
.
GETMODE *GUI=isGui
IF (isGui)
.
. check windows console.
.
CLOCK VERSION,runtimeData
UNPACK runtimeData,runtimeVersion,unused,plbRuntime
CHOP plbRuntime
IF (NOCASE plbRuntime == "PLBCON")
CLEAR isGui
ENDIF
IF (NOCASE plbRuntime == "PLBWEBSV")
SET isWebSrv
ENDIF
IF (NOCASE plbRuntime == "PLBSERVE")
SET isPlbSrv
ENDIF
ENDIF
IF (isGui)
WINHIDE
Client.Getstate Giving isWebCliApp Using $CLI_STATE_CORDOVA
Client.Getstate Giving isWebview Using $CLI_STATE_BOOTSTRAP5
.
. For version 10.6 uncomment the line below
.
. MOVE 1 to isWebview
.
. Check for a small screen (such as iphone)
.
IF (isWebSrv)
Client.GetWinInfo Giving WidthData Using 0x2
MOVE WidthData To checkWidth
MOVE (checkWidth <= 700) to isSmallScreen
ENDIF
ENDIF
FUNCTIONEND
*................................................................
.
. Load a supporting HTML file
.
LoadSupportHtml LFUNCTION
htmlCtl HTMLCONTROL ^
fileName DIM 250
ENTRY
htmlFile FILE
htmlBuffer DIM ^
fileSize INTEGER 4
fullFileName DIM 250
seq FORM "-1"
EXCEPTSET NoFile IF IO
OPEN htmlFile,fileName,Read
*
.Read the registration file into a buffer
.
GETFILE htmlFile,TxtName=fullFileName
FINDFILE fullFileName,FileSize=fileSize
IF (!fileSize)
INCR fileSize
ENDIF
.
DMAKE htmlBuffer,fileSize
.
READ htmlFile,Seq;*ABSON,htmlBuffer
htmlCtl.InnerHtml Using htmlBuffer
CLOSE htmlFile
DFREE htmlBuffer
noFile
FUNCTIONEND
*................................................................
.
. Fetch the event data from the form
.
FetchEventData LFUNCTION
ENTRY
jsCall DIM 4096
guid DIM 40
dateInfo DIM 16
curDate DATETIME
startDate DATETIME
endDate DATETIME
result FORM 5
CLEAR eventRecord
GETPROP calEdtEvent,*TEXT=eventRecord.summary
COUNT result,eventRecord.summary
IF ZERO
ALERT CAUTION,"The event name must not be empty!",result,"Calendar",
RETURN
ENDIF
GETPROP calEdtDesc,*TEXT=eventRecord.description
GETPROP calEdtLoc,*TEXT=eventRecord.location
GETPROP calEdtStart,*TEXT=dateInfo
startDate.SetAsString Using dateInfo,"%Y-%m-%dT%H:%M",1
startDate.GetAsString Giving eventRecord.startTime Using "%Y%m%dT%H%M%S"
GETPROP calEdtEnd,*TEXT=dateInfo
endDate.SetAsString Using dateInfo,"%Y-%m-%dT%H:%M",1
endDate.GetAsString Giving eventRecord.endTime Using "%Y%m%dT%H%M%S"
endDate.Compare Using startDate
IF LESS
ALERT CAUTION,"The end date is before the start date !",result,"Calendar",
RETURN
ENDIF
curDate.SetToNow
curDate.GetAsString Giving eventRecord.timeStamp Using "%Y%m%dT%H%M%SZ",1
PACK jsCall Using "calGetGuid();"
Client.jsrun Giving eventRecord.UID Using jsCall
Client.FlushMessages
SET eventRecord.isValid
FUNCTIONEND
*................................................................
.
. Create a link with the the ICS information to download
.
IcsLink LFUNCTION
fileName DIM 40
ENTRY
htmlData DIM 4096
line DIM 100
result FORM 3
IF (eventRecord.isValid)
CLEAR htmlData
APPEND "<div>",htmlData
PACK line, "<a href='#' download='", fileName, "' id='icsdl'>Download ICS file</a>"
APPEND line,htmlData
APPEND "</div>",htmlData
APPEND "<script>",htmlData
APPEND " var icsData = 'BEGIN:VCALENDAR\n' + ",htmlData
APPEND " 'VERSION:2.0\n' + ",htmlData
APPEND " 'PRODID:-//PLB Calendar Event//EN\n' + ",htmlData
APPEND " 'BEGIN:VEVENT\n' + ",htmlData
PACK line, " 'UID:", eventRecord.UID, "\n' + "
APPEND line,htmlData
PACK line, " 'DTSTAMP:", eventRecord.timeStamp, "\n' + "
APPEND line,htmlData
PACK line, " 'DTSTART:", eventRecord.startTime, "\n' + "
APPEND line,htmlData
PACK line, " 'DTEND:", eventRecord.endTime, "\n' + "
APPEND line,htmlData
PACK line, " 'SUMMARY:", eventRecord.summary, "\n' + "
APPEND line,htmlData
COUNT result,eventRecord.location
IF NOT ZERO
PACK line, " 'LOCATION:", eventRecord.location, "\n' + "
APPEND line,htmlData
ENDIF
COUNT result,eventRecord.description
IF NOT ZERO
PACK line, " 'DESCRIPTION:", eventRecord.description, "\n' + "
APPEND line,htmlData
ENDIF
APPEND " 'END:VEVENT\n' + ",htmlData
APPEND " 'END:VCALENDAR\n'; ",htmlData
APPEND " var icsLk = document.getElementById('icsdl');",htmlData
APPEND " icsLk.href = 'data:text/calendar;charset=utf-8,' + encodeURIComponent(icsData);",htmlData
APPEND "</script>",htmlData
RESET htmlData
calHtmlResult.InnerHtml Using htmlData
ENDIF
FUNCTIONEND
*................................................................
.
. Write the start of the ICS file
.
IcsOpenFile LFUNCTION
fileName DIM ^
ENTRY
IF (eventRecord.isValid)
PREP icsFile,fileName
WRITE icsFile,Seq;"BEGIN:VCALENDAR"
WRITE icsFile,Seq;"VERSION:2.0"
WRITE icsFile,Seq;"PRODID:-//PLB Calendar Event//EN"
ENDIF
FUNCTIONEND
*................................................................
.
. Write one event into the ICS file
.
IcsWriteEvent LFUNCTION
ENTRY
result FORM 4
IF (eventRecord.isValid)
WRITE icsFile,Seq;"BEGIN:VEVENT"
WRITE icsFile,Seq;"UID:",*LL,eventRecord.UID
WRITE icsFile,Seq;"DTSTAMP:",*LL,eventRecord.timeStamp
WRITE icsFile,Seq;"DTSTART:",*LL,eventRecord.startTime
WRITE icsFile,Seq;"DTEND:",*LL,eventRecord.endTime
WRITE icsFile,Seq;"SUMMARY:",*LL,eventRecord.summary
COUNT result,eventRecord.location
IF NOT ZERO
WRITE icsFile,Seq;"LOCATION:",*LL,eventRecord.location
ENDIF
COUNT result,eventRecord.description
IF NOT ZERO
WRITE icsFile,Seq;"DESCRIPTION:",*LL,eventRecord.description
ENDIF
WRITE icsFile,Seq;"END:VEVENT"
ENDIF
FUNCTIONEND
*................................................................
.
. Write the end of the ICS file
.
IcsCloseFile LFUNCTION
ENTRY
IF (eventRecord.isValid)
WRITE icsFile,Seq;"END:VCALENDAR"
CLOSE icsFile
ENDIF
FUNCTIONEND
*................................................................
.
. Build an ICS file and an ICC link
.
IcsBuild LFUNCTION
ENTRY
CALL FetchEventData
CALL IcsOpenFile Using "sample.ics"
CALL IcsWriteEvent
CALL IcsCloseFile
CALL IcsLink Using "sample.ics"
FUNCTIONEND
*................................................................
.
. Main - Main program entry point
.
Main LFUNCTION
ENTRY
result FORM 4
CALL CheckStatus
IF (!isGui)
KEYIN "This runtime can't run this program. ",result
STOP
ENDIF
IF (!isWebview)
ALERT STOP,"This program requires WebView support.",result
STOP
ENDIF
.
. On smaller screens change to % positioning for left and width
.
IF (isWebCliApp || isSmallScreen)
SETMODE *PERCENTCONVERT=1
ENDIF
FORMLOAD mainForm
CALL LoadSupportHtml Using calHtmlArea,"gcalendar_sup.html"
calFrmMain.SetAsClient
Client.SetUTF8Convert Using 0
FUNCTIONEND
You can’t perform that action at this time.
