Skip to content

Commit

Permalink
Refactor subscribe JS
Browse files Browse the repository at this point in the history
Remove jQuery dependency.
  • Loading branch information
Rotzbua committed Jul 26, 2023
1 parent 018b121 commit 8c0b452
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions deeplink/subscribe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@
</div>

<script>
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'), sParameterName, i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
const getUrlParameter = (sParam) => {
const paramValue = new URLSearchParams(window.location.search.substring(1)).get(sParam) ?? '';
if(0 < paramValue.length) {
return decodeURIComponent(paramValue);
}
return false;
};

jQuery("#urlTextBox").text(getUrlParameter("url"));
jQuery("#retryButton").click(function() {
window.open("antennapod-subscribe://" + getUrlParameter("url"));
});
const urlTextBox = document.getElementById("urlTextBox");
const retryButton = document.getElementById("retryButton");
if(getUrlParameter("url") === false) {
urlTextBox.textContent = "URL not available";
retryButton.disabled = true;
retryButton.textContent += " (error)";

} else {
urlTextBox.textContent = getUrlParameter("url");
retryButton.onclick = () => {
window.open("antennapod-subscribe://" + getUrlParameter("url"));
};
}
</script>

0 comments on commit 8c0b452

Please sign in to comment.