File tree Expand file tree Collapse file tree 3 files changed +59
-7
lines changed Expand file tree Collapse file tree 3 files changed +59
-7
lines changed Original file line number Diff line number Diff line change
1
+ //DO NOT CHANGE DELIMITERs
2
+ const DELIMITER_BEG =
3
+ 'DO NOT DELETE THIS TEXT AND INCLUDE A SPACE AFTER COLON: ' ;
4
+ // 2 Ending because for some reason fetching from google doc has to
5
+ const DELIMITER_END1 = '</span>' ;
6
+ const DELIMITER_END2 = '"' ;
7
+
8
+ const deadlineElements = document . querySelectorAll ( '[data-deadline]' ) ;
9
+
10
+ fetch (
11
+ //public view only url
12
+ //trickfirerobotics@gmail .com
13
+ 'https://docs.google.com/document/d/1tRysVWzUv-sKNg6lWe7n-CvKLZU0HNW3SZiIs19d09Q/edit?usp=sharing'
14
+ )
15
+ . then ( res => {
16
+ //check to make sure API works
17
+ if ( ! res . ok ) {
18
+ throw new error ( 'DEADLINE TEXT API NOT WORKING' ) ;
19
+ }
20
+ return res . text ( ) ;
21
+ } )
22
+ . then ( text => {
23
+ let indexBeg = text . indexOf ( DELIMITER_BEG ) + DELIMITER_BEG . length ;
24
+ let indexEnd = Math . min (
25
+ text . indexOf ( DELIMITER_END1 , indexBeg ) ,
26
+ text . indexOf ( DELIMITER_END2 , indexBeg )
27
+ ) ;
28
+ //Catches if the DELIMITER isn't found
29
+ if ( indexBeg == - 1 + DELIMITER_BEG . length || indexEnd == - 1 ) {
30
+ throw new Error ( 'DELIMITER WAS NOT FOUND' ) ;
31
+ }
32
+
33
+ const deadlineText = `Deadline: ${ text . substring ( indexBeg , indexEnd ) } ` ;
34
+ //safety check to make sure it didn't go over
35
+ if ( deadlineText . length > 100 ) {
36
+ throw new Error ( 'TEXT WAS OVER 100 CHARS' ) ;
37
+ }
38
+ deadlineElements . forEach ( ele => {
39
+ ele . innerText = deadlineText ;
40
+ } ) ;
41
+ } )
42
+ . catch ( error => {
43
+ console . error ( error ) ;
44
+ } ) ;
Original file line number Diff line number Diff line change 57
57
</ p >
58
58
</ div >
59
59
< script >
60
- console . log ( document . getElementById ( 'copyright-text' ) . innerText ) ;
61
60
let copyrightTextElement =
62
61
document . getElementById ( 'copyright-text' ) ;
63
62
let currentYear = new Date ( ) . getFullYear ( ) ;
64
- console . log ( currentYear ) ;
65
63
copyrightTextElement . innerText =
66
64
copyrightTextElement . innerText . replace ( '2022' , currentYear ) ;
67
65
</ script >
Original file line number Diff line number Diff line change 50
50
$ ( '#footer' ) . load ( './assets/moduleHtml/footer.html' ) ;
51
51
} ) ;
52
52
</ script >
53
+ <!-- Updates Deadline text dynamicaly -->
54
+ < script
55
+ type ="module "
56
+ async
57
+ src ="./assets/javascript/deadlineText.js "
58
+ > </ script >
53
59
</ head >
54
60
55
61
< body >
@@ -102,9 +108,10 @@ <h1>Why Join?</h1>
102
108
>
103
109
TrickFire Robotics Application Link
104
110
</ a >
105
- < br />
106
- < b > Deadline: Between June 20th and July 15th</ b >
107
-
111
+ < br />
112
+ < b data-deadline >
113
+ Deadline: Please check the form above</ b
114
+ >
108
115
</ p >
109
116
</ div >
110
117
</ div >
@@ -147,15 +154,18 @@ <h1>Why Join?</h1>
147
154
>
148
155
TrickFire Robotics Application Link
149
156
</ a >
150
- < br />
151
- < b > Deadline: Between June 20th and July 15th</ b >
157
+ < br />
158
+ < b data-deadline >
159
+ Deadline: Please check the form above</ b
160
+ >
152
161
</ p >
153
162
</ div >
154
163
</ div >
155
164
< div class ="space-after-rows "> </ div >
156
165
</ section >
157
166
158
167
< footer id ="footer "> </ footer >
168
+
159
169
< script
160
170
src ="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js "
161
171
integrity ="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx "
You can’t perform that action at this time.
0 commit comments