2020-11-16 15:45:40 -05:00
|
|
|
<body>
|
|
|
|
<div id="status">Trying to find the right wiki page...</div>
|
|
|
|
<script>
|
|
|
|
const status_div = document.getElementById("status");
|
2024-09-15 14:39:31 -04:00
|
|
|
const asset_tag = window.location.pathname.slice(1);
|
2020-11-16 15:45:40 -05:00
|
|
|
|
|
|
|
fetch(
|
|
|
|
`https://wiki.claremontmakerspace.org/api.php?action=ask&query=[[Asset Tag::${asset_tag}]]&format=json&api_version=3&origin=*`
|
|
|
|
)
|
|
|
|
.then((r) => r.json())
|
|
|
|
.then((r) => {
|
|
|
|
if (r && r.query && r.query.results && r.query.results.length > 0) {
|
|
|
|
Object.entries(r.query.results[0]).forEach(([name, data]) => {
|
|
|
|
status_div.innerText = `Redirecting to Wiki Page for "${name}"...`;
|
|
|
|
window.location.assign(data.fullurl);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
throw new Error("No results for query!");
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
console.error(e);
|
|
|
|
|
|
|
|
status_div.innerText = "Failed to find an appropriate wiki page. ";
|
|
|
|
const link = status_div.appendChild(document.createElement("a"));
|
|
|
|
link.href =
|
|
|
|
"https://inventory.claremontmakerspace.org/hardware/bytag?assetTag=" +
|
|
|
|
asset_tag;
|
|
|
|
link.textContent = "Click here to go to the Inventory page";
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|