-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathAddFeed.js
35 lines (29 loc) · 1.03 KB
/
AddFeed.js
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
document.getElementById("confirmButton").addEventListener('click', handleConfirm);
document.getElementById("gotoFeedButton").addEventListener('click', handleGotoFeed);
function handleConfirm() {
addFeedURL(document.getElementById("input").value);
console.log(userFeedURLs);
}
function handleGotoFeed() {
if (userFeedURLs.length == 0) {
alert("You haven't entered any RSS feeds");
return;
}
localStorage.setItem('userFeedURLs', userFeedURLs);
window.location.href = 'feed.html';
}
function addFeedURL(url) {
RemoveHtmlTagsFromURL(url);
if (url == "") {
alert("Please enter a RSS URL!")
return;
}
userFeedURLs.push(url);
document.getElementById("input").value = "";
var listElement = "<li class=\"list-group-item border border-dark bg-white\"><h5>" + url + "</h5></li>"
console.log(listElement);
document.getElementById("urlList").insertAdjacentHTML('beforeend', listElement)
}
function RemoveHtmlTagsFromURL(url) {
return url.replace(/(<([^>]+)>)/ig, "");
}