improve code

This commit is contained in:
rofl256 2018-06-22 13:24:12 +02:00
parent 6003fa0f73
commit e236c1af5d
2 changed files with 22 additions and 31 deletions

View File

@ -137,25 +137,25 @@ function readFile(filename, callback) {
function getLocalIp() {
var os = require('os');
var ifaces = os.networkInterfaces();
var ifaces = os.networkInterfaces();
Object.keys(ifaces).forEach(function (ifname) {
var alias = 0;
Object.keys(ifaces).forEach(function (ifname) {
var alias = 0;
ifaces[ifname].forEach(function (iface) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return;
}
ifaces[ifname].forEach(function (iface) {
if ('IPv4' !== iface.family || iface.internal !== false) {
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return;
}
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
console.log(" http://"+iface.address+":"+webPort);
} else {
// this interface has only one ipv4 adress
console.log(" "+ifname+": ", "http://"+iface.address+":"+webPort);
}
++alias;
});
});
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
console.log(" http://"+iface.address+":"+webPort);
} else {
// this interface has only one ipv4 adress
console.log(" "+ifname+": ", "http://"+iface.address+":"+webPort);
}
++alias;
});
});
}

View File

@ -490,20 +490,11 @@ function addNewQuestion(frage) {
'<td>Frage:</td><td><input class="questionIn" type="text"></td>'+
'</tr><tr>'+
'<td>Kürzel:</td><td><input class="questionKIn" type="text"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 1:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 2:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 3:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 4:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 5:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr class="antTr">'+
'<td>Antwort 6:</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td>'+
'</tr><tr>'+
'</tr>'+
'</table></li>');
for(var i=1;i<7;i++) {
newQHtml.find("table").append('<tr class="antTr"><td>Antwort '+i+':</td><td><input class="antwortInp" type="text"><input class="anz" type="number" min="1" max="100"></td></tr>');
}
if(frage != null) {
newQHtml.find(".questionIn").val(frage["frage"]);
newQHtml.find(".questionKIn").val(frage["kuerzel"]);