-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
82 lines (74 loc) · 3.12 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
82
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" type="text/css" href="./style.css">
<title>RCCフォームビューア</title>
<script type="text/javascript"><!--
// ▼ここのURLをGASで公開した時に得られるものに置換▼
const APPURL = "https://script.google.com/macros/s/AKfycbzGTjqZBQaK6A1ib0AVfWj7Ruqp1MkCWwElm3uwlrR_RE7SLKvaaIZ-BbaTlvcGGGbD/exec";
const isIOS = /iP(hone|(o|a)d)/.test(navigator.userAgent);
window.onload = function(){
let furl = getParam("furl");
let token = getParam("token");
var link = document.createElement('link');
if(isIOS) link.href = 'frameForIos.css'; // IOS用CSS
else link.href = 'frameDefault.css'; // デフォルトCSS
link.rel = 'stylesheet';
link.type = 'text/css';
console.log("load: "+link.href);
document.getElementsByTagName('head')[0].appendChild(link);
if(furl){
try{
let lSec = document.getElementById("loader");
let addHtml = `<div style="background-color:#AAA; font-weight:900; padding:1em;">` +
`<p>このフォームに回答済みか調べています.</p>` +
`<p><a href="${furl}">スキップしてフォームを開くにはこちらをクリック</a></p></div>`;
lSec.innerHTML = lSec.innerHTML + addHtml;
token = document.cookie.split("userToken=")[1].split(";")[0];
}catch(e){
console.log(e);
}
window.open(APPURL+"?page=redirect&token="+token+"&furl="+furl,"_mainFrame");
history.replaceState("","","?");
}else if(token){
document.cookie = "userToken=" + encodeURIComponent(token) + ";max-age=8640000";
console.log("login token:" + token);
window.open(APPURL+"?page=login&token="+token,"_mainFrame");
history.replaceState("","","?");
}else{
try{
token = document.cookie.split("userToken=")[1].split(";")[0];
window.open(APPURL+"?page=view&token="+token,"_mainFrame");
}catch(e){
console.log(e);
window.open(APPURL,"_mainFrame");
}
}
var iframe = document.getElementById("_mainFrame");
iframe.onload = function(){
console.log("frame load: done!");
setTimeout(()=>{document.getElementById("loaderSec").style.display="none"},100);
}
}
function getParam(name) {
let url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
--></script>
</head>
<body>
<div class="iframeWrapper"><iframe name="_mainFrame" id="_mainFrame"></iframe></div>
<section id="loaderSec" style="display:flex;">
<div id="loader">
<img src="./logo-w.png" >
<div class="loaderInner">Loading...</div>
</div>
</section>
</body>
</html>