| 121 | "10.0.0.48", "10.0.0.47", "10.0.0.46"].forEach((addr, i) => hosts[addr] = screen(i)) |
| 122 | |
| 123 | class Screens { |
| 124 | constructor() { |
| 125 | this.getParent() |
| 126 | let doc = this.parent.ownerDocument |
| 127 | this.dom = this.parent.appendChild(doc.createElement("div")) |
| 128 | this.dom.style.cssText = "position: relative; max-width: 500px" |
| 129 | let inner = this.dom.appendChild(doc.createElement("div")) |
| 130 | inner.style.cssText = "position: relative; width: 100%; padding-bottom: 60%" |
| 131 | this.screens = [] |
| 132 | for (let i = 0; i < 9; i++) { |
| 133 | let screen = inner.appendChild(doc.createElement("div")) |
| 134 | let row = Math.floor(i / 3), col = i % 3 |
| 135 | screen.style.cssText = "border: 1px solid #222; background: black; position: absolute; width: 33.3%; height: 33.3%; left: " + (col * 33.3) + "%; top: " + (row * 33.3) + "%" |
| 136 | let canvas = screen.appendChild(doc.createElement("canvas")) |
| 137 | canvas.style.cssText = "width: 100%; height: 100%" |
| 138 | this.screens.push(canvas) |
| 139 | } |
| 140 | this.screens.forEach(c => { c.width = c.offsetWidth; c.height = c.offsetHeight }) |
| 141 | } |
| 142 | |
| 143 | getParent() { |
| 144 | this.parent = window.__sandbox ? window.__sandbox.output.div : document.body |
| 145 | } |
| 146 | |
| 147 | update(n, data) { |
| 148 | this.getParent() |
| 149 | if (!this.parent.ownerDocument.body.contains(this.dom)) this.parent.appendChild(this.dom) |
| 150 | |
| 151 | let canvas = this.screens[n], cx = canvas.getContext("2d") |
| 152 | cx.clearRect(0, 0, canvas.width, canvas.height) |
| 153 | let gapX = (canvas.width * 0.4) / 51, sizeX = (canvas.width * 0.6) / 50, skipX = gapX + sizeX |
| 154 | let gapY = (canvas.height * 0.4) / 31, sizeY = (canvas.height * 0.6) / 30, skipY = gapY + sizeY |
| 155 | for (let i = 0, col = 0, row = 0; i < 1500; i++) { |
| 156 | let pixel = data[i] |
| 157 | if (pixel) { |
| 158 | cx.fillStyle = pixel == 3 ? "#fd4" : pixel == 2 ? "#a82" : "#741" |
| 159 | cx.fillRect(gapX + col * skipX, gapY + row * skipY, sizeX, sizeY) |
| 160 | } |
| 161 | if (col == 49) { col = 0; row++ } |
| 162 | else { col++ } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | let screens = null |
| 167 | |
| 168 | return function request(address, content) { |
nothing calls this directly
no outgoing calls
no test coverage detected