From e236c1af5ded72282b95fadd6072e392573ff89e Mon Sep 17 00:00:00 2001 From: rofl256 Date: Fri, 22 Jun 2018 13:24:12 +0200 Subject: [PATCH] improve code --- server/server.js | 36 ++++++++++++++++++------------------ web/js/main.js | 17 ++++------------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/server/server.js b/server/server.js index 76872b3..d2314a5 100644 --- a/server/server.js +++ b/server/server.js @@ -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; + }); + }); } diff --git a/web/js/main.js b/web/js/main.js index 2ed26ba..db4aa9b 100644 --- a/web/js/main.js +++ b/web/js/main.js @@ -490,20 +490,11 @@ function addNewQuestion(frage) { 'Frage:'+ ''+ 'Kürzel:'+ - ''+ - 'Antwort 1:'+ - ''+ - 'Antwort 2:'+ - ''+ - 'Antwort 3:'+ - ''+ - 'Antwort 4:'+ - ''+ - 'Antwort 5:'+ - ''+ - 'Antwort 6:'+ - ''+ + ''+ ''); + for(var i=1;i<7;i++) { + newQHtml.find("table").append('Antwort '+i+':'); + } if(frage != null) { newQHtml.find(".questionIn").val(frage["frage"]); newQHtml.find(".questionKIn").val(frage["kuerzel"]);