1 parent 5fe98a5 commit 36c694eCopy full SHA for 36c694e
1 file changed
index_tmpl.html
@@ -124,7 +124,26 @@
124
{{- if .IsBreaking }}
125
<button class="btn" title="resume from a break" onclick="javascript:resume();">
126
Resume from Breakpoint
127
- </button>
+ </button>
128
+ <script>
129
+ (function() {
130
+ let sent = false;
131
+
132
+ function sendBreak() {
133
+ if (sent) return;
134
+ sent = true;
135
+ const blob = new Blob([JSON.stringify({action: 'resume'})], {type: 'application/json'});
136
+ navigator.sendBeacon(window.location.href, blob);
137
+ }
138
139
+ document.addEventListener('visibilitychange', () => {
140
+ if (document.visibilityState === 'hidden') sendBreak();
141
+ });
142
143
+ window.addEventListener('beforeunload', sendBreak);
144
+ window.addEventListener('pagehide', sendBreak);
145
+ })();
146
+ </script>
147
{{- end }}
148
</p>
149
0 commit comments