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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
import { $gettext, $gettextInterpolate } from '../lib/gettext';
STUDIP.domReady(() => {
$('del.diffdel').each(function() {
var mvv_field = '';
$(this)
.parentsUntil('div')
.each(function() {
if ($(this).attr('data-mvv-field')) {
mvv_field = $(this).attr('data-mvv-field');
return true;
}
});
if (mvv_field != '') {
var mvv_id;
var senddata;
$(this)
.parentsUntil('div')
.each(function() {
if ($(this).attr('data-mvv-id')) {
mvv_id = $(this).attr('data-mvv-id');
return true;
}
});
var mvv_debug = $(this).text();
var del = $(this);
var fields = mvv_field.split(' ');
for (var i = 0; i < fields.length; ++i) {
var obj_elements = fields[i].split('.');
if (obj_elements.length == 1) {
senddata = { mvv_field: fields[i], mvv_debug: mvv_debug, log_action: 'del' };
} else {
senddata = { mvv_field: fields[i], mvv_id: mvv_id, log_action: 'update' };
}
var url = STUDIP.URLHelper.getURL('dispatch.php/shared/log_event/get_log_autor');
$.post(
url,
senddata,
function(data) {
if (data) {
var info = $gettextInterpolate(
$gettext('Entfernt von %{user} am %{time}'),
data
);
del.attr('title', info);
$('<del class="difflog"/>').text(` [${info}] `).insertAfter(del);
}
},
'json'
);
}
}
});
$('ins').each(function() {
var mvv_field = '';
var mvv_coid = '';
var mvv_id = '';
var mvv_log_action;
switch ($('ins').attr('class')) {
case 'diffins':
mvv_log_action = 'new';
break;
case 'diffmod':
mvv_log_action = 'update';
break;
default:
mvv_log_action = null;
break;
}
$(this)
.parentsUntil('div')
.each(function() {
if ($(this).attr('data-mvv-field')) {
mvv_field = $(this).attr('data-mvv-field');
mvv_coid = $(this).attr('data-mvv-coid');
return false;
}
});
if (mvv_field != '') {
$(this)
.parentsUntil('div')
.each(function() {
if ($(this).attr('data-mvv-id')) {
mvv_id = $(this).attr('data-mvv-id');
return false;
}
});
var ins = $(this);
var fields = mvv_field.split(' ');
for (var i = 0; i < fields.length; ++i) {
var senddata;
var obj_elements = fields[i].split('.');
if (obj_elements.length == 1 && mvv_coid) {
senddata = {
mvv_field: fields[i],
mvv_id: mvv_id,
mvv_coid: mvv_coid,
log_action: mvv_log_action
};
} else if (fields[i] == 'mvv_modulteil_stgteilabschnitt.differenzierung' && mvv_coid) {
var classes = $(this)
.parent()
.attr('class')
.split(' ');
if (classes.length > 1) {
var mvv_debug =
$(this)
.parent()
.attr('data-mvv-index') +
';' +
classes[1];
senddata = {
mvv_field: fields[i],
mvv_id: mvv_id,
mvv_coid: mvv_coid,
log_action: mvv_log_action,
mvv_debug: mvv_debug
};
} else {
return true;
}
} else {
senddata = { mvv_field: fields[i], mvv_id: mvv_id, log_action: mvv_log_action };
}
var url = STUDIP.URLHelper.getURL('dispatch.php/shared/log_event/get_log_autor');
$.post(
url,
senddata,
function(data) {
if (data) {
var info = $gettextInterpolate(
$gettext('Änderung durch %{user} am %{time}'),
data
);
ins.attr('title', info);
$('<ins class="difflog"/>').text(` [${info}] `).insertAfter(ins);
}
},
'json'
);
}
}
});
$('.mvv-diff-added').each(function() {
$(this)
.find('table')
.each(function() {
if ($(this).attr('data-mvv-type')) {
var mvv_type = $(this).attr('data-mvv-type');
var mvv_id = $(this).attr('data-mvv-id');
var curtable = $(this);
} else {
return true;
}
var url = STUDIP.URLHelper.getURL('dispatch.php/shared/log_event/get_log_autor');
$.post(
url,
{ mvv_field: 'mvv_' + mvv_type, mvv_id: mvv_id, log_action: 'new' },
onSuccess,
'json'
);
function onSuccess(data) {
if (data) {
var info = $gettextInterpolate(
$gettext('Hinzugefügt von %{user} am %{time}'),
data
);
curtable.attr('title', info);
const log = $('<ins class="difflog"/>').text(` [${info}] `);
const cell = $('<td/>').append(log);
const row = $('<tr/>').append(cell);
curtable.append(row);
}
}
});
});
$('.mvv-diff-deleted').each(function() {
$(this)
.find('table')
.each(function() {
if ($(this).attr('data-mvv-type')) {
var mvv_type = $(this).attr('data-mvv-type');
var mvv_id = $(this).attr('data-mvv-id');
var curtable = $(this);
} else {
return true;
}
var url = STUDIP.URLHelper.getURL('dispatch.php/shared/log_event/get_log_autor');
$.post(
url,
{ mvv_field: 'mvv_' + mvv_type, mvv_id: mvv_id, log_action: 'del' },
onSuccess,
'json'
);
function onSuccess(data) {
if (data) {
var info = $gettextInterpolate(
$gettext('Entfernt von %{user} am %{time}'),
data
);
curtable.attr('title', info);
const log = $('<del class="difflog"/>').text(` [${info}] `);
const cell = $('<td/>').append(log);
const row = $('<tr/>').append(cell);
curtable.append(row);
}
}
});
});
});
|