-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
159 lines (150 loc) · 7.32 KB
/
Copy pathindex.html
File metadata and controls
159 lines (150 loc) · 7.32 KB
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
<!DOCTYPE html>
<html lang="zh-tw">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.1/echarts.min.js" integrity="sha512-OTbGFYPLe3jhy4bUwbB8nls0TFgz10kn0TLkmyA+l3FyivDs31zsXCjOis7YGDtE2Jsy0+fzW+3/OVoPVujPmQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>元智大學學生會學權儀表板</title>
<meta name="description" content="元智大學學生會各項學生權利案辦理進度一覽" />
<meta property="og:type" content="website">
<meta property="og:url" content="https://rights.yzusa.tw">
<meta property="og:title" content="元智大學學生會 - 學權儀表板" />
<meta property="og:description" content="元智大學學生會各項學生權利案辦理進度一覽"/>
<meta property="og:image" content="https://docs.google.com/spreadsheets/d/e/2PACX-1vRgQl4LfaqBclXxx3Viri6DgwM-iY7EYOvrwpbzm95ykfT7RwnV5iUjwmc-dmY0eCilPtqOliOmzTg0/pubchart?oid=1633780512&format=image"/>
<link rel="canonical" href="https://rights.yzusa.tw" />
</head>
<body class="bg-gray-100">
<div class="min-h-screen relative" id="app">
<div class="z-10 sticky top-0 bg-white/75 drop-shadow-md backdrop-blur-md">
<p class="p-2 pl-10 text-xl font-bold">元智大學學生會 學權儀表板</p>
</div>
<!-- <div class="bg-white flex justify-center w-full p-4">
<img src="https://docs.google.com/spreadsheets/d/e/2PACX-1vRgQl4LfaqBclXxx3Viri6DgwM-iY7EYOvrwpbzm95ykfT7RwnV5iUjwmc-dmY0eCilPtqOliOmzTg0/pubchart?oid=1633780512&format=image" alt="">
</div> -->
<ring-chart class="bg-white h-[32rem] w-full" :data="stats"></ring-chart>
<div class="p-2 pb-16 xl:px-64 grid grid-cols-1 md:grid-cols-3">
<div class="" v-for="project in projects">
<card :name="project.名稱" :status="project.狀態" :p-description="project.進度"></card>
</div>
</div>
<div class="bg-[#2b476c] absolute bottom-0 w-full">
<p class="p-2 text-center text-white">©2023 Yuan Ze University Student Association</p>
</div>
</div>
<script src="https://unpkg.com/vue@3.4.5"></script>
<script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"></script>
<script>
const options = {
moduleCache: {
vue: Vue
},
async getFile(url) {
const res = await fetch(url);
if ( !res.ok )
throw Object.assign(new Error(res.statusText + ' ' + url), { res });
return {
getContentData: asBinary => asBinary ? res.arrayBuffer() : res.text(),
}
},
addStyle(textContent) {
const style = Object.assign(document.createElement('style'), { textContent });
const ref = document.head.getElementsByTagName('style')[0] || null;
document.head.insertBefore(style, ref);
},
}
const { loadModule } = window['vue3-sfc-loader'];
const app = Vue.createApp({
data() {
return {
projects: [],
stats: []
}
},
methods: {
fetchData() {
const id = '18i4ERupX1FHffrYmYlmYxOpiNGEkE0vCmtGcEtWyPPw';
const gid = '0';
const url = 'https://docs.google.com/spreadsheets/d/'+id+'/gviz/tq?tqx=out:json&tq&gid='+gid;
fetch(url)
.then( res => {
if(!res.ok) throw new Error('Cannot fetch data!');
return res.text();
})
.then( rawData => {
let data = JSON.parse(rawData.match(new RegExp('(?:^|\\,)"table":(.*?)(?:}\\);|$)'))[1]);
let table = []
let row = []
data.cols.forEach(colonne => row.push(colonne.label))
table.push(row)
data.rows.forEach(r => {
let row = []
r.c.forEach(cel => {
try{var value = cel.f ? cel.f : cel.v}
catch(e){var value = ''}
row.push(value)
}
)
table.push(row)
}
)
// create a Object using the first row as key
for (let i = 2; i < table.length; i++) {
let obj = {}
for (let j = 0; j < table[1].length; j++) {
obj[table[1][j]] = table[i][j]
}
this.projects.push(obj)
}
} )
},
fetchStat() {
const id = '18i4ERupX1FHffrYmYlmYxOpiNGEkE0vCmtGcEtWyPPw';
const gid = '747570329';
const url = 'https://docs.google.com/spreadsheets/d/'+id+'/gviz/tq?tqx=out:json&tq&gid='+gid;
fetch(url)
.then( res => {
if(!res.ok) throw new Error('Cannot fetch data!');
return res.text();
})
.then( rawData => {
let data = JSON.parse(rawData.match(new RegExp('(?:^|\\,)"table":(.*?)(?:}\\);|$)'))[1]);
let table = []
let row = []
data.cols.forEach(colonne => row.push(colonne.label))
table.push(row)
data.rows.forEach(r => {
let row = []
r.c.forEach(cel => {
try{var value = cel.f ? cel.f : cel.v}
catch(e){var value = ''}
row.push(value)
}
)
table.push(row)
}
)
// create a Object using the first row as key
for (let i = 1; i < table.length; i++) {
let obj = {}
obj[table[0][0]] = table[i][0];
obj[table[0][1]] = parseInt(table[i][1]);
this.stats.push(obj)
}
} )
}
},
components: {
'card': Vue.defineAsyncComponent( () => loadModule('./Card.vue', options) ),
'ring-chart': Vue.defineAsyncComponent( () => loadModule('./RingChart.vue', options) )
},
beforeMount() {
this.fetchData();
this.fetchStat();
}
});
app.mount('#app');
</script>
</body>
</html>