Repository navigation
Expand file tree
/
Copy pathview.html
More file actions
48 lines (48 loc) · 2.29 KB
/
Copy pathview.html
File metadata and controls
48 lines (48 loc) · 2.29 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
<!doctype html>
<html lang="zh-Hant">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>預覽</title>
<style>
html,body{margin:0;height:100%;background:#000;overflow:hidden;font:14px -apple-system,"PingFang TC",sans-serif}
body{display:flex;flex-direction:column}
#bar{display:flex;gap:8px;align-items:center;padding:10px 14px;background:#ececec;color:#111113;border-bottom:1px solid rgba(0,0,0,.09)}
#bar button,#bar a{background:rgba(0,0,0,.07);border:0;color:#111113;padding:8px 12px;border-radius:8px;font-size:14px;cursor:pointer;text-decoration:none;white-space:nowrap}
#bar button.on{background:#111113;color:#fff}
#bar .sp{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#bar .sub{color:#6c6c73;margin-left:8px}
#stage{flex:1;min-height:0;display:flex;justify-content:center;background:#000}
#frame{width:100%;height:100%;border:0;background:#fff}
#stage.mobile{padding:16px 0}
#stage.mobile #frame{width:390px;max-width:100%;border-radius:18px}
@media (max-width:600px){#bar .sub,#desktop,#mobile{display:none}}
</style>
</head>
<body>
<div id="bar">
<a href="index.html">← 返回</a>
<span class="sp"><b id="title"></b><span class="sub" id="desc"></span></span>
<button id="desktop" class="on">桌機</button>
<button id="mobile">手機</button>
<a id="open" target="_blank" rel="noopener">開啟網站 ↗</a>
</div>
<div id="stage"><iframe id="frame" allow="fullscreen"></iframe></div>
<script>
const id=new URLSearchParams(location.search).get('site');
const stage=document.getElementById('stage'),desktop=document.getElementById('desktop'),mobile=document.getElementById('mobile');
function mode(m){stage.classList.toggle('mobile',m);mobile.classList.toggle('on',m);desktop.classList.toggle('on',!m)}
desktop.onclick=()=>mode(false);
mobile.onclick=()=>mode(true);
fetch('sites.json',{cache:'no-cache'}).then(r=>r.json()).then(all=>{
const site=all.find(s=>s.id===id);
if(!site){document.getElementById('title').textContent='找不到網站';return}
document.title=site.title;
document.getElementById('title').textContent=site.title;
document.getElementById('desc').textContent=site.desc||'';
document.getElementById('open').href=site.url;
document.getElementById('frame').src=site.url;
});
</script>
</body>
</html>