PageSourceSearch

https://kristofkiekens.be/web/assets/js/contact-gegevens.js

js kristofkiekens.be collected 2026-10-10 02:42:14 UTC 3,239 bytes, 75 lines download raw bytes

1// Contactgegevens uit het CMS
2//
3// Adres, telefoon, e-mail en ondernemingsnummer staan in de HTML als terugval.
4// Dit script vervangt ze door wat in het CMS bewaard is, op elk element met
5// data-contact="adres|telefoon|email|ondernemingsnummer", en werkt ook de
6// schema.org-gegevens bij.
7
8(function () {
9    var isLocal = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
10    var isRailway = window.location.hostname.includes('kristofkiekens.be') || window.location.hostname.includes('railway.app');
11    var API_BASE = isLocal
12        ? 'http://localhost:3000/api'
13        : isRailway
14            ? '/api'
15            : 'https://gordijn-studio-by-kristof-kiekens-production.up.railway.app/api';
16
17    // 0473 62 53 13 -> +32473625313
18    function telLink(nummer) {
19        var cijfers = nummer.replace(/[^\d+]/g, '');
20        if (cijfers.indexOf('00') === 0) return '+' + cijfers.slice(2);
21        if (cijfers.charAt(0) === '0') return '+32' + cijfers.slice(1);
22        return cijfers;
23    }
24
25    function vulIn(contact) {
26        var adres = '';
27        if (contact.straat && contact.postcode && contact.gemeente) {
28            adres = contact.straat + ', ' + contact.postcode + ' ' + contact.gemeente;
29        }
30        var waarden = {
31            adres: adres,
32            telefoon: contact.telefoon || '',
33            email: contact.email || '',
34            ondernemingsnummer: contact.ondernemingsnummer || ''
35        };
36
37        document.querySelectorAll('[data-contact]').forEach(function (el) {
38            var waarde = waarden[el.getAttribute('data-contact')];
39            if (!waarde) return;
40            el.textContent = waarde;
41            if (el.tagName === 'A' && el.getAttribute('data-contact') === 'telefoon') el.href = 'tel:' + telLink(waarde);
42            if (el.tagName === 'A' && el.getAttribute('data-contact') === 'email') el.href = 'mailto:' + waarde;
43        });
44
45        var ld = document.querySelector('script[type="application/ld+json"]');
46        if (!ld) return;
47        try {
48            var data = JSON.parse(ld.textContent);
49            if (waarden.telefoon) data.telephone = telLink(waarden.telefoon);
50            if (waarden.email) data.email = waarden.email;
51            if (adres && data.address) {
52                data.address.streetAddress = contact.straat;
53                data.address.postalCode = contact.postcode;
54                data.address.addressLocality = contact.gemeente;
55                if (contact.geo && contact.geo.lat && contact.geo.lon) {
56                    data.geo = { '@type': 'GeoCoordinates', latitude: contact.geo.lat, longitude: contact.geo.lon };
57                } else {
58                    delete data.geo;
59                }
60            }
61            ld.textContent = JSON.stringify(data, null, 2);
62        } catch (err) {
63            console.error('Schema.org bijwerken mislukt:', err);
64        }
65    }
66
67    fetch(API_BASE + '/settings')
68        .then(function (r) { return r.json(); })
69        .then(function (res) {
70            if (res.success && res.data && res.data.contact) vulIn(res.data.contact);
71        })
72        .catch(function (err) {
73            console.error('Contactgegevens laden mislukt:', err);
74        });
75})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.