$(document).ready(function() { //---------------------------------------------------- //MATOMO var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="https://japetus.narc.fi/piwik/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '83']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); //---------------------------------------------------- $.i18n().load({ "fi": "i18n/languages/fi.json", "sv": "i18n/languages/sv.json", }).done(function() { update_text(); }); var lang = false; if (localStorage.getItem('lang') == 'sv') { lang = true; } //let table = new DataTable('#searchResults'); $('#searchResults').DataTable({ dom: 'Blfrtip', responsive: true, order: [[1, 'asc']], lengthManu: [10, 25, 50, 75, 100], language: { url: lang ? 'sv.json' : 'fi.json' /* aria: { paginate: { first: $.i18n('ensimmainen'), last: 'Viimeinen', previous: 'Edellinen', next: 'Seuraava' } }*/ }, buttons: [ { extend: 'csv', //text: $.i18n('haku16'), text: 'CSV', className: 'csvButton sininen piilossa_tulosteesta' }, { extend: 'excel', //text: $.i18n('haku16b'), text: 'Excel', className: 'excelButton sininen piilossa_tulosteesta pl-4' } ], initComplete: function (settings, json) { //$("div.dt-buttons .csvButton").removeClass("btn-secondary").attr("data-i18n", "haku16"); //$("div.dt-buttons .excelButton").removeClass("btn-secondary").attr("data-i18n", "haku16b"); $("div.dt-buttons .csvButton").removeClass("btn-secondary"); $("div.dt-buttons .excelButton").removeClass("btn-secondary"); } }); update_text(); $(document).on('click', '#lang', function() { if ($('#kieli').html() == "På svenska") { $('#kieli').html($.i18n('navbar3')); localStorage.setItem("lang", "sv"); //update_text(); window.location.reload(); } else { $('#kieli').html($.i18n('navbar2')); localStorage.setItem("lang", "fi"); //update_text(); window.location.reload(); } }); $(document).on("click", ".facetBtn", function() { window.location.href = window.location.href + "&" + $(this).data("key") + "=" + encodeURIComponent($(this).data("value")) + "&" + $(this).data("key") + "_tarkka=on"; }); $(document).on("click", ".aikarajausButton", function() { var id = $(this).attr('id'); if (id == 'aikarajaus_syntymavuosi') { var startdate = $('#startDate_syntymavuosi').val(); var enddate = $('#endDate_syntymavuosi').val(); if (startdate != null && startdate != '' && startdate != 0 && enddate != null && enddate != '' && enddate != 0) { window.location.href = window.location.href + "&syntymavuosi_start=" + encodeURIComponent(startdate) + "&syntymavuosi_end=" + encodeURIComponent(enddate); } } else { var startdate = $('#startDate_rajanylitys_vuosi').val(); var enddate = $('#endDate_rajanylitys_vuosi').val(); if (startdate != null && startdate != '' && startdate != 0 && enddate != null && enddate != '' && enddate != 0) { window.location.href = window.location.href + "&rajanylitys_vuosi_start=" + encodeURIComponent(startdate) + "&rajanylitys_vuosi_end=" + encodeURIComponent(enddate); } } }); $(document).on("click", ".person", function() { window.open($(this).data('url'), '_blank').focus(); }); $(document).on('click', '#tarkennettuHaku', function() { window.location.href = "haku.php?adv=true"; }); $(document).on('click', '#perusHaku', function() { window.location.href = "haku.php"; }); $(document).on('click', '#tyhjenna', function() { window.location.href = "haku.php"; }); $(document).on('click', '#kartalle', function() { var data = $(this).data('list'); //window.location.href = 'kartta.php?henkiloId=' + JSON.stringify(data); window.open('kartta.php?henkiloId=' + JSON.stringify(data), '_blank').focus(); }); $(document).on('click', '#hakutuloksiin', function() { if (document.referrer.indexOf('suomven.kansallisarkisto.fi/haku.php') >= 0) { history.go(-1); } else { window.location.href = "haku.php"; } }); $(document).on('click', '#addRow', function() { var options = { 'sukunimi': 'Sukunimi', 'etunimi': 'Etunimi', 'syntymaaika': 'Syntymäaika', 'syntymamaa': 'Syntymämaa', 'syntymakunta': 'Syntymäkunta', 'kirjoillaolokunta_suomessa': 'Kirjoillaolokunta Suomessa', 'rajanylitys_aika': 'Rajanylitysvuosi', 'rajanylitys_suunta': 'Rajanylityssuunta', 'rajanylitys_tapa': 'Rajanylitystapa', 'kirjoillaoloalue': 'Kirjoillaoloalue (Venäjällä)', 'kirjoillaolokunta': 'Kirjoillaolokunta (Venäjällä)', 'tuomio': 'Tuomio', 'kuolinaika': 'Kuolinaika', 'kuolinalue': 'Kuolinalue', 'kuolinkunta': 'Kuolinkunta', 'kuolintapa': 'Kuolintapa', 'vankeusalue': 'Vankeusalue (Venäjällä)', 'vankeuskunta': 'Vankeuskunta (Venäjällä)', } var html = ''; html += '
'; html += '
'; html += '
'; html += ''; html += ''; html += '
'; html += '
'; html += '
'; html += '
'; html += ''; html += ''; html += '
'; html += '
'; html += '
'; html += '
'; html += ''; html += ''; html += '
'; html += '
'; html += '
'; html += ''; html += '
'; html += '
'; $('#extraFields').append(html); }); $(document).on('click', '.poistaRivi', function() { var id = $(this).attr('id').replace('poistaRivi_', ''); $('#field_' + id).remove(); }); $(document).on('change', '.advSearchSelect', function() { //var id = $(this).attr('id').slice(-1); var id = $(this).attr('id').split("searchTarget")[1]; $('#searchValue' + id).attr('name', $(this).val()); $('#asteriskCheck' + id).attr('name', $(this).val() + '_tarkka'); }); $(document).on('click', '.hakuparametri', function() { var key = $(this).data('key'); var params = new URLSearchParams(window.location.search); params.delete(key); params.delete(key + "_tarkka"); window.location.href = 'https://kohtalonaneuvostoliitto.kansallisarkisto.fi/haku.php?' + params.toString(); }); }); function update_text() { var lang = localStorage.getItem("lang"); if (lang === null) { lang = "fi"; localStorage.setItem("lang", "fi"); } else if (localStorage.getItem("lang") == "sv") { lang = "sv"; } else { lang = "fi"; } // Päivitetään kielitieto $("html").attr("lang", lang); $.i18n().locale = lang; // Päivitetään tekstisisällöt $("html").i18n(); // Ilmoitetaan kielivalinnasta konsoliin // console.log("Vaihdettu kieleksi " + lang); }