-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcal-linkgen.html
589 lines (539 loc) · 18 KB
/
gcal-linkgen.html
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>구글 캘린더 일정 링크 생성기</title>
<!-- style -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nanum+Gothic">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/css/tempusdominus-bootstrap-4.min.css">
<style>
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
font-family: "나눔고딕", "Nanum Gothic", "맑은 고딕", Verdana, sans-serif;
font-size: 16pt;
line-height: 1.6;
text-align: justify;
}
.top-buffer {
margin-top: 8px;
}
input[type="checkbox"], input[type="radio"]{
position: absolute;
right: 9000px;
}
/*Check box*/
input[type="checkbox"] + .label-text:before{
content: "\f096";
font-family: "FontAwesome";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing:antialiased;
width: 1em;
display: inline-block;
margin-right: 5px;
}
input[type="checkbox"]:checked + .label-text:before{
content: "\f14a";
color: #2980b9;
animation: effect 250ms ease-in;
}
input[type="checkbox"]:disabled + .label-text{
color: #aaa;
}
input[type="checkbox"]:disabled + .label-text:before{
content: "\f0c8";
color: #ccc;
}
/*Radio box*/
input[type="radio"] + .label-text:before{
content: "\f10c";
font-family: "FontAwesome";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing:antialiased;
width: 1em;
display: inline-block;
margin-right: 5px;
}
input[type="radio"]:checked + .label-text:before{
content: "\f192";
color: #8e44ad;
animation: effect 250ms ease-in;
}
input[type="radio"]:disabled + .label-text{
color: #aaa;
}
input[type="radio"]:disabled + .label-text:before{
content: "\f111";
color: #ccc;
}
/*Radio Toggle*/
.toggle input[type="radio"] + .label-text:before{
content: "\f204";
font-family: "FontAwesome";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing:antialiased;
width: 1em;
display: inline-block;
margin-right: 10px;
}
.toggle input[type="radio"]:checked + .label-text:before{
content: "\f205";
color: #16a085;
animation: effect 250ms ease-in;
}
.toggle input[type="radio"]:disabled + .label-text{
color: #aaa;
}
.toggle input[type="radio"]:disabled + .label-text:before{
content: "\f204";
color: #ccc;
}
@keyframes effect{
0%{transform: scale(0);}
25%{transform: scale(1.3);}
75%{transform: scale(1.4);}
100%{transform: scale(1);}
}
</style>
<!-- script -->
<script src="https://code.jquery.com/jquery-3.4.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.0.1/js/tempusdominus-bootstrap-4.min.js"></script>
<script src="gcal-linkgen.js"></script>
<script>
'use strict';
function getTimezoneOffset() {
return new Date().getTimezoneOffset();
}
function getTimezoneOffsetStr() {
function z(n){ return (n<10 ? '0' : '') + n; }
let offset = getTimezoneOffset();
let sign = offset < 0? '+' : '-';
offset = Math.abs(offset);
return sign + z(offset/60 | 0) + z(offset%60);
}
function getTimezoneName() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
function onCheckAllDay() {
if ( $("#cal_allDay").is(":checked") ) {
$("#cal_startTime").fadeOut();
$("#cal_endTime").fadeOut();
} else {
$("#cal_startTime").fadeIn();
$("#cal_endTime").fadeIn();
}
}
function onCheckLoopNum() {
if ( $("#cal_loopNumChk").is(":checked") ) {
if ( $("#cal_loopUntilChk").is(":checked") ) {
$("#cal_loopUntilChk").prop('checked', false);
onCheckLoopUntil();
}
$("#cal_loopNum").val( $("#cal_loopNumLast").val() );
$("#cal_loopNum").prop("disabled", false);
} else {
$("#cal_loopNum").prop("disabled", true);
$("#cal_loopNumLast").val( $("#cal_loopNum").val() );
$("#cal_loopNum").val("");
}
}
function onCheckLoopUntil() {
if ( $("#cal_loopUntilChk").is(":checked") ) {
if ( $("#cal_loopNumChk").is(":checked") ) {
$("#cal_loopNumChk").prop('checked', false);
onCheckLoopNum();
}
$("#cal_loopUntil").datetimepicker("daysOfWeekDisabled", []);
$("#cal_loopUntil").prop("disabled", false);
} else {
$("#cal_loopUntil").prop("disabled", true);
$("#cal_loopUntil").val("");
}
}
function onClickLoopOpt(v) {
$("#cal_loopNone").removeClass("active");
$("#cal_loopDay").removeClass("active");
$("#cal_loopWeek").removeClass("active");
$("#cal_loopMonth").removeClass("active");
$("#cal_loopYear").removeClass("active");
switch(v) {
case 0: // 반복 없음
$("#cal_loop").val(0);
$("#cal_loopDrop").text( $("#cal_loopNone").text() );
$("#cal_loopNone").addClass("active");
$("#cal_loopOpt").fadeOut();
$("#cal_loopNumChk").prop('checked', false);
$("#cal_loopUntilChk").prop('checked', false);
onCheckLoopNum();
onCheckLoopUntil();
break;
case 1: // 매일 같은 시간
$("#cal_loop").val(1);
$("#cal_loopDrop").text( $("#cal_loopDay").text() );
$("#cal_loopDay").addClass("active");
$("#cal_loopOpt").fadeIn();
break;
case 2: // 매주 같은 요일
$("#cal_loop").val(2);
$("#cal_loopDrop").text( $("#cal_loopWeek").text() );
$("#cal_loopWeek").addClass("active");
$("#cal_loopOpt").fadeIn();
break;
case 3: // 매월 같은 일자
$("#cal_loop").val(3);
$("#cal_loopDrop").text( $("#cal_loopMonth").text() );
$("#cal_loopMonth").addClass("active");
$("#cal_loopOpt").fadeIn();
break;
case 4: // 매년 같은 날짜
$("#cal_loop").val(4);
$("#cal_loopDrop").text( $("#cal_loopYear").text() );
$("#cal_loopYear").addClass("active");
$("#cal_loopOpt").fadeIn();
break;
}
}
function beginSite() {
// onLoad
let today = new Date();
// 시간대
$("#cal_timezone").val("UTC" + getTimezoneOffsetStr() + "\t" + getTimezoneName());
// 시작 시간
// 시간 단위로 절사
today.setMinutes(0);
today.setSeconds(0);
$("#cal_startDate").datetimepicker({
locale: "ko"
, format: "Y년 M월 D일 dddd"
, defaultDate: today
});
$("#cal_startTime").datetimepicker({
locale: "ko"
, format: "HH:mm (A h시 mm분)"
, defaultDate: today
});
// 끝 시간
// 1시간 뒤로 설정
today.setHours(today.getHours() + 1);
$("#cal_endDate").datetimepicker({
locale: "ko"
, format: "Y년 M월 D일 dddd"
, defaultDate: today
});
$("#cal_endTime").datetimepicker({
locale: "ko"
, format: "HH:mm (A h시 mm분)"
, defaultDate: today
});
// 반복 종료 시점
$("#cal_loopUntil").datetimepicker({
locale: "ko"
, format: "Y년 M월 D일"
, defaultDate: today
});
// input에 datetime 미리 출력
$("#cal_startDate").datetimepicker("daysOfWeekDisabled", []);
$("#cal_startTime").datetimepicker("daysOfWeekDisabled", []);
$("#cal_endDate").datetimepicker("daysOfWeekDisabled", []);
$("#cal_endTime").datetimepicker("daysOfWeekDisabled", []);
// 반복 없음 선택
onClickLoopOpt(0);
$("#cal_allDay").change(onCheckAllDay);
$("#cal_loopNumChk").change(onCheckLoopNum);
$("#cal_loopUntilChk").change(onCheckLoopUntil);
}
function validateForm() {
let title = $("#cal_title").val();
if (!title) {
alert("제목은 반드시 필요합니다.");
$("#cal_title").focus();
return false;
}
let std = $("#cal_startDate").datetimepicker("date")._d;
let stt = $("#cal_startTime").datetimepicker("date")._d;
let end = $("#cal_endDate").datetimepicker("date")._d;
let ent = $("#cal_endTime").datetimepicker("date")._d;
let stD;
let enD;
if ( $("#cal_allDay").is(":checked") ) {
stD = new Date(std.getFullYear(), std.getMonth(), std.getDate());
enD = new Date(end.getFullYear(), end.getMonth(), end.getDate());
} else {
stD = new Date(std.getFullYear(), std.getMonth(), std.getDate(), stt.getHours(), stt.getMinutes());
enD = new Date(end.getFullYear(), end.getMonth(), end.getDate(), ent.getHours(), ent.getMinutes());
}
if (stD > enD) {
alert("시작 시간은 반드시 끝 시간보다 빨라야 합니다.");
$("#cal_startDate").focus();
return false;
}
return true;
}
function makeUrl() {
// 링크 초기화
$("#cal_url").text("#");
$("#cal_url").attr("href", "#");
// 입력값 검사
if ( !validateForm() )
return;
let std = $("#cal_startDate").datetimepicker("date")._d;
let stt = $("#cal_startTime").datetimepicker("date")._d;
let end = $("#cal_endDate").datetimepicker("date")._d;
let ent = $("#cal_endTime").datetimepicker("date")._d;
let stD = new Date(std.getFullYear(), std.getMonth(), std.getDate(), stt.getHours(), stt.getMinutes());
let enD = new Date(end.getFullYear(), end.getMonth(), end.getDate(), ent.getHours(), ent.getMinutes());
console.log("UTC" + getTimezoneOffsetStr() + "\t" + getTimezoneName());
console.log("start: " + stD + "\t" + stD.toISOString());
console.log("end: " + enD + "\t" + enD.toISOString());
let rptype = parseInt( $("#cal_loop").val() );
let rpcnt = 0;
let rpdate = null;
if ( $("#cal_loopNumChk").is(":checked") ) {
rpcnt = parseInt( $("#cal_loopNum").val() );
}
if ( $("#cal_loopUntilChk").is(":checked") ) {
let ld = $("#cal_loopUntil").datetimepicker("date")._d;
rpdate = new Date(ld.getFullYear(), ld.getMonth(), ld.getDate(), 24, 0);
}
let crmn = 0;
if ( $("#cal_crm1").is(":checked") ) {
crmn = 1;
} else if ( $("#cal_crm2").is(":checked") ) {
crmn = 2;
} else if ( $("#cal_crm3").is(":checked") ) {
crmn = 3;
}
let calurl = makeGcalUrl( $("#cal_title").val()
, stD, enD, $("#cal_allDay").is(":checked")
, rptype, rpcnt, rpdate
, getTimezoneName()
, $("#cal_detail").val()
, $("#cal_location").val(), crmn
, $("#cal_guests").val(), $("#cal_source").val() );
// 링크 출력
$("#cal_url").text(calurl);
$("#cal_url").attr("href", calurl);
}
function endSite() {
// onBeforeUnload
}
</script>
</head>
<body onload="beginSite();" onbeforeunload="endSite();">
<!-- contents -->
<div class="container">
<div class="py-5 text-center">
<h2>구글 캘린더 일정 링크 생성기</h2>
<p class="lead">아래의 내용을 작성한 후 링크 생성을 누르면 구글 캘린더에 추가가 가능한 링크를 생성합니다.</p>
</div>
<div class="row">
<div class="col-md-2 col-sm-4">
<label>제목</label>
</div>
<div class="col-md-10 col-sm-8">
<input id="cal_title" type="text" class="form-control" placeholder="제목" value="" required>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>시간대</label>
</div>
<div class="col-md-10 col-sm-8">
<input id="cal_timezone" type="text" class="form-control" placeholder="시간대" value="" readonly>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>시작 시간</label>
</div>
<div class="col-md-10 col-sm-8">
<div class="row">
<div class="col-md">
<input id="cal_startDate" type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker" data-target="#cal_startDate">
</div>
<div class="col-md">
<input id="cal_startTime" type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker" data-target="#cal_startTime">
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>끝 시간</label>
</div>
<div class="col-md-10 col-sm-8">
<div class="row">
<div class="col-md">
<input id="cal_endDate" type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker" data-target="#cal_endDate">
</div>
<div class="col-md">
<input id="cal_endTime" type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker" data-target="#cal_endTime">
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>옵션</label>
</div>
<div class="col-md-10 col-sm-8">
<div class="row">
<div class="col-md-auto col-sm-12">
<div class="form-check">
<label>
<input id="cal_allDay" type="checkbox"> <span class="label-text">종일 일정</span>
</label>
</div>
</div>
<div class="col-md-auto offset-md-1">
<input id="cal_loop" type="hidden" value=0>
<div class="dropdown">
<button id="cal_loopDrop" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">반복 없음</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<h6 class="dropdown-header">일정 반복 옵션</h6>
<button id="cal_loopNone" type="button" class="dropdown-item active" onclick="onClickLoopOpt(0);">반복 없음</button>
<button id="cal_loopDay" type="button" class="dropdown-item" onclick="onClickLoopOpt(1);">매일 같은 시간</button>
<button id="cal_loopWeek" type="button" class="dropdown-item" onclick="onClickLoopOpt(2);">매주 같은 요일</button>
<button id="cal_loopMonth" type="button" class="dropdown-item" onclick="onClickLoopOpt(3);">매월 같은 일자</button>
<button id="cal_loopYear" type="button" class="dropdown-item" onclick="onClickLoopOpt(4);">매년 같은 날짜</button>
</div>
</div>
</div>
<div id="cal_loopOpt" class="col">
<div class="row">
<div class="col-auto">
<div class="form-check">
<label>
<input id="cal_loopNumChk" type="checkbox"> <h6 class="label-text">반복 횟수</h6>
</label>
</div>
</div>
<div class="w-100 d-block d-sm-none"></div>
<div class="col">
<input id="cal_loopNumLast" type="hidden" value="2">
<input id="cal_loopNum" type="number" class="form-control" placeholder="무한" value="2" disabled>
</div>
</div>
<div class="row">
<div class="col-auto">
<div class="form-check">
<label>
<input id="cal_loopUntilChk" type="checkbox"> <h6 class="label-text">종료 시점</h6>
</label>
</div>
</div>
<div class="w-100 d-block d-sm-none"></div>
<div class="col">
<input id="cal_loopUntil" type="text" class="form-control datetimepicker-input" placeholder="영원히" value="" disabled data-toggle="datetimepicker" data-target="#cal_loopUntil">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>상세 내용</label>
</div>
<div class="col-md-10 col-sm-8">
<textarea id="cal_detail" class="form-control" rows=4 placeholder="HTML 태그 사용 가능"></textarea>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>위치</label>
</div>
<div class="col-md-10 col-sm-8">
<input id="cal_location" type="text" class="form-control" placeholder="위치" value="">
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>상태</label>
</div>
<div class="col-md-10 col-sm-8">
<div class="form-check">
<label>
<input id="cal_crm0" type="radio" name="cal_crmgrp" checked> <span class="label-text">기본</span>
</label>
<span> </span>
<label>
<input id="cal_crm1" type="radio" name="cal_crmgrp"> <span class="label-text">한가함</span>
</label>
<span> </span>
<label>
<input id="cal_crm2" type="radio" name="cal_crmgrp"> <span class="label-text">바쁨</span>
</label>
<span> </span>
<label>
<input id="cal_crm3" type="radio" name="cal_crmgrp"> <span class="label-text">불참</span>
</label>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>참석자들</label>
</div>
<div class="col-md-10 col-sm-8">
<input id="cal_guests" type="email" class="form-control" multiple placeholder="콤마로 구분된 메일 주소 목록" value="">
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>주최자</label>
</div>
<div class="col-md-10 col-sm-8">
<input id="cal_source" type="email" class="form-control" placeholder="일정을 생성한 사람의 메일 주소" value="">
</div>
</div>
<div class="row top-buffer">
<div class="col">
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="makeUrl();">링크 생성</button>
</div>
</div>
<div class="row top-buffer">
<div class="col-md-2 col-sm-4">
<label>생성 결과</label>
</div>
<div class="col-md-10 col-sm-8">
<a id="cal_url" href="#" target="_blank">#</a>
</div>
</div>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">© 2019 바람정보기술 유한책임회사</p>
<div class="row top-buffer justify-content-center">
<div class="col-auto d-none d-xl-block">xl</div>
<div class="col-auto d-none d-lg-block d-xl-none">lg</div>
<div class="col-auto d-none d-md-block d-lg-none">md</div>
<div class="col-auto d-none d-sm-block d-md-none">sm</div>
<div class="col-auto d-block d-sm-none">xs</div>
</div>
</footer>
</div>
</body>
</html>