2024-01-22 13:56:12 +00:00
|
|
|
// Global array to store input names
|
2024-07-04 11:39:46 +00:00
|
|
|
var globalInputList = ['display_size', 'file', 'association_measures', 'labeled_trees', 'node_type_upos', 'fixed_order', 'input_url', 'node_type_lemma', 'root_restriction', 'node_type_form', 'frequency_threshold', 'node_type_none', 'query', 'compare_url', 'compare_file', 'ignored_labels'];
|
2024-02-21 10:10:31 +00:00
|
|
|
|
2024-01-22 13:56:12 +00:00
|
|
|
// Function to store values to local storage
|
|
|
|
function storeValuesToLocalstorage() {
|
|
|
|
globalInputList.forEach(function(inputName) {
|
|
|
|
var inputElement = $('[name="' + inputName + '"]');
|
|
|
|
|
|
|
|
if (inputElement.length > 0) {
|
|
|
|
var inputType = inputElement.attr('type');
|
|
|
|
if (inputType === 'text' | inputType === 'hidden') {
|
|
|
|
localStorage.setItem(inputName, inputElement.val());
|
|
|
|
} else if (inputType === 'checkbox') {
|
|
|
|
localStorage.setItem(inputName, inputElement.prop('checked'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function to read values from local storage
|
|
|
|
function readValuesFromLocalstorage() {
|
|
|
|
globalInputList.forEach(function(inputName) {
|
|
|
|
var inputElement = $('[name="' + inputName + '"]');
|
|
|
|
|
|
|
|
if (inputElement.length > 0) {
|
|
|
|
var inputType = inputElement.attr('type');
|
|
|
|
if (inputType === 'text') {
|
|
|
|
var text_val = localStorage.getItem(inputName);
|
|
|
|
if (text_val !== '' & text_val !== null) {
|
|
|
|
// set label to active
|
|
|
|
$("label[for='" + inputElement.attr('id') + "']").addClass('active');
|
|
|
|
}
|
2024-02-13 14:19:22 +00:00
|
|
|
if (inputName === 'frequency_threshold' && text_val === null) {
|
|
|
|
text_val = '1'
|
|
|
|
}
|
2024-07-25 07:29:10 +00:00
|
|
|
if (inputName === 'display_size' && text_val === null) {
|
2024-07-31 15:39:14 +00:00
|
|
|
text_val = '2-10'
|
2024-07-25 07:29:10 +00:00
|
|
|
}
|
2024-01-22 13:56:12 +00:00
|
|
|
inputElement.val(text_val);
|
|
|
|
|
|
|
|
} else if (inputType === 'checkbox') {
|
|
|
|
var check_value = localStorage.getItem(inputName);
|
|
|
|
if (check_value !== null) {
|
|
|
|
inputElement.prop('checked', check_value === 'true');
|
|
|
|
}
|
2024-07-25 07:29:10 +00:00
|
|
|
if (inputName === 'node_type_none' && check_value === null) {
|
|
|
|
$('input.association_measures').prop('disabled', true);
|
|
|
|
$('input.association_measures').prop('checked', false);
|
|
|
|
} else if(inputName === 'node_type_none' && check_value == 'true') {
|
|
|
|
$('input.association_measures').prop('disabled', true);
|
|
|
|
$('input.association_measures').prop('checked', false);
|
|
|
|
}
|
2024-01-22 13:56:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
var tree_size_min = localStorage.getItem('tree_size_min') !== null ? localStorage.getItem('tree_size_min') : 2;
|
|
|
|
var tree_size_max = localStorage.getItem('tree_size_max') !== null ? localStorage.getItem('tree_size_max') : 3;
|
|
|
|
return [tree_size_min, tree_size_max]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-10-04 15:24:40 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function(event) {
|
2024-01-22 13:56:12 +00:00
|
|
|
tree_size = readValuesFromLocalstorage()
|
|
|
|
|
2024-02-13 14:19:22 +00:00
|
|
|
var valuesForSlider = [1,2,3,4,5];
|
2023-10-04 15:24:40 +00:00
|
|
|
|
|
|
|
var format = {
|
|
|
|
to: function(value) {
|
|
|
|
return valuesForSlider[Math.round(value)];
|
|
|
|
},
|
|
|
|
from: function (value) {
|
|
|
|
return valuesForSlider.indexOf(Number(value));
|
|
|
|
}
|
|
|
|
};
|
2024-02-19 14:33:19 +00:00
|
|
|
var urlParams = new URLSearchParams(window.location.search);
|
|
|
|
var lang='en'
|
|
|
|
if (urlParams.has('lang')) {
|
|
|
|
lang=urlParams.get('lang');
|
|
|
|
}
|
|
|
|
|
2024-02-13 14:19:22 +00:00
|
|
|
var perfEntries = performance.getEntriesByType("navigation");
|
|
|
|
for (var i = 0; i < perfEntries.length; i++) {
|
|
|
|
if (perfEntries[i].type === 'back_forward') {
|
2024-02-21 10:10:31 +00:00
|
|
|
window.location.href = '/stark/?lang='+lang;
|
2024-02-13 14:19:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-19 14:33:19 +00:00
|
|
|
|
2024-02-13 14:19:22 +00:00
|
|
|
if (urlParams.has('reload')) {
|
|
|
|
localStorage.clear();
|
2024-02-21 10:10:31 +00:00
|
|
|
window.location.href = '/stark/?lang='+lang;
|
2024-02-13 14:19:22 +00:00
|
|
|
|
|
|
|
}
|
2023-10-04 15:24:40 +00:00
|
|
|
});
|
|
|
|
|
2024-07-25 07:29:10 +00:00
|
|
|
function adjustLabelPosition() {
|
|
|
|
$('.dynamic-height').each(function() {
|
|
|
|
var $label = $(this).find('label');
|
|
|
|
var $input = $(this).find('input');
|
|
|
|
|
|
|
|
// Get the original top and left positions
|
|
|
|
var originalTop = parseFloat($label.css('top'));
|
|
|
|
var labelHeight = parseFloat($label.css('height'));
|
|
|
|
var labelLineHeight = parseFloat($label.css('line-height'));
|
|
|
|
var heightDelta = (Math.floor(labelHeight / labelLineHeight) - 1) * labelLineHeight;
|
|
|
|
|
|
|
|
$label.css({
|
|
|
|
top: -heightDelta
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-04 15:24:40 +00:00
|
|
|
(function($){
|
|
|
|
$(function(){
|
|
|
|
|
|
|
|
$('.sidenav').sidenav();
|
|
|
|
|
2024-02-21 10:10:31 +00:00
|
|
|
});
|
2023-10-04 15:24:40 +00:00
|
|
|
$(document).ready(function(){
|
2024-02-13 14:19:22 +00:00
|
|
|
$('.modal').modal();
|
|
|
|
|
2024-01-22 13:56:12 +00:00
|
|
|
$('.input-field input[type="checkbox"]').on('change', function() {
|
|
|
|
var isChecked = $('.input-field input[type="checkbox"]:checked').length > 0;
|
|
|
|
$('#node-type-error').hide();
|
|
|
|
});
|
|
|
|
$('#submit-form input').on('change', function() {
|
|
|
|
$('#unknown-error').hide();
|
2023-12-05 14:26:57 +00:00
|
|
|
});
|
2024-01-22 13:56:12 +00:00
|
|
|
|
|
|
|
$('#advanced-tree').hide();
|
2023-12-05 14:26:57 +00:00
|
|
|
var advancedTreeExpanded = false;
|
|
|
|
$('#advanced-tree-expand').bind('click', function(e) {
|
|
|
|
if (!advancedTreeExpanded){
|
|
|
|
advancedTreeExpanded = true;
|
2024-07-25 16:36:56 +00:00
|
|
|
$('#advanced-tree').show('fast', function() {
|
|
|
|
adjustLabelPosition();
|
|
|
|
});
|
2023-12-05 14:26:57 +00:00
|
|
|
$('#advanced-tree-expand i').text('remove');
|
|
|
|
} else {
|
|
|
|
advancedTreeExpanded = false;
|
|
|
|
$('#advanced-tree').hide('fast');
|
|
|
|
$('#advanced-tree-expand i').text('add');
|
|
|
|
}
|
|
|
|
});
|
2024-03-05 08:08:24 +00:00
|
|
|
|
|
|
|
$('#compare-settings').hide();
|
|
|
|
var compareExpanded = false;
|
|
|
|
$('#compare-expand').bind('click', function(e) {
|
|
|
|
if (!compareExpanded){
|
|
|
|
compareExpanded = true;
|
2024-07-25 16:36:56 +00:00
|
|
|
$('#compare-settings').show('fast', function() {
|
|
|
|
adjustLabelPosition();
|
|
|
|
});
|
2024-03-05 08:08:24 +00:00
|
|
|
$('#compare-expand i').text('remove');
|
|
|
|
} else {
|
|
|
|
compareExpanded = false;
|
|
|
|
$('#compare-settings').hide('fast');
|
|
|
|
$('#compare-expand i').text('add');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-12-05 14:26:57 +00:00
|
|
|
});
|
2023-10-04 15:24:40 +00:00
|
|
|
|
2023-12-05 14:26:57 +00:00
|
|
|
$("#submit-form").submit( function(eventObj) {
|
2024-01-22 13:56:12 +00:00
|
|
|
storeValuesToLocalstorage();
|
2023-12-05 14:26:57 +00:00
|
|
|
return true;
|
2023-10-04 15:24:40 +00:00
|
|
|
});
|
2024-02-19 14:33:19 +00:00
|
|
|
$("#switch-language").click(function(e) {
|
|
|
|
storeValuesToLocalstorage();
|
|
|
|
return true;
|
|
|
|
});
|
2024-07-04 11:39:46 +00:00
|
|
|
$('input.node_type').on('change', function(e) {
|
|
|
|
if (this.name == 'node_type_none') {
|
|
|
|
$('input.node_type').not(this).prop('checked', false);
|
2024-07-25 07:29:10 +00:00
|
|
|
$('input.association_measures').prop('disabled', true);
|
|
|
|
$('input.association_measures').prop('checked', false);
|
2024-07-04 11:39:46 +00:00
|
|
|
} else {
|
|
|
|
$('input.node_type_none').prop('checked', false);
|
2024-07-25 07:29:10 +00:00
|
|
|
$('input.association_measures').prop('disabled', false);
|
2024-07-04 11:39:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$('a.example-input-link').click(function(e) {
|
|
|
|
$('#input_url').val(this.href)
|
2024-07-25 07:29:10 +00:00
|
|
|
$('label[for="input_url"]').addClass('active')
|
2024-07-04 11:39:46 +00:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
$('a.example-compare-link').click(function(e) {
|
|
|
|
$('#compare_url').val(this.href)
|
2024-07-25 07:29:10 +00:00
|
|
|
$('label[for="compare_url"]').addClass('active')
|
2024-07-04 11:39:46 +00:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2024-07-25 07:29:10 +00:00
|
|
|
// Initial adjustment
|
|
|
|
adjustLabelPosition();
|
|
|
|
|
|
|
|
// Adjust on window resize
|
|
|
|
$(window).resize(adjustLabelPosition);
|
2024-07-04 11:39:46 +00:00
|
|
|
|
|
|
|
|
2024-02-21 10:10:31 +00:00
|
|
|
})(jQuery);
|
2023-10-04 15:24:40 +00:00
|
|
|
|