mirror of
https://github.com/ervanalb/keygen.git
synced 2025-12-17 21:55:32 +00:00
3d preview of key working
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
keygen_endpoint = "http://localhost:8080"; // Change me to your serve.py endpoint
|
||||
|
||||
var key_metadata;
|
||||
var key_stl;
|
||||
|
||||
function populate_types() {
|
||||
$.getJSON( keygen_endpoint, function( data ) {
|
||||
@@ -43,7 +44,41 @@ function populate_outlines_wardings() {
|
||||
});
|
||||
}
|
||||
|
||||
function generate_key() {
|
||||
$("#generated_key").hide();
|
||||
$("#generate_button").prop("disabled", true);
|
||||
$("#please_wait").show();
|
||||
get_data = $.param({
|
||||
"key": $("#key_type").val(),
|
||||
"outline": $("#key_outline").val(),
|
||||
"warding": $("#key_warding").val(),
|
||||
"bitting": $("#key_bitting").val(),
|
||||
});
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", keygen_endpoint + "?" + get_data, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
|
||||
xhr.onload = function(e) {
|
||||
if (this.status == 200) {
|
||||
key_stl = this.response;
|
||||
preview_load(key_stl);
|
||||
preview_animate();
|
||||
$("#generated_key").show();
|
||||
} else {
|
||||
alert("An error occurred");
|
||||
}
|
||||
$("#please_wait").hide();
|
||||
$("#generate_button").prop("disabled", false);
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#key_type").on("change", populate_outlines_wardings);
|
||||
$("#key_form").submit(function(e) {generate_key(); e.preventDefault();});
|
||||
|
||||
populate_types();
|
||||
preview_init();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user