Skip to content

Commit 619165a

Browse files
committed
Refactor subscribe JS
Remove jQuery dependency.
1 parent 1a0d4d9 commit 619165a

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

deeplink/subscribe/index.html

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@
2424
</div>
2525

2626
<script>
27-
var getUrlParameter = function getUrlParameter(sParam) {
28-
var sPageURL = window.location.search.substring(1),
29-
sURLVariables = sPageURL.split('&'), sParameterName, i;
30-
for (i = 0; i < sURLVariables.length; i++) {
31-
sParameterName = sURLVariables[i].split('=');
32-
if (sParameterName[0] === sParam) {
33-
return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
34-
}
27+
const getUrlParameter = (sParam) => {
28+
const paramValue = new URLSearchParams(window.location.search.substring(1)).get(sParam) ?? '';
29+
if(0 < paramValue.length) {
30+
return decodeURIComponent(paramValue);
3531
}
3632
return false;
3733
};
3834

39-
jQuery("#urlTextBox").text(getUrlParameter("url"));
40-
jQuery("#retryButton").click(function() {
41-
window.open("antennapod-subscribe://" + getUrlParameter("url"));
42-
});
35+
const urlTextBox = document.getElementById("urlTextBox");
36+
const retryButton = document.getElementById("retryButton");
37+
if(getUrlParameter("url") === false) {
38+
urlTextBox.textContent = "URL not available";
39+
retryButton.disabled = true;
40+
retryButton.textContent += " (error)";
41+
42+
} else {
43+
urlTextBox.textContent = getUrlParameter("url");
44+
retryButton.onclick = () => {
45+
window.open("antennapod-subscribe://" + getUrlParameter("url"));
46+
};
47+
}
4348
</script>

0 commit comments

Comments
 (0)