-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
81 lines (72 loc) · 2.57 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>電子報產生器</title>
<script src="feature-check.js"></script>
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css">
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">
資訊服務團隊 電子報產生器
</span>
</div>
</header>
<main class="mdl-layout__content Main">
<div class="page-content">
<div class="mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">自動套用電子報樣板</h2>
</div>
<div class="mdl-card__supporting-text">
<p>請確認 Google doc 裡:</p>
<ul>
<li>電子報標題已經套用「Title」格式</li>
<li>Google doc 已經發佈成網頁</li>
</ul>
<form action="#" id="form">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="publish-url">
<label class="mdl-textfield__label" for="publish-url">在此貼上「電子報發佈網址」</label>
</div>
</form>
</div>
</div>
</div>
</main>
</div>
<script>
(() => {
'use strict'
let $form = document.querySelector('#form')
let $input = document.querySelector('#publish-url')
$form.addEventListener('submit', (e) => {
e.preventDefault()
check()
})
$input.addEventListener('paste', () => {
// Paste event is fired before the input is actually populated,
// thus delay a bit before invoking check()
//
setTimeout(check, 0)
})
function check() {
// Format:
// https://docs.google.com/document/d/<DOC_ID>/pub
let url = $input.value
let match = url.match(/https:\/\/docs\.google\.com\/document\/d\/(.+)\/pub/)
if(!match){
alert('請貼上「發佈到網路」的 URL (https://docs.google.com/document/d/xxxxx/pub) 喔!')
return
}
location.href = match[1]
}
})()
</script>
</body>
</html>