2024-01-22 13:56:12 +00:00
|
|
|
// Global array to store input names
|
|
|
|
var globalInputList = ['tree_size_min', 'tree_size_max', 'file', 'association_measures', 'labeled_trees', 'node_type_upos', 'fixed_order', 'input_url', 'node_type_lemma', 'root_restriction', 'node_type_form'];
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
}
|
|
|
|
inputElement.val(text_val);
|
|
|
|
|
|
|
|
} else if (inputType === 'checkbox') {
|
|
|
|
var check_value = localStorage.getItem(inputName);
|
|
|
|
if (check_value !== null) {
|
|
|
|
inputElement.prop('checked', check_value === 'true');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
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()
|
|
|
|
|
2023-10-04 15:24:40 +00:00
|
|
|
var valuesForSlider = [2,3,4,5];
|
|
|
|
|
|
|
|
var format = {
|
|
|
|
to: function(value) {
|
|
|
|
return valuesForSlider[Math.round(value)];
|
|
|
|
},
|
|
|
|
from: function (value) {
|
|
|
|
return valuesForSlider.indexOf(Number(value));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var slider = document.getElementById('slider');
|
|
|
|
noUiSlider.create(slider, {
|
2024-01-22 13:56:12 +00:00
|
|
|
start: [tree_size[0], tree_size[1]],
|
2023-10-04 15:24:40 +00:00
|
|
|
connect: true,
|
|
|
|
tooltips: true,
|
|
|
|
step: 1,
|
|
|
|
range: {
|
|
|
|
'min': 0,
|
|
|
|
'max': valuesForSlider.length - 1
|
|
|
|
},
|
|
|
|
format: format
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
(function($){
|
|
|
|
$(function(){
|
|
|
|
|
|
|
|
$('.sidenav').sidenav();
|
|
|
|
|
|
|
|
}); // end of document ready
|
|
|
|
$(document).ready(function(){
|
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;
|
|
|
|
$('#advanced-tree').show('fast');
|
|
|
|
$('#advanced-tree-expand i').text('remove');
|
|
|
|
} else {
|
|
|
|
advancedTreeExpanded = false;
|
|
|
|
$('#advanced-tree').hide('fast');
|
|
|
|
$('#advanced-tree-expand i').text('add');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2023-10-04 15:24:40 +00:00
|
|
|
|
2023-12-05 14:26:57 +00:00
|
|
|
$("#submit-form").submit( function(eventObj) {
|
|
|
|
var spans = $(".noUi-tooltip").find('span');
|
|
|
|
var tree_size_min = spans[0].innerText;
|
|
|
|
var tree_size_max = spans[1].innerText;
|
|
|
|
console.log('amm');
|
|
|
|
$("<input />").attr("type", "hidden")
|
|
|
|
.attr("name", "tree_size_min")
|
|
|
|
.attr("value", tree_size_min)
|
|
|
|
.appendTo("#submit-form");
|
|
|
|
$("<input />").attr("type", "hidden")
|
|
|
|
.attr("name", "tree_size_max")
|
|
|
|
.attr("value", tree_size_max)
|
|
|
|
.appendTo("#submit-form");
|
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
|
|
|
});
|
|
|
|
})(jQuery); // end of jQuery name space
|
|
|
|
|