diff --git a/entries/static/entries/js/components/LexicalUnitDisplay.js b/entries/static/entries/js/components/LexicalUnitDisplay.js index 1c42ac2428b3ed2ed3c0207c25e01cb42c5362df..3e0d52da23b241c090b6a207857afde7dc9ec4d5 100644 --- a/entries/static/entries/js/components/LexicalUnitDisplay.js +++ b/entries/static/entries/js/components/LexicalUnitDisplay.js @@ -93,15 +93,31 @@ export default { }, setup () { $('#lexical-unit-notes').html(''); - get_entry(this.entryId, false, this.lexicalUnitId).then(entry => { - this.frame = entry.frames[0]; - this.unifiedFrame = entry.unified_frame; - this.subentries = entry.subentries; - this.alternations = entry.alternations; - this.realisation_phrases = entry.realisation_phrases; - this.realisation_descriptions = entry.realisation_descriptions; - this.examples = entry.examples; - setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes); + + var data = { 'entry' : this.entryId, 'no_filters' : false, 'lexical_unit_id': this.lexicalUnitId }; + $.ajax({ + type : 'post', + url : '/' + lang + '/entries/get_entry/', + dataType : 'json', + data : data, + timeout : 60000, + success : function(response) { + + window.clear_info(); + this.frame = response.frames[0]; + this.unifiedFrame = response.unified_frame; + this.subentries = response.subentries; + this.alternations = response.alternations; + this.realisation_phrases = response.realisation_phrases; + this.realisation_descriptions = response.realisation_descriptions; + this.examples = response.examples; + + window.update_last_visited(response.last_visited); + window.setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes); + }.bind(this), + error: function(request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + } }); } }, diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js index 7b7406d74cce7da60b3098b89d69ee1af7c0e4f9..a24251f330b6147dfa24a0d0a3ccfbe787ef1b36 100644 --- a/entries/static/entries/js/components/LexicalUnitEdit.js +++ b/entries/static/entries/js/components/LexicalUnitEdit.js @@ -118,14 +118,9 @@ Object.assign(LexicalUnitEdit, { let ret = frame2dom(frame); return ret.outerHTML; }, - show_semantics_unified_view(frames, subentries) { - $('#semantics-no-examples').hide(); - var schemata_dom = subentries2dom(subentries); - $('#semantics-schemata').append($(schemata_dom)); - }, async loadFrame() { try { - var data = {'unified_frame_id': this.unifiedFrameId}; + const data = {'unified_frame_id': this.unifiedFrameId}; $.ajax({ type: 'post', url: '/' + lang + '/unifier/get_unified_frame/', @@ -135,48 +130,24 @@ Object.assign(LexicalUnitEdit, { success: function (response) { this.img_prefix = window.STATIC_URL; - this.lexical_units = frames2lexical_units(response.frames); - this.unified_frame = response.unified_frame; - this.unified_frame_title = this.unified_frame.title || lexical_units2dom(this.lexical_units) + this.unified_frame_title = this.unified_frame.title; this.unified_frame_arguments = this.unified_frame.arguments; this.frames = response.frames; - - // $('#lexical-unit').html(this.unified_frame_title); - this.slowal_frames2selecional_preferencies_mapping = slowal_frames2selecional_preferencies(this.unified_frame, response.frames); - // unified_view_frame_content = response.frames - curr_entry = this.unifiedFrameId; - // curr_no_filters = related; - clear_info(); - curr_alternations = response.alternations; - curr_realisation_phrases = response.realisation_phrases; - curr_realisation_descriptions = response.realisation_descriptions; - curr_examples = response.examples; - this.subentries = response.subentries; this.alternations = response.alternations; this.realisation_phrases = response.realisation_phrases; this.realisation_descriptions = response.realisation_descriptions; this.examples = response.examples; - curr_examples_by_id = Object(); - for (var i in curr_examples) { - curr_examples_by_id[curr_examples[i].id] = curr_examples[i]; - } - // show_unified_frame_lexical_units(response.frames) - fulfill_slowal_frames_arguments_with_empty_elems(response.unified_frame, response.frames) - this.show_semantics_unified_view(response.frames, response.subentries); - // show_unmatched_examples(); - - // tooltips with meaning gloss - activate_tooltips($('#semantics-frames-pane')); - update_last_visited(response.last_visited); + window.fulfill_slowal_frames_arguments_with_empty_elems(response.unified_frame, response.frames) + window.update_last_visited(response.last_visited); + window.clear_info(); this.changeStatusButtonTitleToDefault(); - if(!this.active_slowal_frame) { this.setup_notes_unified_frame(); } @@ -232,13 +203,13 @@ Object.assign(LexicalUnitEdit, { if (!this.active_unified_frame_argument) { alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję.")); } else { - var existingPreferencies = function () { + const existingPreferencies = function () { return this.active_unified_frame_argument.preferences.map(preference => { return `<label><input type="checkbox" name="preference" value="${preference.id}" /> ${preference.str}</label><br />`; }).join(""); }.bind(this); - var remove_preference_popup = { + const remove_preference_popup = { state0: { title: 'Wybierz preferencje do usunięcia', html: existingPreferencies, @@ -252,7 +223,7 @@ Object.assign(LexicalUnitEdit, { if (v === 1) { e.preventDefault(); let preference_ids = normalizeFormData(f.preference); - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'argument_id': this.active_unified_frame_argument.id, 'preference_ids': JSON.stringify(preference_ids) @@ -282,7 +253,7 @@ Object.assign(LexicalUnitEdit, { }, changeTitle() { let title = this.unified_frame.title != null ? this.unified_frame.title : ''; - var change_title_popup = { + const change_title_popup = { state0: { title: 'Zmiana nazwy ramy', html: '<input type="text" size="32" value="' + title + '" name="title" />', @@ -294,12 +265,12 @@ Object.assign(LexicalUnitEdit, { } if (v === 1) { e.preventDefault(); - var title = f.title; + const title = f.title; if (this.hasWhiteSpace(title)) { alert(gettext("Nazwa zunifikowanej ramy nie może zawierać białych znaków.")); } else { - var data = {'unified_frame_id': this.unified_frame.id, 'unified_frame_title': title}; + const data = {'unified_frame_id': this.unified_frame.id, 'unified_frame_title': title}; $.ajax({ type: 'post', url: '/' + lang + '/unifier/save_unified_frame_title/', @@ -327,7 +298,7 @@ Object.assign(LexicalUnitEdit, { if (!this.active_unified_frame_argument) { alert(gettext("Zaznacz argument, dla którego chcesz wybrać rolę.")); } else { - var existingSelect = function () { + const existingSelect = function () { let selected_unified_frame_argument = this.unified_frame_arguments.find(o => o.id === this.active_unified_frame_argument.id); if (!selected_unified_frame_argument.proposed_roles) { return gettext('Brak ról do wyboru.') @@ -337,7 +308,7 @@ Object.assign(LexicalUnitEdit, { }).join(""); }.bind(this); - var newSelect = function () { + const newSelect = function () { let rolesHTML = roles.map(role => { return `<label><input type="radio" name="role" value="${role.id}" /> ${role.role}</label><br />`; }).join(""); @@ -391,7 +362,7 @@ Object.assign(LexicalUnitEdit, { if (v == 1) { e.preventDefault(); normalizeFormData(f.roles).map(role_id => { - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'complement_id': this.active_unified_frame_argument.id, 'role_id': role_id @@ -428,13 +399,13 @@ Object.assign(LexicalUnitEdit, { if (v == 1) { e.preventDefault(); - var role_id = normalizeFormData(f.role)[0]; - var role_type = normalizeFormData(f.role_type)[0]; + const role_id = normalizeFormData(f.role)[0]; + const role_type = normalizeFormData(f.role_type)[0]; if (role_id != null && role_type != null) { - var attribute_id = normalizeFormData(f.attribute)[0]; + const attribute_id = normalizeFormData(f.attribute)[0]; - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'complement_id': this.active_unified_frame_argument.id, 'role_type': role_type, @@ -467,7 +438,7 @@ Object.assign(LexicalUnitEdit, { } }, addArgument() { - var data = {'unified_frame_id': this.unified_frame.id}; + const data = {'unified_frame_id': this.unified_frame.id}; $.ajax({ type: 'post', url: '/' + lang + '/unifier/add_argument/', @@ -489,10 +460,10 @@ Object.assign(LexicalUnitEdit, { alert(gettext("Zaznacz argument, który chcesz usunąć.")); } else { let hasSlowalFrameArgumentMapping = false; - for (var i in this.unified_frame.slowal_frame_mapping) { - var slowal_frame_mapping = this.unified_frame.slowal_frame_mapping[i]; - for (var j in slowal_frame_mapping.slowal_frame_argument_mapping) { - var slowal_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping[j]; + for (let i in this.unified_frame.slowal_frame_mapping) { + const slowal_frame_mapping = this.unified_frame.slowal_frame_mapping[i]; + for (let j in slowal_frame_mapping.slowal_frame_argument_mapping) { + const slowal_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping[j]; if (slowal_frame_argument_mapping.unified_frame_agrument_id == this.active_unified_frame_argument.id) { hasSlowalFrameArgumentMapping = true; break; @@ -502,7 +473,7 @@ Object.assign(LexicalUnitEdit, { if (hasSlowalFrameArgumentMapping) { alert(gettext("Zaznaczony argument nie może zostać usunięty - podpięte ramy posiadają do niego dowiązania.")); } else { - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'complement_id': this.active_unified_frame_argument.id }; @@ -526,7 +497,7 @@ Object.assign(LexicalUnitEdit, { }, duplicate() { let title = this.unified_frame.title != null ? this.unified_frame.title : ''; - var duplicate_popup = { + const duplicate_popup = { state0: { title: 'Podaj nazwę zduplikowanej ramy', html: '<input type="text" size="32" value="KOPIA_' + title + '" name="title" />', @@ -539,12 +510,12 @@ Object.assign(LexicalUnitEdit, { } if (v === 1) { e.preventDefault(); - var title = f.title; + const title = f.title; if (this.hasWhiteSpace(title)) { alert(gettext("Nazwa zunifikowanej ramy nie może zawierać białych znaków.")); } else { - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'target_unified_frame_title': title }; @@ -578,8 +549,8 @@ Object.assign(LexicalUnitEdit, { } else { let roleDict = {}; let hasPreferenceSelected = true; - for (var i in this.unified_frame_arguments) { - var argument = this.unified_frame_arguments[i]; + for (let i in this.unified_frame_arguments) { + const argument = this.unified_frame_arguments[i]; if(argument.role) { roleDict[argument.role.str] = argument.role; } @@ -590,7 +561,7 @@ Object.assign(LexicalUnitEdit, { if(Object.keys(roleDict).length === this.unified_frame_arguments.length && hasPreferenceSelected) { //all roles are set, and are uniq //TODO: aktywne preferencje w argumencie nie znajdują się w relacji hipo-/hiperonimii. - var data = {'unified_frame_id': this.unified_frame.id}; + const data = {'unified_frame_id': this.unified_frame.id}; $.ajax({ type: 'post', url: '/' + lang + '/unifier/change_unified_frame_status_to_ready/', @@ -611,9 +582,9 @@ Object.assign(LexicalUnitEdit, { } }, change_slowal2unified_frame_argument_mapping(slowal_frame_id) { - var argument_ids = []; + const argument_ids = []; $('.argument.active').each(function() { - var id = $(this).data('argument_id').split('-')[1]; + const id = $(this).data('argument_id').split('-')[1]; if(id.startsWith('_')) { id = -parseInt(id.split('_')[1]) } else { @@ -621,12 +592,12 @@ Object.assign(LexicalUnitEdit, { } argument_ids.push(id); }); - var choosed_slowal_frame_id = null; + let choosed_slowal_frame_id = null; $('.frame.active').each(function() { choosed_slowal_frame_id = $(this).data('frame_id'); }); if(choosed_slowal_frame_id == slowal_frame_id && argument_ids.length == 2) { - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'slowal_frame_id': choosed_slowal_frame_id, 'slowal_frame_selected_arguments': JSON.stringify(argument_ids) @@ -675,7 +646,7 @@ Object.assign(LexicalUnitEdit, { "za niedopasowana do zunifikowanej ramy (identyfikator) przez (Leksykograf)."); } - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'slowal_frame_id': frame.id, 'status': status @@ -726,7 +697,7 @@ Object.assign(LexicalUnitEdit, { const isSuperLeksykograf = this.isSuperLeksykograf(); this.statusButtonTitle = isSuperLeksykograf ? 'Sprawdź' : 'Gotowe'; }, - slowalFrameSelected(frame) { + deselectSlowalFrameSelectedElements () { this.subentries.forEach(subentry => { subentry.schemata.forEach(s => { s.selected = false; @@ -743,6 +714,9 @@ Object.assign(LexicalUnitEdit, { this.selectedLus = []; this.selectedFrameArguments = []; this.selectedSchemas = []; + }, + slowalFrameSelected(frame) { + this.deselectSlowalFrameSelectedElements(); if (this.active_slowal_frame === frame) { this.active_slowal_frame = null; if(!this.readOnly) { @@ -768,13 +742,13 @@ Object.assign(LexicalUnitEdit, { }, extract_frames_to_new_frame() { - var existingSelect = function () { + const existingSelect = function () { return this.frames.map(frame => { return `<label><input type="checkbox" name="frames" value="${frame.id}" /> ${lexical_units2dom(frame.lexical_units)}</label><br />`; }).join(""); }.bind(this); - var extract_frames_to_new_frame_popup = { + const extract_frames_to_new_frame_popup = { state0: { title: 'Podaj nazwę zduplikowanej ramy', html: existingSelect, @@ -788,7 +762,7 @@ Object.assign(LexicalUnitEdit, { if (v === 1) { e.preventDefault(); let frame_ids = normalizeFormData(f.frames); - var data = { 'unified_frame_id' : this.unified_frame.id, 'slowal_frame_ids' : JSON.stringify(frame_ids), + const data = { 'unified_frame_id' : this.unified_frame.id, 'slowal_frame_ids' : JSON.stringify(frame_ids), 'target_unified_frame_id': ''}; $.ajax({ type : 'post', @@ -817,7 +791,7 @@ Object.assign(LexicalUnitEdit, { extract_frame_to_preview_frame() { if(this.currentPreviewedUnifiedFrameId !== -1 && this.currentPreviewedUnifiedFrameId !== this.unified_frame.id) { let target_unified_frame_id = this.currentPreviewedUnifiedFrameId; - var data = { + const data = { 'unified_frame_id': this.unified_frame.id, 'slowal_frame_ids': JSON.stringify([this.active_slowal_frame.id]), 'target_unified_frame_id': target_unified_frame_id }; @@ -1032,7 +1006,7 @@ Object.assign(LexicalUnitEdit, { > <tbody> <tr> - <th scope="row"> + <td scope="row"> <div @mouseenter="frame.hover=true" @mouseleave="frame.hover=false" @@ -1048,7 +1022,7 @@ Object.assign(LexicalUnitEdit, { @frame-selection-changed="insideFrameSelectionChanged" /> </div> - </th> + </td> <th scope="row"> <div v-if="!readOnly"> <div v-if="isFrameVerified(frame)"> diff --git a/entries/static/entries/js/components/frame-components/MeaningComponent.js b/entries/static/entries/js/components/frame-components/MeaningComponent.js index 31eda2c3af6b9d201496ef49d22dbe865070d24a..faefcf9e84bf72e78992bb3b4916f934987d470e 100644 --- a/entries/static/entries/js/components/frame-components/MeaningComponent.js +++ b/entries/static/entries/js/components/frame-components/MeaningComponent.js @@ -13,7 +13,7 @@ export default { components: {InfoTooltip}, methods: { getTooltipStr (lu) { - var tooltip = []; + const tooltip = []; if (lu.definition) { tooltip.push(lu.definition); } diff --git a/entries/static/entries/js/components/frame-components/SemanticsSchemataComponent.js b/entries/static/entries/js/components/frame-components/SemanticsSchemataComponent.js index f5e17ce663aa60dee3ce0e215646a4ceafaef32d..b72993d168fed225731456505ec33f7c4431bda8 100644 --- a/entries/static/entries/js/components/frame-components/SemanticsSchemataComponent.js +++ b/entries/static/entries/js/components/frame-components/SemanticsSchemataComponent.js @@ -52,7 +52,7 @@ export default { for (let i in curr_alternations) { const alternation = curr_alternations[i] - for (var arg_id in alternation){ + for (let arg_id in alternation){ const phrase_ids = alternation[arg_id]; phrase_ids.forEach(phrase_id => { if (phrase_id.startsWith(position.id)) { @@ -78,11 +78,11 @@ export default { for (let i in curr_alternations) { const alternation = curr_alternations[i] - for (var arg_id in alternation){ + for (let arg_id in alternation){ const phrase_ids = alternation[arg_id]; phrase_ids.forEach(phrase_id => { if (phrase_id.startsWith(position.id)) { - phrases.push(curr_realisation_phrases[arg_id][i][phrase_id]); + phrases.push(this.realisation_phrases[arg_id][i][phrase_id]); } }); } @@ -134,7 +134,7 @@ export default { <td class="position py-2 px-1 border-top border-left border-secondary" v-for="position in schema.positions"> - <div v-for="f in getFunctions(position)" class="phrase px-1 py-2 " data-alternation="0" data-phrase_id="42-2-1"> + <div v-for="f in getFunctions(position)" class="phrase px-1 py-2"> <info-tooltip :text="f.tooltip" :visibleText="f.str"/> </div> </td> @@ -148,8 +148,7 @@ export default { <th scope="row" class="py-0 px-1 text-secondary">Typy fraz</th> <td v-for="position in schema.positions" class="px-0 py-0 border-top border-left border-secondary"> <div v-for="phrase in position.phrases" class="phrase px-1 py-2" - :class="getRoleCss(schema, position)" - data-alternation="0" data-phrase_id="45-8-7"> + :class="getRoleCss(schema, position)"> <info-tooltip :text="phrase.desc" :visibleText="phrase.str"/> </div> <div v-for="phrase in getPositionPhrases(schema, position)" class="realisation-phrase px-1 py-2"><i>{{phrase}}</i></div> diff --git a/entries/static/entries/js/components/frame-components/SlowalFrameComponent.js b/entries/static/entries/js/components/frame-components/SlowalFrameComponent.js index 301cda80edbe51293317a0952424e1e29c83a4d8..f9885c322db6b7fd95110af8441f601194facd02 100644 --- a/entries/static/entries/js/components/frame-components/SlowalFrameComponent.js +++ b/entries/static/entries/js/components/frame-components/SlowalFrameComponent.js @@ -41,7 +41,7 @@ export default { this.img_prefix = window.STATIC_URL; }, template: ` - <div class="frame mb-3 active" data-frame_id="52"> + <div class="frame mb-3 active"> <div class="frame mt-3" id="lexical-unit"> <meaning-component :lexicalUnits="frame.lexical_units" diff --git a/entries/static/entries/js/entries.js b/entries/static/entries/js/entries.js index 27be8a756aea4b6de8af707eb58277f67d2b733f..43d1626bfbe718753655721164cb062eee147f81 100644 --- a/entries/static/entries/js/entries.js +++ b/entries/static/entries/js/entries.js @@ -13,7 +13,7 @@ var roles = [] var role_attributes = [] function make_opinion_row(item, span, width) { - var opinion_row = document.createElement('tr'); + const opinion_row = document.createElement('tr'); opinion_row.className = 'opinion-row'; opinion_row.innerHTML = '<th scope="row" class="py-2 px-1 text-secondary" style="width: ' + width + 'em;">' + gettext('Opinia') + '</td>'; opinion_row.innerHTML += '<td class="opinion-cell py-2 px-1" colspan="' + span + '"><img src="' + window.STATIC_URL + 'entries/img/' + item.opinion_key + '.svg" width="12" height="12" alt="' + item.opinion + '"> ' + item.opinion + '</td>'; @@ -22,29 +22,29 @@ function make_opinion_row(item, span, width) { // TODO make schema2dom and frame2dom share as much code as possible function schema2dom(schema) { - var div = document.createElement('div'); + const div = document.createElement('div'); div.className = 'schema mb-3 inactive'; div.setAttribute('data-schema_id', schema.id); - var table = document.createElement('table'); + const table = document.createElement('table'); table.className = 'table m-0 table-borderless border border-secondary text-dark'; - var tbody = document.createElement('tbody'); + const tbody = document.createElement('tbody'); // opinion - var opinion_row = make_opinion_row(schema, schema.positions.length, 3); + const opinion_row = make_opinion_row(schema, schema.positions.length, 3); // position props and phrase types - var props_row = document.createElement('tr'); + const props_row = document.createElement('tr'); props_row.innerHTML = '<th scope="row" class="py-2 px-1 text-secondary">' + gettext('Funkcja') + '</td>'; - var phrases_row = document.createElement('tr'); + const phrases_row = document.createElement('tr'); phrases_row.className = 'phrase-types alt-0' - var phrases_html = '<th scope="row" class="py-0 px-1 text-secondary">' + gettext('Typy fraz') + '</td>'; - for (var i in schema.positions) { - var position = schema.positions[i]; + let phrases_html = '<th scope="row" class="py-0 px-1 text-secondary">' + gettext('Typy fraz') + '</td>'; + for (let i in schema.positions) { + const position = schema.positions[i]; // position props: function, control, predicative control - var props_td = document.createElement('td'); + const props_td = document.createElement('td'); props_td.className = 'position py-2 px-1 border-top border-left border-secondary'; props_td.dataset.position_id = position.id; - var props_spans = []; + const props_spans = []; if (position.func.str !== '') { props_spans.push(tooltipped_span(position.func.str, position.func.desc, null)); } @@ -58,9 +58,9 @@ function schema2dom(schema) { props_row.append(props_td); // don’t append to phrases_row.innerHTML since it automatically closes tags *** (?) phrases_html += '<td class="px-0 py-0 border-top border-left border-secondary">'; - for (var j in position.phrases) { - var phrase = position.phrases[j]; - var cls = j > 0 ? ' border-top' : ''; + for (let j in position.phrases) { + const phrase = position.phrases[j]; + let cls = j > 0 ? ' border-top' : ''; if (phrase.str.length > 32) { cls += ' text-break'; } @@ -1127,13 +1127,13 @@ $(document).ready(function() { initialize_entries_list(); - $('#id_filter_schema_').change(function() { - get_entry(curr_entry, curr_no_filters); - }); - - $('#id_filter_frame_').change(function() { - get_entry(curr_entry, curr_no_filters); - }); + // $('#id_filter_schema_').change(function() { + // get_entry(curr_entry, curr_no_filters); + // }); + // + // $('#id_filter_frame_').change(function() { + // get_entry(curr_entry, curr_no_filters); + // }); initialize_main_form(); diff --git a/entries/static/entries/js/selectional_preference.js b/entries/static/entries/js/selectional_preference.js index d0cc544540d3efa5e970c0fb87827089ed05da17..1ee7f992de301db2d6d0d359f70eb64e7f9db68f 100644 --- a/entries/static/entries/js/selectional_preference.js +++ b/entries/static/entries/js/selectional_preference.js @@ -4,9 +4,9 @@ var synsets = []; var change = false; function predefinedSelect() { - var display = ""; + let display = ""; - var i; + let i; for (i = 0; i < predefined.length; i++) { display += "<input type = \"checkbox\" name = \"predef\" value = \"" + predefined[i].id + "\">" + predefined[i].content + "<br>"; } @@ -30,9 +30,9 @@ function memorizeRelations(new_relations) { } function relationsSelect() { - var display = "<select name = \"rel\">"; + let display = "<select name = \"rel\">"; - var i; + let i; for (i = 0; i < relations.length; i++) { display += "<option value = \"" + relations[i].id + "\">" + relations[i].content + "</option>"; } @@ -41,24 +41,12 @@ function relationsSelect() { } function argumentSelect(frame, complement_id) { - var display = "<select name = \"arg\">"; + let display = "<select name = \"arg\">"; - var i; + let i; for (i = 0; i < frame.arguments.length; i++) { var local_complement_id = frame.arguments[i].argument_id; if (local_complement_id && local_complement_id !== String(complement_id)) { - // var list = frame_content[unified_frame_id].display.roles[i].argument; - // - // var text = []; - // var j; - // for (j = 0; j < list.length; j++) { - // text.push(role_name[list[j]]); - // } - // display += "<option value = \"" + list + "\">" + text + "</option>"; - - // var text = []; - // text.push(frame.arguments[i].role); - display += "<option value = \"" + local_complement_id + "\">" + frame.arguments[i].role + "</option>"; } } @@ -82,14 +70,14 @@ function getSynsets(context, pos) { async: false }); - var display = ""; + let display = ""; - var i; + let i; for (i = 0; i < synsets.length; i++) { display += "<input type = \"radio\" name = \"synset\" value = \"" + synsets[i].id + "\"><div>"; - var j; + let j; for (j = 0; j < synsets[i].content.length; j++) { - var lexical_unit = synsets[i].content[j]; + const lexical_unit = synsets[i].content[j]; display += lexical_unit.base + "-" + lexical_unit.sense + ": <i>" + lexical_unit.glossa + "</i><br>"; } display += "</div>"; @@ -109,7 +97,7 @@ function attachPlWNContextAutocomplete() { }, source: function(req, add){ $.getJSON('plWN_context_lookup', req, function(data) { - var suggestions = []; + const suggestions = []; $.each(data['result'], function(i, val){ suggestions.push(val); }); @@ -127,16 +115,16 @@ function addSelectivePreference(unified_frame, unified_frame_active_argument_id, function addSelectivePreferenceBase(unified_frame, frames, complement_id, callbackFunction) { let unified_frame_id = unified_frame.id; - var submitSynsetSelection = function(e,v,m,f){ + const submitSynsetSelection = function(e,v,m,f){ if (v == -1) { e.preventDefault(); $.prompt.goToState('state2'); } if (v == 1) { e.preventDefault(); - var synset = normalizeFormData(f.synset); + const synset = normalizeFormData(f.synset); - var i; + let i; for (i = 0; i < synset.length; i++) { saveSynsetPreference(unified_frame_id, complement_id, synset[i]) } @@ -144,7 +132,7 @@ function addSelectivePreferenceBase(unified_frame, frames, complement_id, callba } } - var existingSelect = function () { + const existingSelect = function () { let availablePreferencies = slowal_frames2selecional_preferencies(unified_frame, frames)[complement_id]; if (!availablePreferencies) { return gettext('Brak preferencji selekcyjnych do wyboru.') @@ -154,7 +142,7 @@ function addSelectivePreferenceBase(unified_frame, frames, complement_id, callba }).join(""); }; - var select_preference = { + const select_preference = { state0: { title: 'Typ preferencji selekcyjnej', html: 'Wybierz typ preferencji selekcyjnej', @@ -198,9 +186,9 @@ function addSelectivePreferenceBase(unified_frame, frames, complement_id, callba } if (v == 1) { e.preventDefault(); - var predef = normalizeFormData(f.predef); + const predef = normalizeFormData(f.predef); - var i; + let i; for (i = 0; i < predef.length; i++) { savePredefinedPreference(unified_frame_id, complement_id, predef[i]) // addPreference(unified_frame_id, complement_id, { type: 'g', content: predef[i], text: predefined[indexOfId(predefined, predef[i])].content }); @@ -240,10 +228,10 @@ function addSelectivePreferenceBase(unified_frame, frames, complement_id, callba if (v == 1) { e.preventDefault(); - var rel = normalizeFormData(f.rel); - var args = normalizeFormData(f.arg); + const rel = normalizeFormData(f.rel); + const args = normalizeFormData(f.arg); - var i, j; + let i, j; for (i = 0; i < rel.length; i++) { for (j = 0; j < args.length; j++) { saveRelationalSelectionalPreference(unified_frame_id, complement_id, args[j], rel[i]) @@ -296,7 +284,7 @@ function addSelectivePreferenceBase(unified_frame, frames, complement_id, callba function saveSynsetPreference(frame_id, complement_id, synset_preference_id) { - var data = { 'frame_id' : frame_id, 'complement_id' : complement_id, 'synset_preference_id' : synset_preference_id }; + const data = { 'frame_id' : frame_id, 'complement_id' : complement_id, 'synset_preference_id' : synset_preference_id }; $.ajax({ type : 'post', url : '/' + lang + '/unifier/save_synset_preference/', @@ -313,7 +301,7 @@ function saveSynsetPreference(frame_id, complement_id, synset_preference_id) { } function savePredefinedPreference(frame_id, complement_id, predefined_preference_id) { - var data = { 'frame_id' : frame_id, 'complement_id' : complement_id, 'predefined_preference_id' : predefined_preference_id }; + const data = { 'frame_id' : frame_id, 'complement_id' : complement_id, 'predefined_preference_id' : predefined_preference_id }; $.ajax({ type : 'post', url : '/' + lang + '/unifier/save_predefined_preference/', @@ -330,7 +318,7 @@ function savePredefinedPreference(frame_id, complement_id, predefined_preference } function saveRelationalSelectionalPreference(frame_id, complement_id_from, complement_id_to, relation_id) { - var data = { 'frame_id' : frame_id, 'complement_id_from' : complement_id_from, 'complement_id_to' : complement_id_to, 'relation_id': relation_id }; + const data = { 'frame_id' : frame_id, 'complement_id_from' : complement_id_from, 'complement_id_to' : complement_id_to, 'relation_id': relation_id }; $.ajax({ type : 'post', url : '/' + lang + '/unifier/save_relational_selectional_preference/', diff --git a/entries/static/entries/js/unification.js b/entries/static/entries/js/unification.js index cf36939c99e8e6c0a491a0585f284d8fb74a26fd..512cd6292d42ced11533aa0ddcbee837a23d3a75 100644 --- a/entries/static/entries/js/unification.js +++ b/entries/static/entries/js/unification.js @@ -4,8 +4,8 @@ function get_unified_frame(unified_frame_id, related) { check_import_status(); clear_entry(); show_entry_spinners(); - //var data = { 'forms' : serialize_forms($('#main-form')), 'entry' : entry_id }; - var data = { 'unified_frame_id' : unified_frame_id, 'no_filters' : related }; + //const data = { 'forms' : serialize_forms($('#main-form')), 'entry' : entry_id }; + const data = { 'unified_frame_id' : unified_frame_id, 'no_filters' : related }; $.ajax({ type : 'post', url : '/' + lang + '/unifier/get_unified_frame/', @@ -21,7 +21,7 @@ function get_unified_frame(unified_frame_id, related) { curr_realisation_descriptions = response.realisation_descriptions; curr_examples = response.examples; curr_examples_by_id = Object(); - for (var i in curr_examples) { + for (let i in curr_examples) { curr_examples_by_id[curr_examples[i].id] = curr_examples[i]; } // show_syntax(response.subentries); @@ -43,12 +43,12 @@ function get_unified_frame(unified_frame_id, related) { function slowal_frames2selecional_preferencies(unified_frame, slowal_frames) { - var unified_argument_2_selecional_preferencies = {} - for (var i in unified_frame.slowal_frame_mapping) { - var slowal_frame_mapping = unified_frame.slowal_frame_mapping[i]; + const unified_argument_2_selecional_preferencies = {} + for (let i in unified_frame.slowal_frame_mapping) { + const slowal_frame_mapping = unified_frame.slowal_frame_mapping[i]; let slowal_frame = slowal_frames.find(o => o.id === slowal_frame_mapping.slowal_frame_id); - for (var j in slowal_frame_mapping.slowal_frame_argument_mapping) { - var slowal_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping[j]; + for (let j in slowal_frame_mapping.slowal_frame_argument_mapping) { + const slowal_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping[j]; let slowal_frame_argument = slowal_frame.arguments.find(o => o.argument_id === slowal_frame_argument_mapping.slowal_frame_agrument_id); let unified_frame_argument = unified_frame.arguments.find(o => o.id === slowal_frame_argument_mapping.unified_frame_agrument_id); @@ -68,12 +68,12 @@ function slowal_frames2selecional_preferencies(unified_frame, slowal_frames) { function fulfill_slowal_frames_arguments_with_empty_elems(unified_frame, slowal_frames) { - for (var i in unified_frame.slowal_frame_mapping) { - var slowal_frame_mapping = unified_frame.slowal_frame_mapping[i]; + for (let i in unified_frame.slowal_frame_mapping) { + const slowal_frame_mapping = unified_frame.slowal_frame_mapping[i]; let slowal_frame = slowal_frames.find(o => o.id === slowal_frame_mapping.slowal_frame_id); let new_slowal_frame_arguments = []; - for (var j in unified_frame.arguments) { - var unified_frame_argument = unified_frame.arguments[j]; + for (let j in unified_frame.arguments) { + const unified_frame_argument = unified_frame.arguments[j]; let unified_frame_argument_mapping = slowal_frame_mapping.slowal_frame_argument_mapping.find(o => o.unified_frame_agrument_id === unified_frame_argument.id); @@ -99,11 +99,11 @@ function fulfill_slowal_frames_arguments_with_empty_elems(unified_frame, slowal_ } function frames2lexical_units(frames) { - var lexical_units = [] - for (var i in frames) { - var frame = frames[i]; - for (var j in frame.lexical_units) { - var lexical_unit = frame.lexical_units[j]; + const lexical_units = [] + for (let i in frames) { + const frame = frames[i]; + for (let j in frame.lexical_units) { + const lexical_unit = frame.lexical_units[j]; lexical_unit.opinion = frame.opinion; lexical_unit.opinion_key = frame.opinion_key; lexical_unit.frame_status = frame.status; diff --git a/entries/static/entries/js/unification_entries_for_frames_list.js b/entries/static/entries/js/unification_entries_for_frames_list.js index 0b0d90681498593a0ac40c471c413f7312d5ab10..18758e0686d30fc0e6e2446868bcbc7338aa74e1 100644 --- a/entries/static/entries/js/unification_entries_for_frames_list.js +++ b/entries/static/entries/js/unification_entries_for_frames_list.js @@ -11,7 +11,7 @@ function setup_entries_for_frames_list(options) { const ajaxURL = can_see_assignees ? '/' + window.lang + '/entries/get_entries/?with_lexical_units=true&has_unified_frame=true' : '/' + window.lang + '/entries/get_entries/?with_lexical_units=true&has_unified_frame=true&exclude_status=N&restrict_to_user='+window.USER_USERNAME; - var datatable = setup_datatable({ + const datatable = setup_datatable({ element: options.table, selectFirst: true, url: ajaxURL, @@ -25,12 +25,12 @@ function setup_entries_for_frames_list(options) { selectEntryId: options.selectEntryId, }); datatable.on('click', 'tr.entry', function () { - var row = datatable.row(this); - var has_drilldown = row.child.isShown(); + const row = datatable.row(this); + const has_drilldown = row.child.isShown(); $('.drilldown:visible', options.table).each(function () { datatable.row($(this).data("row")).child.hide(); }); if (!has_drilldown) { if (!row.data()) return; - var drilldown = $("<div>").addClass("drilldown").data("row", this); + const drilldown = $("<div>").addClass("drilldown").data("row", this); row.child(drilldown).show(); setup_lexical_units_for_frames_table(drilldown, row.data().lexical_units, can_see_assignees, options); drilldown.closest("td").addClass("p-0 pl-4"); diff --git a/entries/static/entries/js/unification_entries_list.js b/entries/static/entries/js/unification_entries_list.js index 0db5af2c5162e514f116086864a76359892a6650..c7fc045651eea108ffcc3be1efd3da7e47c96f62 100644 --- a/entries/static/entries/js/unification_entries_list.js +++ b/entries/static/entries/js/unification_entries_list.js @@ -9,7 +9,7 @@ function setup_entries_list(options) { ) ? gettext("tak") : gettext("nie"); } - var datatable = setup_datatable({ + const datatable = setup_datatable({ element: options.table, selectFirst: true, url: '/' + window.lang + '/entries/get_entries/?with_lexical_units=true', @@ -22,12 +22,12 @@ function setup_entries_list(options) { selectEntryId: options.selectEntryId, }); datatable.on('click', 'tr.entry', function () { - var row = datatable.row(this); - var has_drilldown = row.child.isShown(); + const row = datatable.row(this); + const has_drilldown = row.child.isShown(); $('.drilldown:visible', options.table).each(function () { datatable.row($(this).data("row")).child.hide(); }); if (!has_drilldown) { if (!row.data()) return; - var drilldown = $("<div>").addClass("drilldown").data("row", this); + const drilldown = $("<div>").addClass("drilldown").data("row", this); row.child(drilldown).show(); setup_lexical_units_table(drilldown, row.data().lexical_units, can_see_assignees, options); drilldown.closest("td").addClass("p-0 pl-4"); diff --git a/entries/static/entries/js/unification_frames_list.js b/entries/static/entries/js/unification_frames_list.js index 63b2fc91270f87bd007102d16cd2eb0ad865a1dc..bada75f7a6630bcca476f86e569713ae260a8d16 100644 --- a/entries/static/entries/js/unification_frames_list.js +++ b/entries/static/entries/js/unification_frames_list.js @@ -10,7 +10,7 @@ function setup_frames_list(options) { const ajaxURL = can_see_assignees ? '/' + lang + '/unifier/get_unified_frames/' : '/' + lang + '/unifier/get_unified_frames/?exclude_status=N&restrict_to_user='+window.USER_USERNAME; - var datatable = setup_datatable({ + const datatable = setup_datatable({ element: options.table, url: ajaxURL, columns: [ @@ -22,9 +22,9 @@ function setup_frames_list(options) { hidden_columns: can_see_assignees ? [3] : [2,3] }); datatable.on('click', 'tr.entry', function () { - var data = datatable.row(this).data(); + const data = datatable.row(this).data(); if (!data) return; - var related = data.related === true; + const related = data.related === true; $('.entry', options.table).removeClass('table-primary'); options.unifiedFrameSelected(Number(data.id)); $(this).addClass('table-primary');