()
| 1113 | } |
| 1114 | |
| 1115 | function createLayout() { |
| 1116 | console.log("createLayout: Function called"); |
| 1117 | console.log("createLayout: SERVER object:", SERVER); |
| 1118 | |
| 1119 | // Check if SERVER object has required data |
| 1120 | if (!SERVER || !SERVER["clientInfo"]) { |
| 1121 | console.log("createLayout: Proceeding without clientInfo; rendering menu skeleton"); |
| 1122 | } |
| 1123 | |
| 1124 | console.log("createLayout: Proceeding with menu creation"); |
| 1125 | console.log("createLayout: clientInfo keys:", getObjKeys(SERVER["clientInfo"])); |
| 1126 | |
| 1127 | // Client Info (only if available) |
| 1128 | if (SERVER && SERVER["clientInfo"]) { |
| 1129 | var obj = SERVER["clientInfo"] |
| 1130 | var keys = getObjKeys(obj); |
| 1131 | console.log("createLayout: clientInfo keys:", keys); |
| 1132 | console.log("createLayout: clientInfo values:", obj); |
| 1133 | |
| 1134 | for (var i = 0; i < keys.length; i++) { |
| 1135 | var elementId = keys[i]; |
| 1136 | var element = document.getElementById(elementId); |
| 1137 | if (element) { |
| 1138 | console.log("createLayout: Setting element", elementId, "to value:", obj[elementId]); |
| 1139 | (<HTMLInputElement>element).value = obj[elementId]; |
| 1140 | } else { |
| 1141 | console.log("createLayout: Element not found for ID:", elementId); |
| 1142 | } |
| 1143 | } |
| 1144 | } else { |
| 1145 | console.log("createLayout: No clientInfo available in SERVER object"); |
| 1146 | console.log("createLayout: SERVER object:", SERVER); |
| 1147 | } |
| 1148 | |
| 1149 | if (SERVER && SERVER["clientInfo"] && document.getElementById("playlist-connection-information")) { |
| 1150 | let activeClass = "text-primary" |
| 1151 | if (SERVER["clientInfo"]["activePlaylist"] / SERVER["clientInfo"]["totalPlaylist"] >= 0.6 && SERVER["clientInfo"]["activePlaylist"] / SERVER["clientInfo"]["totalPlaylist"] < 0.8) { |
| 1152 | activeClass = "text-warning" |
| 1153 | } else if (SERVER["clientInfo"]["activePlaylist"] / SERVER["clientInfo"]["activePlaylist"] >= 0.8) { |
| 1154 | activeClass = "text-danger" |
| 1155 | } |
| 1156 | document.getElementById("playlist-connection-information").innerHTML = "Playlist Connections: <span class='" + activeClass + "'>" + SERVER["clientInfo"]["activePlaylist"] + " / " + SERVER["clientInfo"]["totalPlaylist"] + "</span>" |
| 1157 | } |
| 1158 | |
| 1159 | if (SERVER && SERVER["clientInfo"] && document.getElementById("client-connection-information")) { |
| 1160 | let activeClass = "text-primary" |
| 1161 | if (SERVER["clientInfo"]["activeClients"] / SERVER["clientInfo"]["totalClients"] >= 0.6 && SERVER["clientInfo"]["activeClients"] / SERVER["clientInfo"]["totalClients"] < 0.8) { |
| 1162 | activeClass = "text-warning" |
| 1163 | } else if (SERVER["clientInfo"]["activeClients"] / SERVER["clientInfo"]["totalClients"] >= 0.8) { |
| 1164 | activeClass = "text-danger" |
| 1165 | } |
| 1166 | document.getElementById("client-connection-information").innerHTML = "Client Connections: <span class='" + activeClass + "'>" + SERVER["clientInfo"]["activeClients"] + " / " + SERVER["clientInfo"]["totalClients"] + "</span>" |
| 1167 | } |
| 1168 | |
| 1169 | if (!document.getElementById("main-menu")) { |
| 1170 | console.log("createLayout: main-menu element not found, returning"); |
| 1171 | return |
| 1172 | } |
no test coverage detected