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

View File

@ -490,20 +490,11 @@ function addNewQuestion(frage) {
'<td>Frage:</td><td><input class="questionIn" type="text"></td>'+ '<td>Frage:</td><td><input class="questionIn" type="text"></td>'+
'</tr><tr>'+ '</tr><tr>'+
'<td>Kürzel:</td><td><input class="questionKIn" type="text"></td>'+ '<td>Kürzel:</td><td><input class="questionKIn" type="text"></td>'+
'</tr><tr class="antTr">'+ '</tr>'+
'<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>'+
'</table></li>'); '</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) { if(frage != null) {
newQHtml.find(".questionIn").val(frage["frage"]); newQHtml.find(".questionIn").val(frage["frage"]);
newQHtml.find(".questionKIn").val(frage["kuerzel"]); newQHtml.find(".questionKIn").val(frage["kuerzel"]);