Skip to content

Instantly share code, notes, and snippets.

@ionicpanda
Created October 3, 2018 21:16
Show Gist options
  • Save ionicpanda/51a37b36e0dfcd917ddce5411eb25d5a to your computer and use it in GitHub Desktop.
Save ionicpanda/51a37b36e0dfcd917ddce5411eb25d5a to your computer and use it in GitHub Desktop.
cb
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>Server Analyzer</title>
</head>
<body>
<div class = "container">
<h2>Server Analyzer</h2>
<form id="formid" action="/analyzeURL" method="POST">
<div class = "form-group">
<label for="url">URL:</label>
<input type="text" class="form-control" id="url" name="url" placeholder = "https://www.google.com:443" autofocus required>
</div>
<button class="btn btn-success" type="submit">Analyze</button>
</form>
</div>
<br />
<div class = "container">
<h3>Output</h3>
<textarea rows = "10" cols = "100" id="output" class = "form-control" readonly></textarea>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#formid").submit(function (event) {
event.preventDefault();
generateOutput();
});
});
function generateOutput() {
var url = {}
url["url"] = $("#url").val();
$.ajax({
type: "POST",
contentType: "application/json",
url: "/analyzeURL",
data: JSON.stringify(data),
dataType: 'json',
timeout: 100000,
success: function (data) {
console.log("SUCCESS: ", data);
display(data);
},
error: function (e) {
console.log("ERROR: ", e);
display(e);
},
done: function (e) {
console.log("DONE");
}
});
}
function enableSearchButton(flag) {
$("#btn-search").prop("disabled", flag);
}
function display(data) {
var json = "<h4>Ajax Response</h4><pre>"
+ JSON.stringify(data, null, 4) + "</pre>";
$('#feedback').html(json);
}
</script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment