Repository navigation
Expand file tree
/
Copy pathnotepad.html
More file actions
205 lines (199 loc) · 10.5 KB
/
Copy pathnotepad.html
File metadata and controls
205 lines (199 loc) · 10.5 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
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta name="theme-color" content="#1a7ff5">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="GitFiles 记事本">
<script>
(function () {
if (/\/notepad\.html\/+$/.test(location.pathname)) {
location.replace(
location.pathname.replace(/\/notepad\.html\/+$/, '/notepad.html')
+ location.search
+ location.hash
);
return;
}
const APP_ROOT_KEY = 'storage_hub_app_root';
const DEPLOY_BASE = '/GitFiles';
function looksLikeDriveRouteSegment(segment) {
return segment.includes('@') || (segment.includes('.') && !segment.includes(' '));
}
function isPlausibleStoredRoot(stored, pathname) {
if (!stored) return true;
if (stored === DEPLOY_BASE) {
return pathname === DEPLOY_BASE || pathname.startsWith(`${DEPLOY_BASE}/`)
|| /\.github\.io$/i.test(location.hostname);
}
const parts = pathname.replace(/\/$/, '').split('/').filter(Boolean);
if (parts.length >= 2 && `/${parts[0]}` === stored && !looksLikeDriveRouteSegment(parts[1])) {
return false;
}
const bare = pathname.replace(/\/+$/, '') || '/';
if (bare === '/' || bare === stored) return true;
return pathname === stored || pathname.startsWith(`${stored}/`);
}
function detectRoot(pathname) {
if (DEPLOY_BASE && (pathname === DEPLOY_BASE || pathname.startsWith(`${DEPLOY_BASE}/`))) {
return DEPLOY_BASE;
}
if (pathname.endsWith('/index.html')) {
return pathname.slice(0, -'/index.html'.length).replace(/\/$/, '');
}
if (pathname.endsWith('/notepad.html') || /\/notepad\.html\/+$/.test(pathname)) {
return pathname.replace(/\/notepad\.html\/?$/, '').replace(/\/$/, '');
}
try {
const stored = sessionStorage.getItem(APP_ROOT_KEY);
if (stored !== null && isPlausibleStoredRoot(stored, pathname)) {
return stored;
}
} catch (_) {}
const parts = pathname.replace(/\/$/, '').split('/').filter(Boolean);
if (!parts.length) return '';
if (looksLikeDriveRouteSegment(parts[0])) return '';
if (parts.length >= 2 && looksLikeDriveRouteSegment(parts[1])) {
return `/${parts[0]}`;
}
return '';
}
const root = detectRoot(location.pathname);
const href = root ? `${root}/` : '/';
if (!document.querySelector('base[data-storage-hub-root]')) {
const base = document.createElement('base');
base.href = href;
base.setAttribute('data-storage-hub-root', '1');
document.head.appendChild(base);
}
})();
</script>
<script src="js/site-config.js"></script>
<!-- 覆盖文件须在 config.js 之前加载:config.js 执行时读取 window.CONFIG_OVERRIDES 完成合并 -->
<script src="js/config.local.js"></script>
<script src="js/config.runtime.js"></script>
<script src="js/config.js"></script>
<script src="js/base-path.js"></script>
<script src="js/app-version.js"></script>
<title>Notepad — GitFiles</title>
<!-- 唯一样式表:style.css 内含「V2 覆盖层」小节(原 ui-v2.css 已并入)。 -->
<link rel="stylesheet" data-storage-hub-css href="css/style.css">
<script>BasePath.bootstrapHeadAssets();</script>
<link id="notepad-favicon-32" rel="icon" href="assets/favicon-32.png" sizes="32x32" type="image/png">
<link id="notepad-favicon-svg" rel="icon" href="assets/favicon.svg" type="image/svg+xml">
<link id="notepad-manifest" rel="manifest" href="manifest.webmanifest">
</head>
<body class="notepad-page">
<div id="notepad-app" class="notepad-shell">
<div class="notepad-window">
<div class="title-bar notepad-titlebar">
<div class="title-bar-left">
<svg class="notepad-app-icon" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
<path fill="currentColor" d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm-1 2l5 5h-5V4zM8 13h8v2H8v-2zm0 4h5v2H8v-2z"/>
</svg>
<span id="notepad-title" class="notepad-title">未命名 - 记事本</span>
</div>
<div class="title-bar-controls">
<button type="button" class="title-btn" aria-label="最小化" disabled>─</button>
<button type="button" class="title-btn" aria-label="最大化" disabled>□</button>
<button type="button" class="title-btn close notepad-close" aria-label="关闭">✕</button>
</div>
</div>
<div class="notepad-menubar">
<div class="notepad-menu">
<span class="notepad-menu-label">文件</span>
<div class="notepad-menu-dropdown">
<button type="button" data-notepad-action="save">保存 <span class="notepad-kbd">Ctrl+S</span></button>
<button type="button" data-notepad-action="save-as">另存为…</button>
<div class="notepad-menu-sep"></div>
<button type="button" data-notepad-action="print">打印…</button>
<div class="notepad-menu-sep"></div>
<button type="button" data-notepad-action="close">退出 <span class="notepad-kbd">Ctrl+W</span></button>
</div>
</div>
<div class="notepad-menu">
<span class="notepad-menu-label">编辑</span>
<div class="notepad-menu-dropdown">
<button type="button" data-notepad-action="find">查找… <span class="notepad-kbd">Ctrl+F</span></button>
<button type="button" data-notepad-action="replace">替换… <span class="notepad-kbd">Ctrl+H</span></button>
<div class="notepad-menu-sep"></div>
<button type="button" data-notepad-action="select-all">全选</button>
<button type="button" data-notepad-action="time-date">时间/日期</button>
</div>
</div>
<div class="notepad-menu">
<span class="notepad-menu-label">格式</span>
<div class="notepad-menu-dropdown">
<button type="button" id="notepad-wrap-toggle" data-notepad-action="wrap" class="active" aria-pressed="true">自动换行</button>
</div>
</div>
<div class="notepad-menu">
<span class="notepad-menu-label">帮助</span>
<div class="notepad-menu-dropdown">
<button type="button" data-notepad-action="about">关于记事本</button>
</div>
</div>
</div>
<div class="notepad-toolbar">
<button type="button" class="notepad-tool-btn notepad-tool-btn--primary" data-notepad-action="save" title="保存">
<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true"><path fill="currentColor" d="M17 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-4-4zm-5 16a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm3-9H5V5h10v5z"/></svg>
保存
</button>
<span class="notepad-toolbar-sep" aria-hidden="true"></span>
<button type="button" class="notepad-tool-btn" id="notepad-undo-btn" data-notepad-action="undo" title="撤销" disabled>撤销</button>
<button type="button" class="notepad-tool-btn" id="notepad-redo-btn" data-notepad-action="redo" title="重做" disabled>重做</button>
<span class="notepad-toolbar-sep" aria-hidden="true"></span>
<button type="button" class="notepad-tool-btn" data-notepad-action="find" title="查找">查找</button>
<button type="button" class="notepad-tool-btn" data-notepad-action="find-replace" title="查找和替换">查找和替换</button>
</div>
<div id="notepad-find-bar" class="notepad-find-bar hidden" role="search" aria-label="查找和替换">
<div class="notepad-find-row">
<label class="notepad-find-field">
<span class="notepad-find-label">查找</span>
<input type="text" id="notepad-find-input" class="notepad-find-input" autocomplete="off" spellcheck="false" aria-label="查找">
</label>
<label class="notepad-find-field notepad-find-field--replace">
<span class="notepad-find-label">替换</span>
<input type="text" id="notepad-find-replace" class="notepad-find-input" autocomplete="off" spellcheck="false" aria-label="替换为">
</label>
</div>
<div class="notepad-find-actions">
<button type="button" class="notepad-find-btn" data-find-action="prev" title="查找上一个">◀</button>
<button type="button" class="notepad-find-btn" data-find-action="next" title="查找下一个">▶</button>
<button type="button" class="notepad-find-btn notepad-find-btn--replace" data-find-action="replace">替换</button>
<button type="button" class="notepad-find-btn notepad-find-btn--replace" data-find-action="replace-all">全部替换</button>
<button type="button" class="notepad-find-btn notepad-find-btn--close" data-find-action="close" aria-label="关闭查找栏">✕</button>
</div>
<span id="notepad-find-status" class="notepad-find-status" aria-live="polite"></span>
</div>
<div id="notepad-banner" class="notepad-banner hidden" role="status"></div>
<div class="notepad-editor-area">
<div id="notepad-loading" class="notepad-loading hidden" aria-live="polite">
<div class="notepad-loading-spinner" aria-hidden="true"></div>
<span>加载中…</span>
</div>
<textarea id="notepad-editor" class="notepad-editor notepad-editor--wrap" spellcheck="false" wrap="soft" autocomplete="off" autocorrect="off" autocapitalize="off" aria-label="文档编辑器"></textarea>
</div>
<div class="notepad-statusbar">
<span id="notepad-modified"></span>
<span id="notepad-status"></span>
<span id="notepad-position">第 1 行,第 1 列</span>
</div>
</div>
</div>
<script src="js/storage-migrate.js"></script>
<script src="js/auth.js"></script>
<script src="js/drive.js"></script>
<script src="js/localdisk.js"></script>
<script src="js/github-api.js"></script>
<script src="js/github-paths.js"></script>
<script src="js/githubdisk.js"></script>
<script src="js/dialog.js"></script>
<script src="js/notepad.js"></script>
<script>Notepad.initStandalone();</script>
<script src="js/register-sw.js"></script>
</body>
</html>