Altes Köln

Widget:GOV-Test: Unterschied zwischen den Versionen

Aus Altes Köln
Wechseln zu:Navigation, Suche
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(32 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<!--Test-Widget von Christopher zum Austesten des GOV-Aufrufes (eigentlich für das GenWiki)-->
<!--Test-Widget von Christopher zum Austesten des GOV-Aufrufes (eigentlich für das GenWiki)-->
<div id="widget-container"></div>


<h1>Variante: Einfacher iframe mit <!--{$CallType|escape:'url'}--></h1>
<div style="width: 100vw; height: 0; padding-bottom: 160%; position: relative;">
  <iframe src="https://gov.genealogy.net/item/<!--{$CallType|escape:'url'}-->/<!--{$GOVID|escape:'url'}-->" style="position: absolute; top: 0; left: 0; width: vw; height: 100%; transform: scale(1.8); /* Skaliere den iframe-Inhalt */" frameborder="0" allowfullscreen></iframe>
</div>
<h1>Variante: responsiv mit <!--{$CallType|escape:'url'}--></h1>
<style>
    body {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
    }
    .iframe-container {
      width: 100%; /* Container hat immer die volle Breite des Viewports */
      position: relative; /* Wichtig für absolute Positionierung */
      padding-top: 56.25%; /* Seitenverhältnis 16:9 */
 
    }
    iframe {
      position: absolute;
      top: 0;
      left: 0;
      width: 100vw; /* Breite des Viewports */
      height: calc(100vw * 0.5625); /* Höhe proportional zur Breite (16:9) */
      transform-origin: top left; /* Skalierung startet oben links */
    }
    /* Media Queries für kleinere Bildschirme */
    @media (max-width: 768px) {
      iframe {
        transform: scale(0.9); /* Skaliere den iframe-Inhalt */
      }
    }
    @media (max-width: 480px) {
      iframe {
        transform: scale(0.8); /* Weitere Skalierung für kleine Geräte */
      }
    }
  </style>
<div class="iframe-container">
  <iframe src="https://gov.genealogy.net/item/<!--{$CallType|escape:'url'}-->/<!--{$GOVID|escape:'url'}-->" allowfullscreen></iframe>
</div>
<!--
<h1>Aufruf von NVK relativ mit Iframe</h1>
<iframe src="https://nvk.genealogy.net/karte/Schmitz" width="600" height="600"></iframe>
-->
<!--
<h1>Laden der GOV-Seite mit Javascript (fetch)</h1>
<div id="gov-content"></div>
<script>
<script>
  fetch('https://gov.genealogy.net/item/show/HOHAUSJO30MX')
    (function () {
    .then(response => response.text())
        const fetchURL = "https://gov.genealogy.net/item/wikihtml/<!--{$GOVID|escape:'url'}-->";
    .then(data => {
        const baseURL = "https://gov.genealogy.net";
      document.getElementById('gov-content').innerHTML = data;
    })
    .catch(error => {
      console.error('Error loading GOV content:', error);
    });
</script>


<h1>Laden der Übersichtskarte mit Javascript (fetch)</h1>
        fetch(fetchURL)
<div id="map-content"></div>
            .then(response => {
<script>
                if (!response.ok) {
  const mapUrl = 'https://gov.genealogy.net/item/map/HOHAUSJO30MX';
                    throw new Error(`HTTP-Fehler! Status: ${response.status}`);
                }
                return response.text();
            })
            .then(html => {
                const widgetContainer = document.getElementById('widget-container');


  fetch(mapUrl)
                // Shadow DOM erstellen
    .then(response => {
                const shadow = widgetContainer.attachShadow({ mode: 'open' });
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      return response.blob();
    })
    .then(blob => {
      const mapObjectUrl = URL.createObjectURL(blob);


      const imgElement = document.createElement('img');
                // Stile für das Widget im Shadow DOM hinzufügen
      imgElement.src = mapObjectUrl;
                const style = document.createElement('style');
      imgElement.alt = 'Karte';
                style.textContent = `
      imgElement.style.maxWidth = '100%';
                    :host {
      imgElement.style.height = 'auto';
                        all: initial;
                        display: block;
                        max-width: 1200px;
                        margin: 20px auto;
                        padding: 0;
                        border: none;
                        background-color: #fff;
                        overflow: auto;
                        font-family: Arial, sans-serif;
                        font-size: 16px;
                    }
                    table {
                        width: 100%;
                        table-layout: auto;
                        border-collapse: collapse;
                        margin: 10px 0;
                        border: 1px solid #ccc;
                    }
                    th, td {
                        border: 1px solid #ddd;
                        padding: 10px;
                        text-align: left;
                        word-wrap: break-word;
                    }
                    th {
                        background-color: #f2f2f2;
                    }
                    td:first-child {
                        width: 1%;
                        white-space: nowrap;
                    }
                    ul {
                        padding-left: 20px;
                        margin: 10px 0;
                    }
                    object {
                        max-width: 100%;
                        height: 400px; /* Feste Höhe */
                        display: block;
                        margin: 0;
                    }
                    .map-container {
                        text-align: left;
                    }
                    a {
                        color: #007BFF;
                        text-decoration: none;
                    }
                    a:hover {
                        text-decoration: underline;
                    }
                `;


      document.getElementById('map-content').appendChild(imgElement);
                // Geladenen HTML-Inhalt einfügen
    })
                const content = document.createElement('div');
    .catch(error => {
                content.innerHTML = html;
      console.error('Error loading map:', error);
    });
</script>


<h1>Laden der Grafik mit übergeordneten Objekten mit Javascript (fetch)</h1>
                // 1) Passe width und height in <object> an
<div id="relationship-graph-content"></div>
                const objects = content.querySelectorAll('object[data^="https://www.genealogy.net/viewer-js/"]');
<script>
                objects.forEach(obj => {
  const relationshipGraphUrl = 'https://gov.genealogy.net/item/relationshipGraph/HOHAUSJO30MX?full-size=1';
                    obj.setAttribute('width', '400'); // Setze Breite auf 400
                    obj.setAttribute('height', '400'); // Setze Höhe auf 400
                });


  fetch(relationshipGraphUrl)
                // 2) Passe <a> und <img> für den relationshipGraph an
    .then(response => {
                const imageLinks = content.querySelectorAll('a[href*="relationshipGraph"]');
      if (!response.ok) {
                imageLinks.forEach(link => {
        throw new Error(`HTTP error! status: ${response.status}`);
                    // Passe das <a>-Tag an die Base-URL an
      }
                    const originalHref = link.getAttribute('href');
      return response.blob();
                    link.setAttribute('href', baseURL + originalHref);
    })
    .then(blob => {
      const graphObjectUrl = URL.createObjectURL(blob);


      const imgElement = document.createElement('img');
                    // Passe das <img>-Tag im <a>-Tag an
      imgElement.src = graphObjectUrl;
                    const img = link.querySelector('img');
      imgElement.alt = 'Beziehungsgraph';
                    if (img) {
      imgElement.style.maxWidth = '100%';
                        const originalSrc = img.getAttribute('src');
      imgElement.style.height = 'auto';
                        img.setAttribute('src', baseURL + originalSrc + "?full-size=1"); // Absoluten Pfad setzen
                        img.setAttribute('width', '80%'); // Breite auf 80% setzen
                    }
                });


      document.getElementById('relationship-graph-content').appendChild(imgElement);
                // 3) Füge Base-URL zu allen relativen <a> hinzu
    })
                const allLinks = content.querySelectorAll('a[href^="/"]');
    .catch(error => {
                allLinks.forEach(link => {
      console.error('Error loading relationship graph:', error);
                    const originalHref = link.getAttribute('href');
    });
                    link.setAttribute('href', baseURL + originalHref);
</script>
                });


<h1>Leaflet-Karte</h1>
                // 4) Füge Base-URL zu allen relativen <img> hinzu
<div id="leaflet-map" style="width: 100%; height: 400px;"></div>
                const allImages = content.querySelectorAll('img[src^="/"]');
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
                allImages.forEach(img => {
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
                    const originalSrc = img.getAttribute('src');
<script>
                    img.setAttribute('src', baseURL + originalSrc);
  // Initialisierung der Leaflet-Karte
                });
  var map = L.map('leaflet-map').setView([50.9812, 7.0326], 12);


  // OpenStreetMap-Tiles hinzufügen
                // Stile und Inhalte in das Shadow DOM einfügen
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                shadow.appendChild(style);
    attribution: '© OpenStreetMap contributors',
                shadow.appendChild(content);
    maxZoom: 18
            })
  }).addTo(map);
            .catch(error => {
 
                console.error('Fehler beim Laden:', error);
  // Optional: Marker hinzufügen
                const widgetContainer = document.getElementById('widget-container');
  L.marker([50.9812, 7.0326]).addTo(map)
                widgetContainer.textContent = "Fehler: Inhalte konnten nicht geladen werden.";
    .bindPopup('GOV-Standort<br>50.9812, 7.0326.')
            });
     .openPopup();
     })();
</script>
</script>
<h1>Einfaches HTML (nur Hyberlink auf GOV)</h1>
<p>Hello <b>World</b></p>
<p>Die GOV-Daten <a href="https://gov.genealogy.net/item/show/HOHAUSJO30MX">finden Sie hier</a>.</p>
<h1>Aufruf von GOV mit Object</h1>
<object data="https://gov.genealogy.net/item/show/HOHAUSJO30MX" width="600" height="400"></object>
-->

Aktuelle Version vom 22. Januar 2025, 18:18 Uhr

<script>

   (function () {
       const fetchURL = "https://gov.genealogy.net/item/wikihtml/";
       const baseURL = "https://gov.genealogy.net";
       fetch(fetchURL)
           .then(response => {
               if (!response.ok) {
                   throw new Error(`HTTP-Fehler! Status: ${response.status}`);
               }
               return response.text();
           })
           .then(html => {
               const widgetContainer = document.getElementById('widget-container');
               // Shadow DOM erstellen
               const shadow = widgetContainer.attachShadow({ mode: 'open' });
               // Stile für das Widget im Shadow DOM hinzufügen
               const style = document.createElement('style');
               style.textContent = `
                   :host {
                       all: initial;
                       display: block;
                       max-width: 1200px;
                       margin: 20px auto;
                       padding: 0;
                       border: none;
                       background-color: #fff;
                       overflow: auto;
                       font-family: Arial, sans-serif;
                       font-size: 16px;
                   }
                   table {
                       width: 100%;
                       table-layout: auto;
                       border-collapse: collapse;
                       margin: 10px 0;
                       border: 1px solid #ccc;
                   }
                   th, td {
                       border: 1px solid #ddd;
                       padding: 10px;
                       text-align: left;
                       word-wrap: break-word;
                   }
                   th {
                       background-color: #f2f2f2;
                   }
                   td:first-child {
                       width: 1%;
                       white-space: nowrap;
                   }
                   ul {
                       padding-left: 20px;
                       margin: 10px 0;
                   }
                   object {
                       max-width: 100%;
                       height: 400px; /* Feste Höhe */
                       display: block;
                       margin: 0;
                   }
                   .map-container {
                       text-align: left;
                   }
                   a {
                       color: #007BFF;
                       text-decoration: none;
                   }
                   a:hover {
                       text-decoration: underline;
                   }
               `;
               // Geladenen HTML-Inhalt einfügen
               const content = document.createElement('div');
               content.innerHTML = html;
               // 1) Passe width und height in <object> an
               const objects = content.querySelectorAll('object[data^="https://www.genealogy.net/viewer-js/"]');
               objects.forEach(obj => {
                   obj.setAttribute('width', '400'); // Setze Breite auf 400
                   obj.setAttribute('height', '400'); // Setze Höhe auf 400
               });
               // 2) Passe <a> und <img> für den relationshipGraph an
               const imageLinks = content.querySelectorAll('a[href*="relationshipGraph"]');
               imageLinks.forEach(link => {
                   // Passe das <a>-Tag an die Base-URL an
                   const originalHref = link.getAttribute('href');
                   link.setAttribute('href', baseURL + originalHref);
                   // Passe das <img>-Tag im <a>-Tag an
                   const img = link.querySelector('img');
                   if (img) {
                       const originalSrc = img.getAttribute('src');
                       img.setAttribute('src', baseURL + originalSrc + "?full-size=1"); // Absoluten Pfad setzen
                       img.setAttribute('width', '80%'); // Breite auf 80% setzen
                   }
               });
               // 3) Füge Base-URL zu allen relativen <a> hinzu
               const allLinks = content.querySelectorAll('a[href^="/"]');
               allLinks.forEach(link => {
                   const originalHref = link.getAttribute('href');
                   link.setAttribute('href', baseURL + originalHref);
               });
               // 4) Füge Base-URL zu allen relativen <img> hinzu
               const allImages = content.querySelectorAll('img[src^="/"]');
               allImages.forEach(img => {
                   const originalSrc = img.getAttribute('src');
                   img.setAttribute('src', baseURL + originalSrc);
               });
               // Stile und Inhalte in das Shadow DOM einfügen
               shadow.appendChild(style);
               shadow.appendChild(content);
           })
           .catch(error => {
               console.error('Fehler beim Laden:', error);
               const widgetContainer = document.getElementById('widget-container');
               widgetContainer.textContent = "Fehler: Inhalte konnten nicht geladen werden.";
           });
   })();

</script>

Cookies helfen uns bei der Bereitstellung von Altes Köln. Durch die Nutzung von Altes Köln erklärst du dich damit einverstanden, dass wir Cookies speichern.