forked from ntoulasd/Linux-pc-debugger-project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
86 lines (82 loc) · 3.53 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<style>.highlight{background-color: yellow}</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function create_table() {
var data = $.mydata.text.split(/\n/);
var html = '<div id="result" style="display:none">\n<table id="questions">\n';
for(var j = 0; j < data.length; j += 1) {
var dataFields = data[j].split('#');
if (dataFields[1] != null
&& dataFields[1] != '" "') {
q = '^"'+$.mydata.currentkey+'\\.[0-9]*"';
c = $.mydata.currentkey;
d1 = dataFields[1];
//first pass
if (c == "") { if (d1[2] == '.') { continue; } }
else if (!(d1.match(new RegExp(q, 'i')))) { continue; }
var k=dataFields[1].replace(/\"/g,'');
var v=dataFields[2];
html += '<tr>\n';
html += '<td>\n<input class="replies" type="button" value="' + k + '" name="' + k + '" />\n</td>\n';
html += '<td>\n' + v + '\n</td>\n';
html += '</tr>\n';
}
}
html += '</table>\n</div>\n';
console.log(html);
if (html == '<div id="result" style="display:none">\n<table id="questions">\n</table>\n</div>\n') {
html = '<div id="result" style="display:none"><table id="questions">\n<tr>\n<td>\nΔεν υπάρχουν περαιτέρω βήματα.</td>\n</tr>\n</table>\n</div>\n';
}
//$(html).appendTo('body');
$('#answers').append(html);
$("tr:even").css("background-color", "#C2E053");
$("tr:odd").css("background-color", "#E2E3DE");
$("#result").show('slow');
$(".replies").attr('onclick','$.mydata.currentkey = $(this).attr("name"); recreate_table();');
}
function recreate_table() {
$("#result").hide('slow', function () {
$(this).remove();
create_table();
});
}
function begin_again() {
$.mydata.currentkey = "";
recreate_table();
}
function go_back() {
//Remove last ".number"
$.mydata.currentkey = $.mydata.currentkey.replace(/(\.[0-9]*)$/, '');
recreate_table();
}
$(document).ready(function() {
$.mydata = {file: "data.csv", text: "", currentkey: ""};
if ($.mydata.text == "") { //Text not set! Reading from file
$.ajax({
url: $.mydata.file,
beforeSend: function(xhr) {
xhr.overrideMimeType('text/plain; charset=UTF-8');
},
async: false, //wait until it's finished
success: function(data) {
$.mydata.text = data.slice(0);
}
});
}
function main() { create_table(); }
main();
});
</script>
</head>
<body>
<div id="menu">
<input type="button" value="Άρχισε ξανά" onclick="begin_again();" />
<input type="button" value="Πήγαινε πίσω" onclick="go_back();" />
</div>
<div id="answers">
</div>
</body>
</html>