-
Notifications
You must be signed in to change notification settings - Fork 1
/
share.html
32 lines (30 loc) · 960 Bytes
/
share.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Radio - Shared link</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="assets/icon.png" type="image/png">
</head>
<script type="module">
import Table from "./lib/storage.js";
var handleShare = async function() {
var search = new URLSearchParams(window.location.search);
var params = Object.fromEntries(search);
var url = params.url || params.text || params.title;
if (url && url.match(/^https?:\/\//i)) {
var confirmed = window.confirm(`Add feed at "${url}"?`);
if (confirmed) {
var feeds = new Table("feeds");
await feeds.set(url, { url, subscribed: Date.now() });
}
} else {
window.alert(`Shared data "${url}" doesn't seem to be a valid URL`);
}
// redirect to the actual app
window.location = "./";
};
window.addEventListener("DOMContentLoaded", handleShare);
</script>
</html>