mirror of
https://github.com/redstrate/Auracite.git
synced 2025-05-02 00:47:45 +00:00
Fix the web version for the new API
This commit is contained in:
parent
8fe4a36a88
commit
c4b27b8a7b
2 changed files with 30 additions and 9 deletions
|
@ -392,3 +392,12 @@ pub async extern "C" fn archive_character_base64(
|
||||||
.map(|x| BASE64_STANDARD.encode(x))?;
|
.map(|x| BASE64_STANDARD.encode(x))?;
|
||||||
return Ok(format!("data:application/octet-stream;charset=utf-16le;base64,{buf}").into());
|
return Ok(format!("data:application/octet-stream;charset=utf-16le;base64,{buf}").into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_family = "wasm")]
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub async extern "C" fn search_for_character(name: &str) -> Option<u64> {
|
||||||
|
#[cfg(feature = "debug")]
|
||||||
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
|
search_character(name).await
|
||||||
|
}
|
||||||
|
|
|
@ -5,19 +5,31 @@
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>Auracite</title>
|
<title>Auracite</title>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init, {archive_character_base64} from "./pkg/auracite.js";
|
import init, {archive_character_base64, search_for_character} from "./pkg/auracite.js";
|
||||||
|
|
||||||
function archive() {
|
function archive() {
|
||||||
init().then(() => {
|
init().then(() => {
|
||||||
archive_character_base64(document.getElementById("name").value, document.getElementById("scales").checked).then((uri) => {
|
console.debug("Auracite initialized successfully!");
|
||||||
// Download character archive
|
|
||||||
var link = document.createElement('a');
|
let name = document.getElementById("name").value;
|
||||||
link.download = document.getElementById("name").value + ".zip";
|
|
||||||
link.href = uri;
|
search_for_character(name).then((id) => {
|
||||||
link.click();
|
console.debug("Lodestone id for " + name + ": " + id);
|
||||||
document.getElementById("statusMessage").innerText = "Archive complete!";
|
|
||||||
|
archive_character_base64(id, document.getElementById("scales").checked).then((uri) => {
|
||||||
|
console.debug("Archive complete!");
|
||||||
|
|
||||||
|
// Download character archive
|
||||||
|
var link = document.createElement('a');
|
||||||
|
link.download = name + ".zip";
|
||||||
|
link.href = uri;
|
||||||
|
link.click();
|
||||||
|
document.getElementById("statusMessage").innerText = "Archive complete!";
|
||||||
|
}).catch((err) => {
|
||||||
|
document.getElementById("statusMessage").innerText = err;
|
||||||
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
document.getElementById("statusMessage").innerText = err;
|
document.getElementById("statusMessage").innerText = "No character found!";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue