Military-Tactical-Graphics / milgraphics

Military Tactical Graphics
MIT License
5 stars 4 forks source link

Create a javascript dropdown to switch between JSON files in folder #14

Open Plavit opened 3 years ago

Plavit commented 3 years ago

This would allow for easy flipping between multiple files to test/showcase without the need to change the code

Plavit commented 3 years ago

Should probably be done in plain javascript

Plavit commented 3 years ago

fe5182b has init of dropdown button and selector

TODO:

Plavit commented 3 years ago

I disagree with @mariobgr. If there is no server setting preventing a directory listing, then the html generated by requesting that directory can be parsed for the contents.

$ tree maindir
maindir
├── index.html
└── somedir
    ├── doc1
    ├── doc2
    └── doc3

index.html


<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"><!--  JQUERY  -->

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
  </script>
  <title></title>
</head>
<body>
  <h1>Listing /somedir</h1><!-- Custom Script (defered load, after dom ready) -->
  <script>
    $.getJSON('./somedir', data => {
        console.log(data); //["doc1.jpg", "doc2.jpg", "doc3.jpg"] 
    });
  </script>
</body>

src: https://stackoverflow.com/questions/30622369/easiest-way-to-get-list-of-files-in-the-server-directory

Plavit commented 3 years ago

OpenLayers maps are extremely tricky to pass information to. Not sure if there is much value in throwing more manhours at this...

Plavit commented 3 years ago

Quick Czech rant about how I understand a potential functional solution to work:

Dropdowny v React DOMu musíš jednotlivě konvertovat na tlačítka, jelikož OpenLayer mapa je nezná a registrovat je speciálně jako "control" prvek pro OL mapu, načíst všechny nákresy najednou, a teprve pak podle zvolenýho tlačítka měnit styly nezvolených prvků tak, aby byly neviditelný, když nejsou zvolený...