Newer
Older
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
$.ajaxSetup({
async: false
});
//Umwandlung von dezimal zu hexadezimal
function dec2hex(dec) {
var hex = "";
if (dec < 0) {
dec = 0xFFFFFFFF + dec + 1;
}
hex = parseInt(dec, 10).toString(16);
return hex;
}
//Berechne den Farbwert (z.B.: #FFFFFF) fuer gegebene Fehlerwerte
function calcColor(fehler, maxFehler) {
//console.log("Farbe Fehler: " + fehler + " Max: " + maxFehler);
var part = 0;
if (fehler != 0) {
var x = 255/Math.log(maxFehler);
part = x*Math.log(fehler);
}
//console.log("Farbe Fehler: " + fehler + " Max: " + maxFehler + " Part: " + part);
var hex = dec2hex(255-part);
//console.log("Farbe Fehler: " + fehler + " Max: " + maxFehler + " Part: " + part + " Farbcode: " + ("#FF" + hex + hex));
if (hex >= 0 && hex <= 9 ) {
return "#FF" + hex + hex + hex + hex;
} else {
return "#FF" + hex + hex;
}
}
//Tooltip für Instruktionszeilen mit Fehler
$('body').popover({
selector: ".hasFehler",
html: true,
title: function() { return $(this).attr("id"); },
content: function() {
var ausgabe = '';
var caller = $(this);
$.getJSON("core.php", {kommando: 'getResultTypes'}, function(data) {
$.each(data, function(key, val) {
ausgabe = ausgabe + val +': ' + caller.attr(val) + '<br>';
});
});
return ausgabe;
}
});
//Einblenden des Modal "Loading" fuer Ajax Requests
/*$(document).ajaxStart(function(){
//console.log("ajaxstart");
$("body").addClass("loading");
}).ajaxStop(function(){
//console.log("ajaxstop");
$("body").removeClass("loading");
});*/
//User-Interaktionen nachdem das DOM geladen ist
$(document).ready(function() {
//DB check
$.getJSON("core.php", {kommando: 'dbTest'}, function(data) {
if(data != "ok") {
$('html').html(data);
}
});
//Holen der Binarys, die in der DB in der Tabelle Variant vorkommen
$.getJSON("core.php", {kommando: 'getBinarys'}, function(data) {
$.each(data, function(key, val) {
$('#binary').append('<option value="' + val + '">' + val + '</option>');
});
});
//Auswahl eines Eintrages aus den Source-Files für die Darstellung des Hochsprachencode
$('#sourceFiles').change(function() {
if($(this).val() != 'none') {
$.getJSON("core.php", {kommando: 'getHighlevelCode', variant_id: $('#variant').val(), file_id: $(this).val(), version: $('#faerbung').val()}, function(data) {
$('#hcode').html(data);
$('.maxFehlerMapping').on( "calcColor", function( event, newMaxFehler, activeFehlertypes) {
var newFehler = 0;
var actualRow = $(this);
$.each(activeFehlertypes, function(key, val) {
newFehler = newFehler + parseInt(actualRow.attr(val));
});
console.log("jepp" + newMaxFehler + " " + newFehler);
$(this).prev().prev().prev().css("background-color", calcColor(newFehler, newMaxFehler))
.css('cursor', 'pointer');
});
$('.hasFehler').on( "calcColor", function( event, newMaxFehler, activeFehlertypes) {
var newFehler = 0;
var actualRow = $(this);
$.each(activeFehlertypes, function(key, val) {
newFehler = newFehler + parseInt(actualRow.attr(val));
});
$(this).css("background-color", calcColor(newFehler, newMaxFehler))
.css('cursor', 'pointer');
});
});
setTimeout(function(){
var activeFehlertypes = new Array();
var newMaxFehler = 0;
$('#fehlertypenset > .active').each(function(){
activeFehlertypes.push($(this).attr("id"));
//console.log("Hinzugefuegt: " + $(this).attr("id"));
});
$.each(activeFehlertypes,function(key, name){
//Neuen MaxFehler berechnen
newMaxFehler = newMaxFehler + parseInt($('#maxFehler').attr(name));
});
$('.hasFehler').trigger('calcColor', [ newMaxFehler, activeFehlertypes ]);
$('.maxFehlerMapping').trigger('calcColor', [ newMaxFehler, activeFehlertypes ]);
},100);
}
});
//Auswahl eines Eintrages aus den Binarys für die Darstellung des Assembler-Code
$('#binary').change(function() {
if($(this).val() != 'none') {
$('#variant').html('<option value="none" selected="selected"></option>');
$.getJSON("core.php", {kommando: 'getVariants', datei: $(this).val()}, function(data) {
$.each(data, function(key, val) {
$('#variant').append('<option value="' + key + '">' + val + '</option>');
});
});
}
});
//Analyse Button wird gedrueckt
$('#analyse').button().click( function () {
$.getJSON("core.php", {kommando: 'getAsmCode', variant_id: $('#variant').val(), version: $('#faerbung').val()}, function(data) {
$('#asm').html(data);
});
$.getJSON("core.php", {kommando: 'getSourceFiles', variant: $('#variant').val()}, function(data) {
$.each(data, function(key, val) {
$('#sourceFiles').append('<option value="' + key + '">' + val + '</option>');
});
});
$.getJSON("core.php", {kommando: 'getResultTypes'}, function(data) {
$('#fehlertypenset').html('');
$.each(data, function(key, val) {
$('#fehlertypenset').append('<label class="btn btn-default" id="' + val + '"><input type="checkbox" id="' + val + '">' + val + '</label>');
//$('#'+ val +'.btn').button('toggle');
});
$('.hasFehler').on( "calcColor", function( event, newMaxFehler, activeFehlertypes) {
var newFehler = 0;
var actualRow = $(this);
$.each(activeFehlertypes, function(key, val) {
newFehler = newFehler + parseInt(actualRow.attr(val));
});
$(this).css("background-color", calcColor(newFehler, newMaxFehler))
.css('cursor', 'pointer');
});
//Auf Änderungen bzgl. des Fehler-Buttonset horchen
$('#fehlertypenset input[type=checkbox]').change(function() {setTimeout(function(){
//console.log("aenderung!");
var activeFehlertypes = new Array();
var newMaxFehler = 0;
$('#fehlertypenset > .active').each(function(){
activeFehlertypes.push($(this).attr("id"));
});
$.each(activeFehlertypes,function(key, name){
//Neuen MaxFehler berechnen
newMaxFehler = newMaxFehler + parseInt($('#maxFehler').attr(name));
});
$('.hasFehler').trigger('calcColor', [ newMaxFehler, activeFehlertypes ]);
$('.maxFehlerMapping').trigger('calcColor', [ newMaxFehler, activeFehlertypes ]);
},100)});
});
});
});