this repo has no description
at master 6.2 kB view raw
1<script> 2 let months = ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"] 3 let months_length = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] 4 let weeks = ["M", "T", "O", "T", "F", "L", "S"] 5 let lengths = {} 6 7 init(); 8 9 function init() { 10 for(var i = 0; i < months.length; i++) { 11 lengths[months[i]] = [] 12 for(var j = 0; j < months_length[i]; j++) { 13 lengths[months[i]].push(0); 14 } 15 } 16 } 17 18 function get_time(index) { 19 var date = new Date(); 20 let time = new Date(date.getFullYear(), index, 1).getDay(); 21 time -= 1; 22 if(time == -1) { 23 time = 6; 24 } 25 26 let array = [] 27 for(var i = 0; i < time; i++) { 28 array.push(i); 29 } 30 return array; 31 } 32 33 function get_day() { 34 var date = new Date(); 35 // console.log(date.getDate()); 36 return date.getDate() 37 // return 25; 38 } 39 40 function get_month() { 41 var date = new Date(); 42 // console.log(date.getDate()); 43 return date.getMonth() 44 } 45 46 function get_year() { 47 var date = new Date(); 48 console.log(date.getDate()); 49 return date.getFullYear() 50 } 51 52 function get_week_day() { 53 var date = new Date(); 54 // console.log(date.getDate()); 55 return date.getDay() 56 } 57 58 function get_week_day_long(year, month, day) { 59 var date = new Date(year, month, day); 60 // console.log(date.getDate()); 61 return date.getDay() 62 } 63 64 function get_weekdays() { 65 var list = [] 66 var day = 0; 67 for(var i = 0; i < 37; i++) { 68 day += 1; 69 if(day == 8) { 70 day = 1; 71 } 72 switch(day) { 73 case 1: list.push("M"); break; 74 case 2: list.push("T"); break; 75 case 3: list.push("O"); break; 76 case 4: list.push("T"); break; 77 case 5: list.push("F"); break; 78 case 6: list.push("L"); break; 79 case 7: list.push("S"); break; 80 } 81 } 82 return list 83 } 84 85 function get_hours() { 86 let arr =[] 87 for(var i = 0; i < 24; i++) { 88 arr.push(i) 89 } 90 return arr; 91 } 92 93 function get_hour() { 94 let date = new Date(); 95 return date.getHours() 96 } 97 98 function get_minutes() { 99 let arr =[] 100 for(var i = 0; i < 60; i++) { 101 arr.push(i) 102 } 103 return arr; 104 } 105 106 function get_minute() { 107 let date = new Date(); 108 return date.getMinutes() 109 } 110 111</script> 112 113<main> 114 2022 115 <div class="months"> 116 {#each months as month, month_i} 117 <div> 118 {#if month_i == get_month()} 119 <div> 120 <div class="selected monthtag"> 121 {month} 122 </div> 123 </div> 124 {:else} 125 <div> 126 {month} 127 </div> 128 {/if} 129 <span class="days"> 130 {#each get_time(month_i) as i} 131 <div class="day"> 132 133 </div> 134 {/each} 135 {#each lengths[month] as day, i} 136 {#if get_week_day_long(get_year(), month_i, i) != 5 && get_week_day_long(get_year(), month_i, i) != 6} 137 {#if i == get_day() - 1 && month_i == get_month()} 138 <div class="day selected"> 139 {i + 1} 140 </div> 141 {:else} 142 <div class="day"> 143 {i + 1} 144 </div> 145 {/if} 146 {:else} 147 {#if i == get_day() - 1 && month_i == get_month()} 148 <div class="day selected weekend"> 149 {i + 1} 150 </div> 151 {:else} 152 <div class="day weekend"> 153 {i + 1} 154 </div> 155 {/if} 156 {/if} 157 {/each} 158 </span> 159 </div> 160 {/each} 161 </div> 162 <div class="weeks"> 163 <!-- {#each [1, 2, 3, 4, 5] as i} 164 {#each weeks as week, week_i} 165 {console.log(week_i + (5 * (i - 1)))} 166 {#if week_i + 1 == get_week_day()} 167 <div class="selected"> 168 {week} 169 </div> 170 {:else} 171 <div> 172 {week} 173 </div> 174 {/if} 175 {/each} 176 {/each} 177 <div> 178 M 179 </div> 180 <div> 181 T 182 </div> --> 183 {#each get_weekdays() as day, i} 184 {#if i - 1 == get_day()} 185 <div class="selected"> 186 {day} 187 </div> 188 {:else} 189 <div> 190 {day} 191 </div> 192 {/if} 193 {/each} 194 </div> 195</main> 196 197<time> 198 <div class="time"> 199 <div> 200 Hrs 201 </div> 202 <div> 203 Min 204 </div> 205 <div class="hss"> 206 {#each get_hours() as hour} 207 {#if hour.toString().length == 2} 208 {#if get_hour() != hour} 209 <div class="hs"> 210 {hour} 211 </div> 212 {:else} 213 <div class="hs selected"> 214 {hour} 215 </div> 216 {/if} 217 {:else} 218 {#if get_hour() != hour} 219 <div class="hs"> 220 {"0" + hour.toString()} 221 </div> 222 {:else} 223 <div class="hs selected"> 224 {"0" + hour.toString()} 225 </div> 226 {/if} 227 {/if} 228 {/each} 229 </div> 230 <div class="mss"> 231 {#each get_minutes() as hour} 232 {#if hour.toString().length == 2} 233 {#if get_minute() != hour} 234 <div class="hs"> 235 {hour} 236 </div> 237 {:else} 238 <div class="hs selected"> 239 {hour} 240 </div> 241 {/if} 242 {:else} 243 {#if get_minute() != hour} 244 <div class="hs"> 245 {"0" + hour.toString()} 246 </div> 247 {:else} 248 <div class="hs selected"> 249 {"0" + hour.toString()} 250 </div> 251 {/if} 252 {/if} 253 {/each} 254 </div> 255 </div> 256</time> 257 258<style> 259 @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); 260 main { 261 font-family: 'Roboto', sans-serif; 262 font-size: 30px; 263 padding-left: 120px; 264 padding-top: 40px; 265 background-color: white; 266 } 267 268 time { 269 position: absolute; 270 font-family: 'Roboto', sans-serif; 271 font-size: 30px; 272 padding-left: 120px; 273 top:1000px; 274 } 275 276 .hss { 277 position: absolute; 278 display: flex; 279 flex-direction: row; 280 left: 250px; 281 flex-basis: 20px; 282 gap: 25px; 283 font-weight: normal; 284 } 285 286 .mss { 287 position: absolute; 288 display: flex; 289 flex-direction: row; 290 left: 250px; 291 flex-basis: 20px; 292 gap: 25px; 293 font-weight: normal; 294 top: 70px; 295 width: 1800px; 296 height: 100px; 297 flex-wrap: wrap; 298 } 299 300 .hs { 301 width: 35px; 302 height: max-content; 303 } 304 305 .time { 306 display: flex; 307 flex-direction: column; 308 gap: 30px; 309 font-weight: bold; 310 } 311 312 .months { 313 display: flex; 314 flex-direction: column; 315 gap: 30px; 316 margin-top: 30px; 317 font-weight: bold; 318 } 319 320 .weeks { 321 position: absolute; 322 display: flex; 323 flex-direction: row; 324 margin-left: 120px; 325 gap: 40px; 326 top: 48px; 327 font-weight: bold; 328 } 329 330 .days { 331 position: absolute; 332 display: flex; 333 flex-direction: row; 334 left: 245px; 335 flex-basis: 20px; 336 gap: 25px; 337 margin-top: -36px; 338 font-weight: normal; 339 } 340 341 .day { 342 width: 35px; 343 text-align: center; 344 } 345 346 .selected { 347 background-color: black; 348 color: white; 349 } 350 351 .monthtag { 352 width: max-content; 353 } 354 355 .weekend { 356 color: lightgray; 357 } 358</style>