|
| 1 | +*--------------------------------------------------------------- |
| 2 | +. |
| 3 | +. Program Name: gcalender.pls |
| 4 | +. Description: Sample google calendar support |
| 5 | +. Embedded calendar support |
| 6 | +. |
| 7 | +. Revision History: |
| 8 | +. |
| 9 | +. Date: 10/20/2025 |
| 10 | +. Original code |
| 11 | +. |
| 12 | +. Note: |
| 13 | +. |
| 14 | +. The html file named gcalendar_sup.html must be updated with a |
| 15 | +. Google <iframe> embed code from the "Integrate calendar" section |
| 16 | +. |
| 17 | +. Step 1: Get the embed code from Google Calendar |
| 18 | +. Open Google Calendar on your computer. |
| 19 | +. Click the Settings menu (the gear icon) in the top right corner, then select Settings. |
| 20 | +. In the left-hand menu, click on the name of the calendar you wish to embed. |
| 21 | +. Scroll down to the "Integrate calendar" section and copy the <iframe> code that is provided. |
| 22 | +. To customize the calendar's appearance, click Customize before copying the code. You can |
| 23 | +. choose the default view, color, and size options. |
| 24 | +. |
| 25 | +. Step 2: Add the embed code to the gcalendar_sup.html file |
| 26 | +. |
| 27 | + INCLUDE plbequ.inc |
| 28 | + INCLUDE plbmeth.inc |
| 29 | + INCLUDE plbstdlib.inc |
| 30 | + |
| 31 | + CIFNDEF $CLI_STATE_CORDOVA |
| 32 | +$CLI_STATE_CORDOVA EQU 2 |
| 33 | +$CLI_STATE_BOOTSTRAP5 EQU 16 |
| 34 | + CENDIF |
| 35 | + |
| 36 | +// Runtime status variables |
| 37 | +isGui BOOLEAN |
| 38 | +isWebSrv BOOLEAN |
| 39 | +isPlbSrv BOOLEAN |
| 40 | +isWebview BOOLEAN |
| 41 | +isWebCliApp BOOLEAN |
| 42 | +isSmallScreen BOOLEAN |
| 43 | + |
| 44 | +// Global data |
| 45 | +mainForm PLFORM gcalendar.plf |
| 46 | +Client CLIENT |
| 47 | + |
| 48 | + |
| 49 | +*--------------------------------------------------------------- |
| 50 | +// <program wide variables> |
| 51 | +*................................................................ |
| 52 | +. |
| 53 | +. Code start |
| 54 | +. |
| 55 | + CALL Main |
| 56 | + LOOP |
| 57 | + EVENTWAIT |
| 58 | + REPEAT |
| 59 | + STOP |
| 60 | +*................................................................ |
| 61 | +. |
| 62 | +. Check what type of runtime support we have |
| 63 | +. |
| 64 | +CheckStatus LFUNCTION |
| 65 | + ENTRY |
| 66 | +runtimeData DIM 50 |
| 67 | +runtimeVersion DIM 5 |
| 68 | +unused DIM 1 |
| 69 | +plbRuntime DIM 9 |
| 70 | +WidthData DIM 5 |
| 71 | +checkWidth FORM 5 |
| 72 | +. |
| 73 | +. Check for character mode runtime |
| 74 | +. |
| 75 | + GETMODE *GUI=isGui |
| 76 | + |
| 77 | + IF (isGui) |
| 78 | +. |
| 79 | +. check windows console. |
| 80 | +. |
| 81 | + CLOCK VERSION,runtimeData |
| 82 | + UNPACK runtimeData,runtimeVersion,unused,plbRuntime |
| 83 | + CHOP plbRuntime |
| 84 | + |
| 85 | + IF (NOCASE plbRuntime == "PLBCON") |
| 86 | + CLEAR isGui |
| 87 | + ENDIF |
| 88 | + |
| 89 | + IF (NOCASE plbRuntime == "PLBWEBSV") |
| 90 | + SET isWebSrv |
| 91 | + ENDIF |
| 92 | + |
| 93 | + IF (NOCASE plbRuntime == "PLBSERVE") |
| 94 | + SET isPlbSrv |
| 95 | + ENDIF |
| 96 | + |
| 97 | + ENDIF |
| 98 | + |
| 99 | + IF (isGui) |
| 100 | + WINHIDE |
| 101 | + |
| 102 | + Client.Getstate Giving isWebCliApp Using $CLI_STATE_CORDOVA |
| 103 | + Client.Getstate Giving isWebview Using $CLI_STATE_BOOTSTRAP5 |
| 104 | +. |
| 105 | +. For version 10.6 uncomment the line below |
| 106 | +. |
| 107 | +. MOVE 1 to isWebview |
| 108 | + |
| 109 | +. |
| 110 | +. Check for a small screen (such as iphone) |
| 111 | +. |
| 112 | + IF (isWebSrv) |
| 113 | + Client.GetWinInfo Giving WidthData Using 0x2 |
| 114 | + MOVE WidthData To checkWidth |
| 115 | + MOVE (checkWidth <= 700) to isSmallScreen |
| 116 | + ENDIF |
| 117 | + |
| 118 | + ENDIF |
| 119 | + |
| 120 | + FUNCTIONEND |
| 121 | +*................................................................ |
| 122 | +. |
| 123 | +. Load a supporting HTML file |
| 124 | +. |
| 125 | +LoadSupportHtml LFUNCTION |
| 126 | +htmlCtl HTMLCONTROL ^ |
| 127 | +fileName DIM 250 |
| 128 | + ENTRY |
| 129 | +htmlFile FILE |
| 130 | +htmlBuffer DIM ^ |
| 131 | +fileSize INTEGER 4 |
| 132 | +fullFileName DIM 250 |
| 133 | +seq FORM "-1" |
| 134 | + |
| 135 | + EXCEPTSET NoFile IF IO |
| 136 | + OPEN htmlFile,fileName,Read |
| 137 | +* |
| 138 | +.Read the registration file into a buffer |
| 139 | +. |
| 140 | + GETFILE htmlFile,TxtName=fullFileName |
| 141 | + FINDFILE fullFileName,FileSize=fileSize |
| 142 | + IF (!fileSize) |
| 143 | + INCR fileSize |
| 144 | + ENDIF |
| 145 | +. |
| 146 | + DMAKE htmlBuffer,fileSize |
| 147 | +. |
| 148 | + READ htmlFile,Seq;*ABSON,htmlBuffer |
| 149 | + |
| 150 | + htmlCtl.InnerHtml Using htmlBuffer,$HTML_HAS_EVENTS |
| 151 | + |
| 152 | + CLOSE htmlFile |
| 153 | + DFREE htmlBuffer |
| 154 | + |
| 155 | +noFile |
| 156 | + FUNCTIONEND |
| 157 | +*................................................................ |
| 158 | +. |
| 159 | +. Main - Main program entry point |
| 160 | +. |
| 161 | +Main LFUNCTION |
| 162 | + ENTRY |
| 163 | +result FORM 4 |
| 164 | + |
| 165 | + CALL CheckStatus |
| 166 | + |
| 167 | + IF (!isGui) |
| 168 | + KEYIN "This runtime can't run this program. ",result |
| 169 | + STOP |
| 170 | + ENDIF |
| 171 | + |
| 172 | + IF (!isWebview) |
| 173 | + ALERT STOP,"This program requires WebView support.",result |
| 174 | + STOP |
| 175 | + ENDIF |
| 176 | + |
| 177 | +. |
| 178 | +. On smaller screens change to % positioning for left and width |
| 179 | +. |
| 180 | + IF (isWebCliApp || isSmallScreen) |
| 181 | + SETMODE *PERCENTCONVERT=1 |
| 182 | + ENDIF |
| 183 | + |
| 184 | + FORMLOAD mainForm |
| 185 | + |
| 186 | + CALL LoadSupportHtml Using calHtmlArea,"gcalendar_sup.html" |
| 187 | + |
| 188 | + calFrmMain.SetAsClient |
| 189 | + Client.SetUTF8Convert Using 0 |
| 190 | + |
| 191 | + FUNCTIONEND |
| 192 | + |
| 193 | + |
| 194 | + |
0 commit comments