For an interactive leaflet map, is there a way to make a search bar that filters data?

I’m working an interactive Leaflet map that has museum specimen location data. I want the user to be able to search for a specific specimen and have the map update based on the search.
Data is somewhat as the following:

Genus, Species, Lat, Long,

  1. Canis, Canis latrans, ., .
  2. Canis, Canis lupus, . , .
  3. Canis, Canis lupus, ., .
  4. Puma, Puma concolor, ., .

So I would want the user to be able to search either the genus or the entire species, and have the search bar autocomplete the search. If the user types in Canis I want the map to filter to only show specimens from the Canis genus. If the user wants to continue typing and search Canis lupus I want only Canis lupus specimens to be on the map.

I’ve looked at leaflet’s map and their search plugin only seems to handle one search result at once. I was thinking it would be useful to somehow combine their search and filter plugin but I’m not sure if this is the best way to do this or if there are better examples out there. Here are the links to the search and filter plugin respectively:

Search: https://github.com/stefanocudini/leaflet-search

Filter:https://github.com/maydemirx/leaflet-tag-filter-button

Would appreciate any code snippets or links to questions that are useful. Thank you!

Clicking one of SVG parts to show an image

I’m a JS noob, never touched any coding other than simple CSS stuff.
What I’m trying to do here is to create an interactive graphic where you click a part of the SVG, and it shows you a picture. Here’s the code I used:

 <script>
function myFunction(idblue) {
    var bluepic = "https://i.ibb.co/yfn8GwC/bluecity.jpg";
    document.getElementById(idblue).src = bluepic;
}

and I put the onclick on <path> like this.

<path id="bluecity" onclick="myFunction('idblue')" class="bc" d="000 000 000..."> </path>

However, it just doesn’t work. Here’s also the SVG file I’m fiddling with. How do I make it work?

what is difference between using delete keyword , assign undefined value to object literal in javascript? [duplicate]

I met some needs for deep copying original object literals, excepts some keys.
I know spread operator doesn’t copy deeply whole nested objects, however it’s not main points for this question, so let’s pass that issues.

so, back in original question,
I see no difference between using delete keyword and assign undefined to target property which I want to remove.

const original = {
   a: 1,
   b: 2,
}

const copied = {
  ...original,
  b: undefined
}

const explicitDelete = {
 ...original
}
delete explicitDelete["b"]

seems copied way is less verbose, but it’s totally okay with that way?

Converting Python Timedelta object in order to be read by Recharts

I’m trying to make basic plots in Recharts (using React) and Flask (using the Formula1 API). The data I get in Flask is originally a Timedelta object and I’m having trouble sending it over to React.
To send the data, it needs to be JSON serializable, so I tried converting it to:

  • a string (of the Timedelta object)
  • an integer (Timdelta converted to nanoseconds)

but I’m not sure how to unpack these in React.

Here are the 2 data formats I tried.

>>> data_str = [{
     "LapNumber": '0',
     "44": "0 days 00:01:27.440000",
     "6": "0 days 00:01:27.313000"},
    {"name": '1',
     "44": "0 days 00:01:28.982000",
     "6":  "0 days 00:01:27.504000"
     }]
>>> data_int = [{
         "LapNumber": '0',
         "44": 87440000000,
         "6": 87313000000},
        {"LapNumber": '1',
         "44": 88982000000,
         "6":  87504000000
         }]

app.py

@app.route('/api/lap_number_time')
    def getChartData():
        # data = list of dictionaries in one of the formats shown above
        return jsonify(data)

App.js

useEffect(() => {
        fetch("http://127.0.0.1:5000/api/lap_number_time")
            .then((res) => res.json())
            .then((data) => {
                console.log("first chart data is", data)
                setCurrentChartData(data)
            })
    }, [])

...
<LineChart width={400} height={400} data={currentChartData}>
    <Line type="monotone" dataKey="14" stroke="#8884d8" />
    <Line type="monotone" dataKey="ham" stroke="#82ca9d" />
    <Line type="monotone" dataKey="6" stroke="#1a5d57" />
    <XAxis dataKey="LapNumber"/>
    <YAxis />
    <Legend />
</LineChart>

My questions are:

  • Can I transfer the Timdelta object to Recharts and plot it there (since integer conversion for each data point would take a long time)?
  • if not, I got Recharts to successfully plot when its in integer format. But, I need help displaying it in [%min:%sec:%millisec] format in Recharts.

I am trying to use AJAX to change the orderby and order arguments in a WP_Query, but I can’t determine why my code won’t work

So I’ve been working on this for hours now. About 6 of them with no breaks and I cannot understand why this isn’t working.

So I have this form:

<div id="wp-ajax-filter-search" class="full">
        <form action="" method="get">
            <div class="flex filters-grid">
                <div id="#sortBy" class="flex filters-dropdown">
                    <p class="filters-title">
                        Sort By
                    </p>
                    <div class="filters-options">
                        <input class="wp-drop-filter-item" type="radio" id="alphabetically" value="title" name="sort_filter">
                            <label for="alphabetically">
                                Alphabetically
                            </label>
                        <input class="wp-drop-filter-item" type="radio" id="datenew2old" value="ASC" name="sort_filter">
                            <label for="datenew2old">
                                Date Added (New to Old)
                            </label>
                        <input class="wp-drop-filter-item" type="radio" id="dateold2new" value="DESC" name="sort_filter">
                            <label for="dateold2new">
                                Date Added (Old to New)
                            </label>
                    </div>
                </div>
                <div id="#countries" class="flex filters-dropdown">
                    <p class="filters-title">
                        Country
                    </p>
                    <?php
                    // set up a new query for each category, pulling in related posts.
                    $destinations = new WP_Query(
                        array(
                            'showposts'      => -1,
                            'post_type'      => 'destinations',
                            'post_status'    => 'publish',
                            'order_by' => 'title',
                            'order' => 'ASC'
                        )
                    );
                    if ($destinations->have_posts()):
                    ?>
                        <div class="filters-options">
                            <input class="wp-drop-filter-item <?php echo $country_slug ?>" type="radio" id="any" value="any" name="country_filter">
                                <label for="any">
                                    Any
                                </label>
                            <?php while ($destinations->have_posts()) : $destinations->the_post(); 
                            global $post;
                            $post_slug = $post->post_name;?>
                            <input class="wp-drop-filter-item country-option" type="radio" id="<?php echo $post_slug ?>" value="<?php echo $post->ID ?>" name="country_filter" >
                                <label for="<?php echo $post_slug; ?>">
                                    <?php echo get_the_title(); ?>
                                </label>
                            <?php endwhile; ?>
                            <?php
                                // Reset things, for good measure
                                $destinations = null;
                                wp_reset_postdata();
                            ?>

                        </div>
                    <?php endif; ?>
                </div>
                <div id="#regions" class="flex filters-dropdown">
                    <p class="filters-title">
                        Region <span class="extra">(Choose Country First)</span>
                    </p>
                    <?php
                    // set up a new query for each category, pulling in related posts.
                    $regions = new WP_Query(
                        array(
                            'showposts'      => -1,
                            'post_type'      => 'regions',
                            'post_status'    => 'publish',
                            'order_by'       => 'title',
                            'order'          => 'ASC'
                        )
                    );
                    if ($regions->have_posts()):
                    ?>
                        <div class="filters-options">
                            <input class="wp-drop-filter-item" type="radio" id="any-region" value="any" name="region_filter">
                            <label class="region-option" for="any-region">
                                    Any
                            </label>
                            <?php while ($regions->have_posts()) : $regions->the_post(); 
                            global $post;
                            $post_slug = $post->post_name;
                            $country = get_field( "country", $post ); 
                            $country_slug = get_post_field( 'post_name', $country ); ?> 
                            <input class="wp-drop-filter-item" type="radio" id="<?php echo $post_slug ?>" value="<?php echo $post->ID ?>" name="region_filter">
                            <label class="region-option <?php echo $country_slug ?>" for="<?php echo $post_slug; ?>">
                                <?php echo get_the_title(); ?>
                            </label>
                            <?php endwhile; ?>
                            <?php
                                // Reset things, for good measure
                                $regions = null;
                                wp_reset_postdata();
                            ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </form>
        <ul id="ajax_filter_search_results" class="destinations grid"></ul>
    </div>

Whenever you change one of the radio buttons, AJAX is triggered using this JS code:

var wpmafs = $("#wp-ajax-filter-search"); 
var wpmafsForm = wpmafs.find("form"); 


$(".wp-drop-filter-item").on("change",function(e){
    e.preventDefault(); 

    var sort_filter = $("input[name='sort_filter']:checked").val();
    var country_filter = $("input[name='country_filter']:checked").val();
    var region_filter = $("input[name='region_filter']:checked").val();

    var data = {
        action : "wp_ajax_filter_search",
        sort_filter : sort_filter,
        country_filter : country_filter,
        region_filter : region_filter
    };
    
    console.log(data);
    
    $.ajax({
        url : ajax_url,
        data : data,
        success : function(response) {
            grid = $( "#ajax_filter_search_results" );
            wpmafs.find(grid).empty();
            if(response) {
                for(var i = 0 ;  i < response.length ; i++) {
                    var html = '<a class="grid-item destination" href="' + response[i].permalink + '">';
                        html += '<p class="grid-item-title">' + response[i].title + '</p>';
                        html += '<ul class="features">';
                        var features = response[i].features;
                        for(var k = 0 ;  k < features.length ; k++){
                            if(k > 3) break;
                            html += '<li> <img width="8" height="8" src="/wp-content/uploads/2022/03/golf-escapes-sussex-uk-packages-benefits-copy.svg" class="attachment-medium size-medium">' + features[k]['point'] + '</li>';
                        }
                        html += '</ul>';
                        html += '<div class="bg-img">';
                        html +=     '<img src="' + response[i].image_url + '">';
                        html += '</div>';
                        html += '</a>';
                        wpmafs.find(grid).append(html);
                }
            } else {
                var html  = "<li class='no-result'>No matches found. Try a different filter.</li>";
                wpmafs.find(grid).append(html);
            }
        },
        error: function() {
            grid = $( "#ajax_filter_search_results" );
            wpmafs.find(grid).empty();
            var html  = "<li class='no-result'>It appears we're having some technical difficulties. Please try again shortly or call us.</li>";
            wpmafs.find(grid).append(html);
        }
    });
});

And here’s the AJAX function:

function wp_ajax_filter_search_callback() {
 
    header("Content-Type: application/json"); 
    
    if(isset($GET['sort_filter'])) {
        $sortval = $GET['sort_filter'];
        if($sortval == 'title'){
            $orderby = $sortval;
            $order = 'ASC';
        } elseif ($sortval == 'ASC' || $sortval == 'DESC'){
            $orderby = 'date';
            $order = $sortval;
        } else {
            $orderby = 'title';
            $order = 'ASC';
        }
    };
    
    if(isset($_GET['country_filter'])) {
        $location = $_GET['country_filter'];
        if ($location != 'any'){
            $loc_query[] = array(
                'key' => 'country',
                'value' => $location,
                'compare' => "IN",
            );
        }
    };
    
    if(isset($_GET['region_filter'])) {
        $region = $_GET['region_filter'];
        if ($region != 'any'){
            $region_query[] = array(
                'key' => 'region',
                'value' => $region,
                'compare' => "IN",
            );
        }
    };  
    
    $meta_query = array(
        'relation' => 'AND',
        $loc_query,
        $region_query,
    );
    
    $args = array(
        'post_type' => 'hotels',
        'post_status' => 'publish',
        'posts_per_page' => -1,
        'orderby' => $orderby,
        'order' => $order,
        'meta_query' => $meta_query
    );
    
 
    $search_query = new WP_Query( $args );
 
    if ( $search_query->have_posts() ) {
 
        $result = array();
 
        while ( $search_query->have_posts() ) {
            $search_query->the_post();
 
            $result[] = array(
                "id" => get_the_ID(),
                "title" => get_the_title(),
                "permalink" => get_permalink(),
                "image_url" => get_the_post_thumbnail_url('', 'medium-large'),
                "features" => get_field('featured_offer')
            );
        }
        wp_reset_query();
 
        echo json_encode($result);
 
    } else {
        
    }
    wp_die();
}

I have used this code before on another website, so I know that it can work, but it’s not working in this instance.

The country_filter and region_filter radio buttons are working. When you change them the AJAX call runs, and the wp_query is actually filtered.

The problem, however, is that the sort_filter radio button won’t work for some reason.

So, to test I’ve been putting print_r("some random bit of text") and checking the network tab in my browsers inspector to see if that text appears in the Request. Under if(isset($_GET['country_filter'])) and if(isset($_GET['region_filter'])), the text displays. But, if I put it under if(isset($_GET['sort_filter'])) it doesn’t display.

So, clearly, the AJAX code is getting to the if(isset($_GET['sort_filter'])) line and saying “Nope, it’s not set”. But it is.

And if I use console.log() in the JS code to log the data that is being sent to the AJAX call, I can clearly see that the value of the selected sort_filter radio button is being sent:

{action: 'wp_ajax_filter_search', sort_filter: 'title', country_filter: undefined, region_filter: undefined}

The request URL in the Network tab also has that information in it, for example:

https://my.staging.url/wp-admin/admin-ajax.php?action=wp_ajax_filter_search&sort_filter=title

Despite all that, I can’t get the AJAX code to $GET the sort_filter radio button value and use it in the WP_Query.

Any help is totally appreciated. I’m going to get some shut-eye for a bit as I’ve completely burnt myself out on this but I look forward to seeing what help anyone can offer because this really is driving me up the wall and the deadline is fast approaching.

Enormous thanks in advance!

How to use electron-redux in electron and react app to share state in multiple react renderer processes

I use electron and react to build desktop application,in the way electron-redux works you need to import the reducers in the main and in the renderer processes as well , in case of react you can not import files outside of ‘src’ folder, and by putting the reducers inside the ‘src’ folder and import it in the main process fails because electron uses ES5 importing syntax and react uses ES6, when electron import the reducers it seems to force the entire file to use ES5 syntax,

after making all import/export statements in the reducers file to use ES5, electron still complains and actually complains about syntax that used in other react files other than the reducers file !

is there a solution for this , or there is another way to use redux in electron react application ?

Thanks

How do you search for an element within a set when that element is an object/array that is passed by reference? [duplicate]

In JavaScript, objects within a set are passed by reference. This means calling any methods that would otherwise work on a set or array such as forEach or Set.has() won’t work if all of the elements are arrays.

Example Set:

{
  Alpha: [],
  Beta: [ 'abc' ],
  Delta: []
}

How do you find the array with the most elements (In this case, there is only one array with any elements at all) when the elements aren’t found since they are passed by reference?

Contact Form Validation Not Working But Successfully Sending Messages to Server

I followed a tutorial on sending a contact form message to a mail server and ran into validation issues.

The message sends to the server fine but I get this validation error:

“Error: {“type”:”success”,”message”:”Contact form successfully submitted. Thank you, I will get back to you soon!”}”

The validation js I am assuming is the issue since it came included with the theme and not part of the tutorial files for sending form messages via php.

I tried other bs validation methods and got no where. Any help or direction would be appreciated.

The php for the form action…

<?php
/*
 *  CONFIGURE EVERYTHING HERE
 */

// an email address that will be in the From field of the email.
$from = '<[email protected]>';

// an email address that will receive the email with the output of the form
$sendTo = '<[email protected]>';

// subject of the email
$subject = 'New message sent from a contact form on mysite.com';

// form field names and their translations.
// array variable name => Text to appear in the email
$fields = array('name' => 'Name', 'surname' => 'Surname', 'need' => 'Need', 'email' => 'Email', 'message' => 'Message');

// message that will be displayed when everything is OK :)
$okMessage = 'Contact form successfully submitted. Thank you, I will get back to you soon!';

// If something goes wrong, we will display this message.
$errorMessage = 'There was an error while submitting the form. Please try again later';

/*
 *  LET'S DO THE SENDING
 */

// if you are not debugging and don't need error reporting, turn this off by error_reporting(0);
error_reporting(E_ALL & ~E_NOTICE);

try
{

    if(count($_POST) == 0) throw new Exception('Form is empty');

    $emailText = "You have a new message from your contact formn=============================n";

    foreach ($_POST as $key => $value) {
        // If the field exists in the $fields array, include it in the email
        if (isset($fields[$key])) {
            $emailText .= "$fields[$key]: $valuen";
        }
    }

    // All the neccessary headers for the email.
    $headers = array('Content-Type: text/plain; charset="UTF-8";',
        'From: ' . $from,
        'Reply-To: ' . $from,
        'Return-Path: ' . $from,
    );

    // Send email
    mail($sendTo, $subject, $emailText, implode("n", $headers));

    $responseArray = array('type' => 'success', 'message' => $okMessage);
}
catch (Exception $e)
{
    $responseArray = array('type' => 'danger', 'message' => $errorMessage);
}


// if requested by AJAX request return JSON response
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    $encoded = json_encode($responseArray);

    header('Content-Type: application/json');

    echo $encoded;
}
// else just display the message
else {
    echo $responseArray['message'];
}
?>


The validation js file being called before the closing body tag…

(function () {
  "use strict";

  let forms = document.querySelectorAll('.php-email-form');

  forms.forEach( function(e) {
    e.addEventListener('submit', function(event) {
      event.preventDefault();

      let thisForm = this;

      let action = thisForm.getAttribute('action');
      let recaptcha = thisForm.getAttribute('data-recaptcha-site-key');

      if( ! action ) {
        displayError(thisForm, 'The form action property is not set!')
        return;
      }
      thisForm.querySelector('.loading').classList.add('d-block');
      thisForm.querySelector('.error-message').classList.remove('d-block');
      thisForm.querySelector('.sent-message').classList.remove('d-block');

      let formData = new FormData( thisForm );

      if ( recaptcha ) {
        if(typeof grecaptcha !== "undefined" ) {
          grecaptcha.ready(function() {
            try {
              grecaptcha.execute(recaptcha, {action: 'php_email_form_submit'})
              .then(token => {
                formData.set('recaptcha-response', token);
                php_email_form_submit(thisForm, action, formData);
              })
            } catch(error) {
              displayError(thisForm, error)
            }
          });
        } else {
          displayError(thisForm, 'The reCaptcha javascript API url is not loaded!')
        }
      } else {
        php_email_form_submit(thisForm, action, formData);
      }
    });
  });

  function php_email_form_submit(thisForm, action, formData) {
    fetch(action, {
      method: 'POST',
      body: formData,
      headers: {'X-Requested-With': 'XMLHttpRequest'}
    })
    .then(response => {
      if( response.ok ) {
        return response.text()
      } else {
        throw new Error(`${response.status} ${response.statusText} ${response.url}`);
      }
    })
    .then(data => {
      thisForm.querySelector('.loading').classList.remove('d-block');
      if (data.trim() == 'OK') {
        thisForm.querySelector('.sent-message').classList.add('d-block');
        thisForm.reset();
      } else {
        throw new Error(data ? data : 'Form submission failed and no error message returned from: ' + action);
      }
    })
    .catch((error) => {
      displayError(thisForm, error);
    });
  }

  function displayError(thisForm, error) {
    thisForm.querySelector('.loading').classList.remove('d-block');
    thisForm.querySelector('.error-message').innerHTML = error;
    thisForm.querySelector('.error-message').classList.add('d-block');
  }

})();```

Change color of Pathlayer on Click, MapBox DeckGl React.js

I have a mapbox React.js component implemented with DeckGl

I am trying to make my Pathlayer color changes on evenry mouse click (onClick), using onClick, getColor, getFillColor. As you see I have already the mechanism that detects that an item is clicked selectedItem which returns an object (with all item’s infos) but the color change does not seem to work.

  const [selectedItem, setSelectedItem] = useState("");



  const layers = [
  new PathLayer({
  id: "CanalisationData",
  data: reseauData,
  pickable: true,
  widthScale: 3,
  widthMinPixels: 2,
  autoHighlight: true,
  highlightColor: [255, 255, 255],
  getPath: (d) => d.GEOJSON.coordinates,
  onHover: (info) => setHoverCanalisations(info),
  onClick: (d) => setSelectedItem(d.object),
  getColor: d => findColor(d), 

  getFillColor: d => selectedItem ? [255,0,0] : [255, 255, 255],
  updateTriggers: {
      getFillColor: [selectedItem]
  })],

My idea is to say to the code :

if selectedItem ===> make the selected item look [255,0,0] color
else ===> just let it with the basic color.

What Am I doing wrong ?

map through two arrays React

I am wanting to display information on my app from two mapped arrays.

{filmWorld.Provider &&
        filmWorld.Movies.map((movie, index) => {
          return (
            <div className="movies" key={index}>
              <h3>{movie.Title}</h3>
              <img src={movie.Poster} alt={movie.Title} />
              <h5>{movie.Actors} </h5>
              <h6> Price: ${movie.Price}</h6>
              <hr />
            </div>
          );
        })}

This is currently working fine but I’m wanting to have another price displayed from another cinema ideally in the same h6. All the other information is the same.

the other map would be very similar:

{cinemaWorld.Provider &&
        cinemaWorld.Movies.map((movie, index) => {
          return (
            <div className="movies" key={index}>
              
          <h6> Price: ${movie.Price}</h6>
          
        </div>
      );
    })}

but again i would only need the price from this cinema to be displayed on the same h6 tag.
Or would it be more intuitive to take a different approach like merging the variables?

CSS Propery: backdrop-filter: blur(1rem); only works at some instances

I am having some issues with applying the backdrop-filter to some components of the website. It appears to me that this property works just fine on most occasions, however, there are some instances when I am not seeing any changes to the design and the blur is not being applied. Currently, I am using Google Chrome to view my website – so compatibility should not be an issue. Please find the applied code below.

HTML:

      <div class="content">
        <h1 class="hero-title">Castles.</h1>
        <p>
          Glasgow Science Centre is a visitor attraction on the south bank of
          the River Clyde in Glasgow, Scotland, in the Clyde Waterfront
          Regeneration region. The Glasgow Science Centre was inaugurated by
          Queen Elizabeth II on July 5, 2001. It is one of the most popular
          paid-for tourist attractions in Scotland.
        </p>
      </div>

CSS:

.content p {
  font-size: 18px;
  margin: 3rem 0;
  font-weight: 300;
  position: relative;
  background-color: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2rem);
  -webkit-backdrop-filter: blur(2rem);
}

How to get styling to refresh with new variable in react native

Using a global variable to store dark and light mode variable. In app I have place where variable is changed as user toggles if they want dark or light theme, but I cannot figure out how to get styling to refresh with this new variable once I have changed it. I know this is probably not the best way to go about it but can anyone help me out here?

/*  Universal styling page, all styling on pages is located here
    Styling is adjusted by window and screen dimensions so that
    styling will look nice on multiple devices of varying sizes
*/
import { StyleSheet, Dimensions, Appearance} from 'react-native';;

const window = Dimensions.get("window");
const screen = Dimensions.get("screen");
//const colorScheme = 'dark'
let pref = Appearance.getColorScheme();
global.COLORSCHEME = [pref];
const darkTheme = "#1A1A1A"
const lightTheme = "#FAFAFA"

export default StyleSheet.create({
    noPadContainer: {
        flex: 1,
        backgroundColor: COLORSCHEME[0]==="dark" ? darkTheme : lightTheme,

    },
    container: {
        flex: 1,
        padding: 24,
        backgroundColor: COLORSCHEME[0]==="dark" ? darkTheme : lightTheme
    },
    TextInput: {
        backgroundColor: COLORSCHEME[0]==="dark" ? "grey" : "#FAFAFA",
    },
    overlay: {
        flex: 2,
        position: 'absolute',
        left: 0,
        top: 0,
        opacity: COLORSCHEME[0]==="dark" ? 0.7 : 1.0,
        backgroundColor: COLORSCHEME[0]==="dark" ? 'black' : 'transparent',
        width: window.width,
        height: window.height,
        alignItems:"center",
        marginHorizontal: 0,
    },
    generalOverlay: {
        flex: 1,
        position: 'absolute',
        left: 0,
        top: 0,
        opacity: COLORSCHEME[0]==="dark" ? 0.7 : 1.0,
        backgroundColor: COLORSCHEME[0]==="dark" ? 'black' : 'transparent',
        width: window.width,
        height: window.height,
        marginHorizontal: 0,
    },
    generalButtonContained: {
        //backgroundColor: "#6200ed"
        backgroundColor: COLORSCHEME[0]==="dark" ? '#332940' : '#6200ed',
        color: COLORSCHEME[0]==="dark" ? '#696969' : '#FAFAFA',
    },
    generalButton: {
        color: COLORSCHEME[0]==="dark" ? '#696969' : '#FAFAFA',
    },
    generalText: {
        color: COLORSCHEME[0]==="dark" ? '#696969' : 'black',
    },
    scrollview: {
        flex: 2,
        alignItems:"center",
        marginHorizontal: 0,
        //paddingBottom: bottomNavigatorBarHeight
    },
    centerPage: {
        justifyContent: "center",
        alignItems:"center"
    },
    centerPageMargin: {
        justifyContent: "center",
        alignItems:"center",
        marginTop: 40,
        
    },
    tinyLogo:{
        width: screen.width*.6,
        height: screen.height*.25,
        marginTop: 10,
        alignItems: "center",
        marginTop: "25%",
    },
    cardStyleWelcome: {
        backgroundColor: "grey",
    },
    buttonStyle: {
        width: "100%",
        height: "100%",
        minWidth: screen.width*.4,
        minHeight: screen.height*.18,
        maxWidth: screen.width*.45,
        maxHeight: screen.height*.25,
        textAlign: "center",
        backgroundColor: COLORSCHEME[0]==="dark" ? '#332940' : '#6200ed',
        //backgroundColor: "#7F46C7",
        borderRadius: 20,
        borderWidth: 1,
        borderColor: COLORSCHEME[0]==="dark" ? '#696969' : 'white',
        elevation: 10,
        justifyContent: "center",
        
    },
    textStyle: {
        
        //color: "#6200ed",
        color: COLORSCHEME[0]==="dark" ? '#a1a1a1' : 'white',
        justifyContent: "center",
        alignItems:"center",
        textAlign: "center",
        fontWeight: '500',
        fontSize: 14,
        fontFamily: "System",
        textTransform: "uppercase",
        letterSpacing: 1,
        marginVertical: 9,
        marginHorizontal: 16,
    },
    modalText: {
        color: "white",
        justifyContent: "flex-start",
        alignItems:"flex-start",
        textAlign: "center",
        fontWeight: '500',
        fontSize: 12,
        fontFamily: "System",
        textTransform: "uppercase",
        marginHorizontal: 10,
    },
    modalStyle: {
        
        shadowOpacity: 0.25,
        shadowRadius: 4,
        elevation: 5,
        margin: 0,
        
        alignItems:"center",
        textAlign: "center",
        backgroundColor: 'rgba(52, 52, 52, 0.25)',
    
    },
    
    viewStyle: {
        flex:-1,
        flexDirection:"row",
        marginTop: 10,
    },
    cardStyle: {
    backgroundColor: "powderblue",
    margin: 10,
    },
    label: {
    color: "black",
    },
    title: {
    margin: 8,
    color: "#20232a",
    textAlign: "center",
    fontSize: 20,
    fontWeight: "600",
    flexWrap: "wrap",
    },
    buttonStyleT:{
        backgroundColor :"silver"
    },
    scheduleHeight: {
        height: screen.height * .82
    }
});;





How do you collect the use of “hr” as a value and display it on a main page?

I am new to HTML and JavaScript and am trying to make a counter that finds the use of “hr” in HTML code over multiple pages. The separate pages are in a folder while the main file and the JavaScript file and not. This is what I have written so far in the main page, JavaScript file, and individual pages respectively.

<h3 id="total_id">Total: </h3>

<script src="counter.js"></script>
let total = document.querySelectorAll('hr').length

total_id.innerText = "Total: " + total
<script src=../counter.js></script>

If any help at all could be provided, that would be amazing!