Altes Köln

Widget:GOV-Test: Unterschied zwischen den Versionen

Aus Altes Köln
Wechseln zu:Navigation, Suche
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(27 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)-->
<h1>Ajax-Variante mit wiki</h1>
<div id="widget-container"></div>
<div id="content"></div>


<script>
<script>
     const serverBaseURL = "https://gov.genealogy.net";
     (function () {
    fetch('https://gov.genealogy.net/item/wikihtml/SCHERGJO54EJ')
        const fetchURL = "https://gov.genealogy.net/item/wikihtml/<!--{$GOVID|escape:'url'}-->";
        .then(response => response.text())
         const baseURL = "https://gov.genealogy.net";
         .then(html => {
            const tempDiv = document.createElement('div');
            tempDiv.innerHTML = html;


            // Anpassung relativer URLs
        fetch(fetchURL)
            const links = tempDiv.querySelectorAll('a[href^="/"]');
             .then(response => {
             links.forEach(link => {
                 if (!response.ok) {
                 link.href = serverBaseURL + link.getAttribute('href');
                    throw new Error(`HTTP-Fehler! Status: ${response.status}`);
            });
                }
            const images = tempDiv.querySelectorAll('img[src^="/"]');
                 return response.text();
            images.forEach(img => {
             })
                 img.src = serverBaseURL + img.getAttribute('src');
             .then(html => {
             });
                 const widgetContainer = document.getElementById('widget-container');
 
             // Grafik ersetzen und Zoom-Wrapper hinzufügen
            const zoomImage = tempDiv.querySelector('td a[href*="relationshipGraph"] img');
            if (zoomImage) {
                 const wrapper = document.createElement('div');
                wrapper.className = 'zoomable';
                zoomImage.parentElement.replaceWith(wrapper);
                wrapper.appendChild(zoomImage);


                 // Initiales Zoom-Level setzen
                 // Shadow DOM erstellen
                 zoomImage.dataset.scale = 1;
                 const shadow = widgetContainer.attachShadow({ mode: 'open' });
            }


            document.getElementById('content').innerHTML = tempDiv.innerHTML;
                // Stile für das Widget im Shadow DOM hinzufügen
        })
                const style = document.createElement('style');
        .catch(error => console.error('Error loading content:', error));
                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;
                    }
                `;


    // Zoom mit STRG + Mausrad
                // Geladenen HTML-Inhalt einfügen
    document.addEventListener('wheel', (event) => {
                const content = document.createElement('div');
        if (event.ctrlKey) {
                 content.innerHTML = html;
            const zoomable = document.querySelector('.zoomable img:hover');
            if (zoomable) {
                 const scale = parseFloat(zoomable.dataset.scale || 1);
                const newScale = event.deltaY < 0 ? scale * 1.1 : scale / 1.1;
                zoomable.style.transform = `scale(${newScale})`;
                zoomable.dataset.scale = newScale;
                event.preventDefault(); // Standardverhalten verhindern
            }
        }
    });
</script>


<style>
                // 1) Passe width und height in <object> an
    /* Zoomable Styles */
                const objects = content.querySelectorAll('object[data^="https://www.genealogy.net/viewer-js/"]');
    .zoomable {
                objects.forEach(obj => {
        position: relative;
                    obj.setAttribute('width', '400'); // Setze Breite auf 400
        display: inline-block;
                    obj.setAttribute('height', '400'); // Setze Höhe auf 400
        overflow: hidden;
                });
        max-width: 100%;
        cursor: grab;
    }


    .zoomable img {
                // 2) Passe <a> und <img> für den relationshipGraph an
        transition: transform 0.3s ease;
                const imageLinks = content.querySelectorAll('a[href*="relationshipGraph"]');
        width: 100%;
                imageLinks.forEach(link => {
        height: auto;
                    // Passe das <a>-Tag an die Base-URL an
    }
                    const originalHref = link.getAttribute('href');
                    link.setAttribute('href', baseURL + originalHref);


    .zoomable img:hover {
                    // Passe das <img>-Tag im <a>-Tag an
        cursor: zoom-in;
                    const img = link.querySelector('img');
    }
                    if (img) {
</style>
                        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);
                });


<h1>Variante: Einfacher iframe mit <!--{$CallType|escape:'url'}--></h1>
                // 4) Füge Base-URL zu allen relativen <img> hinzu
<div style="width: 100vw; height: 0; padding-bottom: 160%; position: relative;">
                const allImages = content.querySelectorAll('img[src^="/"]');
  <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>
                allImages.forEach(img => {
</div>
                    const originalSrc = img.getAttribute('src');
                    img.setAttribute('src', baseURL + originalSrc);
                });


<h1>Variante: responsiv mit <!--{$CallType|escape:'url'}--></h1>
                // Stile und Inhalte in das Shadow DOM einfügen
 
                shadow.appendChild(style);
<style>
                shadow.appendChild(content);
    body {
            })
      margin: 0;
            .catch(error => {
      padding: 0;
                console.error('Fehler beim Laden:', error);
      font-family: Arial, sans-serif;
                const widgetContainer = document.getElementById('widget-container');
    }
                widgetContainer.textContent = "Fehler: Inhalte konnten nicht geladen werden.";
 
            });
    .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>
  fetch('https://gov.genealogy.net/item/show/HOHAUSJO30MX')
    .then(response => response.text())
    .then(data => {
      document.getElementById('gov-content').innerHTML = data;
    })
    .catch(error => {
      console.error('Error loading GOV content:', error);
     });
</script>
</script>
<h1>Laden der Übersichtskarte mit Javascript (fetch)</h1>
<div id="map-content"></div>
<script>
  const mapUrl = 'https://gov.genealogy.net/item/map/HOHAUSJO30MX';
  fetch(mapUrl)
    .then(response => {
      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');
      imgElement.src = mapObjectUrl;
      imgElement.alt = 'Karte';
      imgElement.style.maxWidth = '100%';
      imgElement.style.height = 'auto';
      document.getElementById('map-content').appendChild(imgElement);
    })
    .catch(error => {
      console.error('Error loading map:', error);
    });
</script>
<h1>Laden der Grafik mit übergeordneten Objekten mit Javascript (fetch)</h1>
<div id="relationship-graph-content"></div>
<script>
  const relationshipGraphUrl = 'https://gov.genealogy.net/item/relationshipGraph/HOHAUSJO30MX?full-size=1';
  fetch(relationshipGraphUrl)
    .then(response => {
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      return response.blob();
    })
    .then(blob => {
      const graphObjectUrl = URL.createObjectURL(blob);
      const imgElement = document.createElement('img');
      imgElement.src = graphObjectUrl;
      imgElement.alt = 'Beziehungsgraph';
      imgElement.style.maxWidth = '100%';
      imgElement.style.height = 'auto';
      document.getElementById('relationship-graph-content').appendChild(imgElement);
    })
    .catch(error => {
      console.error('Error loading relationship graph:', error);
    });
</script>
<h1>Leaflet-Karte</h1>
<div id="leaflet-map" style="width: 100%; height: 400px;"></div>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script>
  // Initialisierung der Leaflet-Karte
  var map = L.map('leaflet-map').setView([50.9812, 7.0326], 12);
  // OpenStreetMap-Tiles hinzufügen
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '© OpenStreetMap contributors',
    maxZoom: 18
  }).addTo(map);
  // Optional: Marker hinzufügen
  L.marker([50.9812, 7.0326]).addTo(map)
    .bindPopup('GOV-Standort<br>50.9812, 7.0326.')
    .openPopup();
</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.