semantics_coupling.js
4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
function schemaGotAssignedSemantics(element_id) {
var semanticsAssigned = true;
var id_map = parseId(element_id);
var schema_id = id_map['frame_id'];
if(schema_id < 0) {
semanticsAssigned = false;
}
else {
jQuery.ajax({
type: 'get',
url: ajax_schema_got_assigned_semantics,
data: {lemma_id: window.lemma_id,
schema_id: schema_id},
success: function(result) {
semanticsAssigned = result['got_assigned_semantics'];
},
async: false
});
}
return semanticsAssigned;
}
function semanticsAssignedAlert() {
error_alert('Działaj rozważnie, element jest wykorzystywany w ramach semantycznych.');
}
function exampleGotAssignedSemantics(example_tab_id)
{
var semanticsAssigned = true;
var example_id = example_tab_id.replace('nkjp_', '');
if (example_id < 0) {
semanticsAssigned = false;
}
else {
jQuery.ajax({
type: 'get',
url: ajax_example_got_assigned_semantics,
data: {lemma_id: window.lemma_id,
example_id: example_id},
success: function(result) {
semanticsAssigned = result['got_assigned_semantics'];
},
async: false
});
}
return semanticsAssigned;
}
function semanticsAssignedExampleAlert() {
error_alert('Działaj rozważnie, przykład jest wykorzystywany w ramach semantycznych.');
}
function semanticsChanged() {
if(window.frames_operations.length > 0) {
return true;
}
return false;
}
function checkIfSemChangedAndAlert() {
if(semanticsChanged()) {
alert('Przed dokonaniem zmiany zapisz semantykę.');
return true;
}
return false;
}
function clearSemanticConnections(type, schemaElement) {
if(type == 'frame') {
clearSchemaConnections(schemaElement);
}
else if(type == 'position') {
clearPositionConnections(schemaElement);
}
else if(type == 'argument') {
clearPhraseTypeConnections(schemaElement);
}
}
function clearSchemaConnections(schema) {
for(var i=0; i<schema.positions.length; i++) {
clearPositionConnections(schema.positions[i]);
}
}
function clearPositionConnections(position) {
for(var i=0; i<position.arguments.length; i++) {
clearPhraseTypeConnections(position.arguments[i]);
}
}
function clearPhraseTypeConnections(phraseType) {
phraseType.connections = [];
}
function updateSchemataConnections() {
$('#new-frame-tables').empty();
$("#show_nkjp_table").empty();
$.ajaxJSON({
method: 'get',
url: ajax_get_schemata,
data: {
lemma_id: window.lemma_id
},
callback: function(result) {
window.schemas = serializedObjToObj(result['schemata']);
resetLemmaVersions();
var frame_class = 'InactiveFrameTable';
if(result['can_modify']) {
frame_class = 'ActiveFrameTable';
}
draw_filtered_frames(window.schemas, 'new-frame-tables', 'new-frame-table',
'frame_filter', window.nkjp_examples, frame_class,
window.lemma_entry, window.lemma_entry);
},
error_callback: function(xhr, status, error) {
error_alert(status + ': ' + error);
},
bad_data_callback: function(result) {
return true;
},
});
}
function updateExamplesConnections() {
$('#new-frame-tables').empty();
$("#show_nkjp_table").empty();
$.ajaxJSON({
method: 'get',
url: ajax_get_examples,
data: {
lemma_id: window.lemma_id
},
callback: function(result) {
window.nkjp_examples = serializedNkjpToObj(result['examples']);
resetLemmaVersions();
var frame_class = 'InactiveFrameTable';
if(result['can_modify']) {
frame_class = 'ActiveFrameTable';
}
draw_filtered_frames(window.schemas, 'new-frame-tables', 'new-frame-table',
'frame_filter', window.nkjp_examples, frame_class,
window.lemma_entry, window.lemma_entry);
},
error_callback: function(xhr, status, error) {
error_alert(status + ': ' + error);
},
bad_data_callback: function(result) {
return true;
},
});
}