function addOrUpdateUrlParameter(url, key, value) { var urlObject = new URL(url); urlObject.searchParams.set(key, value); return urlObject.href; } function getUrlParameters() { var searchParams = new URLSearchParams(window.location.search); var params = {}; // Iterate over each parameter and add to the 'params' object searchParams.forEach(function(value, key) { params[key] = value; }); return params; } $(document).ready(function() { var params = getUrlParameters(); // Make table rows clickable $(".visualization-table").hide(); $(".table-wrapper tbody tr").click(function() { $(".visualization-table").show(); var grew_url = $(this).data("href"); var example_id = $(this).data("exid"); var example_positions = $(this).data("expositions"); var dir_name = window.location.pathname.split("/").pop() var url = window.location.origin + '/stark/visualization/' + dir_name + '/' + example_id + '/' + example_positions $.ajax({url: url, success: function(result){ var escapedHtml = `
${result['annodoc']}
`; $(".visualization").html(escapedHtml); $('.visualization .conllu').each(function() { Annodoc.embedAnnotation($(this), Annodoc.parseConllU, Config.bratCollData); }); }}); if (grew_url == 'unknown') { $(".grew-link").html("/"); } else { $(".grew-link").html("GREW link"); } }); $(".th-desc").hide(); $(".th-asc").hide(); if ('order_by' in params) { if ('order_type' in params && params.order_type == 'desc') { $('th:contains(' + params.order_by + ') .th-desc').show(); } else { $('th:contains(' + params.order_by + ') .th-asc').show(); } } // Make table rows clickable $(".table-wrapper thead th").click(function(e) { var column_name = $(this).find('span:first').text(); var newUrl = addOrUpdateUrlParameter(window.location.href, 'order_by', column_name); if ('order_by' in params && 'order_type' in params && params.order_by == column_name && params.order_type == 'desc') { newUrl = addOrUpdateUrlParameter(newUrl, 'order_type', 'asc'); } else { newUrl = addOrUpdateUrlParameter(newUrl, 'order_type', 'desc'); } // Redirect to the modified URL window.location.href = newUrl; }); });