2022-08-07 00:12:30 +03:00
function rssbridge _list _search ( ) {
function remove _www _from _url ( url ) {
if ( url . hostname . indexOf ( 'www.' ) === 0 ) {
url . hostname = url . hostname . substr ( 4 ) ;
}
}
var search = document . getElementById ( 'searchfield' ) . value ;
var searchAsUrl = document . createElement ( 'a' ) ;
searchAsUrl . href = search ;
remove _www _from _url ( searchAsUrl ) ;
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 bridgeUrl = bridgeCards [ i ] . getElementsByTagName ( 'a' ) [ 0 ] ;
remove _www _from _url ( bridgeUrl ) ;
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 . toString ( ) . match ( searchRegex ) ) {
bridgeCards [ i ] . style . display = 'block' ;
}
if ( bridgeUrl . hostname === searchAsUrl . hostname ) {
bridgeCards [ i ] . style . display = 'block' ;
}
}
2017-03-21 23:31:10 +03:00
}
2022-08-18 23:52:01 +03:00
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 ;
}
}
2023-08-22 21:44:36 +03:00
2023-10-02 04:02:57 +03:00
function rssbridge _use _placeholder _value ( sender ) {
let inputId = sender . getAttribute ( 'data-for' ) ;
let inputElement = document . getElementById ( inputId ) ;
inputElement . value = inputElement . getAttribute ( "placeholder" ) ;
}
2023-08-22 21:44:36 +03:00
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' ) ;
2023-09-06 04:46:47 +03:00
let content = encodeURIComponent ( input . value ) ;
2023-08-22 21:44:36 +03:00
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 += ` <div class="search-result">
< div class = "icon" >
< img src = "${element.bridgeMeta.icon}" width = "60" / >
< / d i v >
< div class = "content" >
< h2 > < a href = "${element.url}" > $ { element . bridgeMeta . name } < / a > < / h 2 >
< p >
< span class = "description" > < a href = "${element.url}" > $ { element . bridgeMeta . description } < / a > < / s p a n >
< / p >
< div >
< ul > ` ;
// Now display every Feed parameter
for ( const param in element . bridgeData ) {
content += ` <li> ${ element . bridgeData [ param ] . name } : ${ element . bridgeData [ param ] . value } </li> ` ;
}
content += ` </div>
< / d i v >
< / d i v > ` ;
}
content += '<p><div class="alert alert-info" role="alert">This feed may be only one of the possible feeds. You may find more feeds using one of the bridges with different parameters, for example.</div></p>' ;
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 !<div class="alert alert-info" role="alert">Not every bridge supports feed detection. You can check below within the bridge parameters to create a feed.</div>' ;
}
// 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 ;
} ( ) ) ;