function rssbridge_list_search() { var search = document.getElementById('searchfield').value; var bridgeCards = document.querySelectorAll('section.bridge-card'); for (var i = 0; i < bridgeCards.length; i++) { var bridgeName = bridgeCards[i].getAttribute('data-ref'); var bridgeShortName = bridgeCards[i].getAttribute('data-short-name'); var bridgeDescription = bridgeCards[i].querySelector('.description'); var bridgeUrlElement = bridgeCards[i].getElementsByTagName('a')[0]; var bridgeUrl = bridgeUrlElement.toString(); bridgeCards[i].style.display = 'none'; if (!bridgeName || !bridgeUrl) { continue; } var searchRegex = new RegExp(search, 'i'); if (bridgeName.match(searchRegex)) { bridgeCards[i].style.display = 'block'; } if (bridgeShortName.match(searchRegex)) { bridgeCards[i].style.display = 'block'; } if (bridgeDescription.textContent.match(searchRegex)) { bridgeCards[i].style.display = 'block'; } if (bridgeUrl.match(searchRegex)) { bridgeCards[i].style.display = 'block'; } } } function rssbridge_toggle_bridge(){ var fragment = window.location.hash.substr(1); var bridge = document.getElementById(fragment); if(bridge !== null) { bridge.getElementsByClassName('showmore-box')[0].checked = true; } } function rssbridge_use_placeholder_value(sender) { let inputId = sender.getAttribute('data-for'); let inputElement = document.getElementById(inputId); inputElement.value = inputElement.getAttribute("placeholder"); } var rssbridge_feed_finder = (function() { /* * Code for "Find feed by URL" feature */ // Start the Feed search async function rssbridge_feed_search(event) { const input = document.getElementById('searchfield'); let content = encodeURIComponent(input.value); if (content) { const findfeedresults = document.getElementById('findfeedresults'); findfeedresults.innerHTML = 'Searching for matching feeds ...'; let baseurl = window.location.protocol + window.location.pathname; let url = baseurl + '?action=findfeed&format=Html&url=' + content; const response = await fetch(url); if (response.ok) { const data = await response.json(); rss_bridge_feed_display_found_feed(data); } else { rss_bridge_feed_display_feed_search_fail(); } } else { rss_bridge_feed_display_find_feed_empty(); } } // Display the found feeds function rss_bridge_feed_display_found_feed(obj) { const findfeedresults = document.getElementById('findfeedresults'); let content = 'Found Feed(s) :'; // Let's go throug every Feed found for (const element of obj) { content += `

${element.bridgeMeta.name}

${element.bridgeMeta.description}

    `; // Now display every Feed parameter for (const param in element.bridgeData) { content += `
  • ${element.bridgeData[param].name} : ${element.bridgeData[param].value}
  • `; } content += `
`; } content += '

'; findfeedresults.innerHTML = content; } // Display an error if no feed were found function rss_bridge_feed_display_feed_search_fail() { const findfeedresults = document.getElementById('findfeedresults'); findfeedresults.innerHTML = 'No Feed found !'; } // Empty the Found Feed section function rss_bridge_feed_display_find_feed_empty() { const findfeedresults = document.getElementById('findfeedresults'); findfeedresults.innerHTML = ''; } // Add Event to 'Detect Feed" button var rssbridge_feed_finder = function() { const button = document.getElementById('findfeed'); button.addEventListener("click", rssbridge_feed_search); button.addEventListener("keyup", rssbridge_feed_search); }; return rssbridge_feed_finder; }());