change plain text questions to base64 so the server will run on linux aswell
This commit is contained in:
parent
0d0561bd76
commit
cab717d18b
File diff suppressed because one or more lines are too long
@ -234,7 +234,7 @@ function loadQuestionToGui(index) {
|
||||
$("#schweinchenImg").hide();
|
||||
$("#answers").empty();
|
||||
if(index > -1) {
|
||||
$("#frageDiv").text("Frage: "+fragen[index]["frage"]);
|
||||
$("#frageDiv").html("Frage: "+fragen[index]["frage"]);
|
||||
for(var i=0;i<fragen[index]["antworten"].length;i++) {
|
||||
if(fragen[index]["antworten"][i]["antwort"] != "") {
|
||||
var oneLine = $('<div style="height:55px">'+
|
||||
@ -328,22 +328,43 @@ function saveQuestions() {
|
||||
var objToSave = [];
|
||||
$.each($("#fragenListe").find("li"), function() {
|
||||
var oneQ = {
|
||||
"frage" : $(this).find(".questionIn").val(),
|
||||
"kuerzel" : $(this).find(".questionKIn").val(),
|
||||
"frage" : replaceSomeCharactersInHtml($(this).find(".questionIn").val()),
|
||||
"kuerzel" : replaceSomeCharactersInHtml($(this).find(".questionKIn").val()),
|
||||
"antworten" : []
|
||||
};
|
||||
$.each($(this).find(".antTr"),function() {
|
||||
oneQ["antworten"].push({
|
||||
"antwort" : $(this).find(".antwortInp").val(),
|
||||
"anz" : $(this).find(".anz").val()
|
||||
"antwort" : replaceSomeCharactersInHtml($(this).find(".antwortInp").val()),
|
||||
"anz" : replaceSomeCharactersInHtml($(this).find(".anz").val())
|
||||
});
|
||||
});
|
||||
objToSave.push(oneQ);
|
||||
});
|
||||
var jsonQues = JSON.stringify(objToSave);
|
||||
jsonQues = btoa(jsonQues);
|
||||
wsSend("fileOp","write###fragen.txt###"+jsonQues);
|
||||
}
|
||||
|
||||
function replaceSomeCharactersInHtml(str) {
|
||||
str = str.replace(/Ü/g, "Ü");
|
||||
str = str.replace(/ü/g, "ü");
|
||||
str = str.replace(/Ö/g, "Ö");
|
||||
str = str.replace(/ö/g, "ö");
|
||||
str = str.replace(/Ä/g, "Ä");
|
||||
str = str.replace(/ä/g, "ä");
|
||||
return str;
|
||||
}
|
||||
|
||||
function replaceSomeCharactersInStd(str) {
|
||||
str = str.replace(/Ü/g, "Ü");
|
||||
str = str.replace(/ü/g, "ü");
|
||||
str = str.replace(/Ö/g, "Ö");
|
||||
str = str.replace(/ö/g, "ö");
|
||||
str = str.replace(/Ä/g, "Ä");
|
||||
str = str.replace(/ä/g, "ä");
|
||||
return str;
|
||||
}
|
||||
|
||||
function addNewQuestion(frage) {
|
||||
var newQHtml = $('<li style="list-style-type: none; padding: 5px; border: 1px solid black; margin-right: 80px; position: relative;"><i style="cursor:pointer; position: absolute; right: 5px;" class="fa fa-trash-o trash"></i><table>'+
|
||||
'<tr>'+
|
||||
@ -365,11 +386,11 @@ function addNewQuestion(frage) {
|
||||
'</tr><tr>'+
|
||||
'</table></li>');
|
||||
if(frage != null) {
|
||||
newQHtml.find(".questionIn").val(frage["frage"]);
|
||||
newQHtml.find(".questionKIn").val(frage["kuerzel"]);
|
||||
newQHtml.find(".questionIn").val(replaceSomeCharactersInStd(frage["frage"]));
|
||||
newQHtml.find(".questionKIn").val(replaceSomeCharactersInStd(frage["kuerzel"]));
|
||||
for(var i=0;i<frage["antworten"].length;i++) {
|
||||
$(newQHtml.find(".antwortInp")[i]).val(frage["antworten"][i]["antwort"]);
|
||||
$(newQHtml.find(".anz")[i]).val(frage["antworten"][i]["anz"]);
|
||||
$(newQHtml.find(".antwortInp")[i]).val(replaceSomeCharactersInStd(frage["antworten"][i]["antwort"]));
|
||||
$(newQHtml.find(".anz")[i]).val(replaceSomeCharactersInStd(frage["antworten"][i]["anz"]));
|
||||
}
|
||||
}
|
||||
newQHtml.find(".trash").click(function() {
|
||||
|
@ -104,7 +104,8 @@ var connectWs = function() {
|
||||
} else if(key == "file") {
|
||||
if(value == "fragen.txt") {
|
||||
try {
|
||||
fragen = JSON.parse(messageParts_a[2]);
|
||||
var base64 = atob(messageParts_a[2]);
|
||||
fragen = JSON.parse(base64);
|
||||
fillFragenEditor();
|
||||
fillFragenSelect();
|
||||
} catch(e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user