-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
143 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
function getHistHTML(hist) { | ||
|
||
let html = '', col, title; | ||
|
||
for (let h of hist) { | ||
if (h.Now != 0) { | ||
col = `fill:var(--bs-success);stroke:var(--bs-primary);`; | ||
} else { | ||
col = `fill:var(--bs-gray-500);stroke:var(--bs-primary);`; | ||
} | ||
title = `title="Date: ${h.Date}\nIface: ${h.Iface}\nIP: ${h.IP}\nKnown: ${h.Known}"`; | ||
|
||
html = html + `<i ${title}><svg width="10" height="20"> | ||
<rect width="10" height="20" style="${col}"/> | ||
Sorry, your browser does not support inline SVG. | ||
</svg></i>`; | ||
} | ||
return html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,60 @@ | ||
var addrsArray = {}; | ||
let show = 500; | ||
let addrsArray; | ||
|
||
loadAddrs(); | ||
|
||
function createHTML(addr, i) { | ||
let now = ''; | ||
|
||
if (addr.Now == 0) { | ||
now = `<i class="bi bi-circle-fill" style="color:var(--bs-gray-500);"></i>`; | ||
} else { | ||
now = `<i class="bi bi-check-circle-fill" style="color:var(--bs-success);"></i>`; | ||
} | ||
|
||
let html = ` | ||
<tr> | ||
<td style="opacity: 45%;">${i}.</td> | ||
<td>${addr.Name}</td> | ||
<td>${addr.Iface}</td> | ||
<td> | ||
<a href="http://${addr.IP}">${addr.IP}</a> | ||
</td> | ||
<td>${addr.Mac}</td> | ||
<td>${addr.Hw}</td> | ||
<td>${addr.Date}</td> | ||
<td>${addr.Known}</td> | ||
<td>${now}</td> | ||
</tr> | ||
`; | ||
async function loadAddrs() { | ||
|
||
return html; | ||
const n = localStorage.getItem("histShow"); | ||
if (n != null) { | ||
show = n; | ||
} | ||
|
||
const url = '/api/all'; | ||
addrsArray = await (await fetch(url)).json(); | ||
|
||
loadHistory(); | ||
} | ||
|
||
async function loadAddrs() { | ||
async function loadHistory() { | ||
|
||
let url = '/api/history'; | ||
let addrsMap = await (await fetch(url)).json(); | ||
if (addrsMap != null) { | ||
addrsArray = Object.values(addrsMap); | ||
let tr, td, url, hist; | ||
let i = 0; | ||
|
||
document.getElementById('showHist').innerHTML = ''; | ||
|
||
for (let a of addrsArray) { | ||
url = '/api/history/'+a.Mac; | ||
hist = await (await fetch(url)).json(); | ||
if (show > 0) { | ||
hist = hist.slice(0, show); | ||
} | ||
|
||
td = getHistHTML(hist); // hist-html.js | ||
i = i + 1; | ||
|
||
tr = ` | ||
<tr> | ||
<td style="opacity: 45%;">${i}.</td> | ||
<td> | ||
<p>${a.Name}</p> | ||
<p><a href="http://${a.IP}" target="blank">${a.IP}</a></p> | ||
<p><a href="/host/${a.ID}">${a.Mac}</a></p> | ||
</td> | ||
<td>${td}</td> | ||
</tr>`; | ||
|
||
document.getElementById('showHist').insertAdjacentHTML('beforeend', tr); | ||
} | ||
} | ||
|
||
displayArrayData(addrsArray); | ||
function showHist(n) { | ||
show = n; | ||
localStorage.setItem("histShow", show); | ||
loadHistory(); | ||
} | ||
|
||
function sortBy(field) { | ||
sortByAny(addrsArray, field); | ||
function manualShow() { | ||
const n = document.getElementById('man-show').value; | ||
showHist(n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.