No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

domain_check.html 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% extends "base.html" %}
  2. {% load staticfiles %}
  3. {% block content %}
  4. <div class="row">
  5. <div class="col-sm-12">
  6. <div class="panel panel-default">
  7. <div class="panel-heading">Checking domain {{ domain.name }}</div>
  8. <div class="panel-body">
  9. <div id="dnscontent">
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. <script>
  16. function addMessage(div, level, message) {
  17. $(div).html($(div).html() + ' <div role="alert" class="alert alert-'+level+' alert-dismissible"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> '+message+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
  18. }
  19. function addRecord(d, key, title) {
  20. var msg = "";
  21. if(d[key].length > 0) {
  22. msg += "\n<p>" + title + ":<ul>";
  23. for(var i=0; i<d[key].length; i++)
  24. msg += "<li>" + d[key][i].join(" ") + "</li>";
  25. msg += "</ul></p>";
  26. }
  27. return msg;
  28. }
  29. $(document).ready(function() {
  30. $("#dnscontent").text("Running API request...");
  31. $.get({
  32. url: "{% url "api:domain-check" %}",
  33. data: {domain: "{{ domain.name }}"},
  34. beforeSend: function() {
  35. $("#dnscontent").html('<img src="{% static "img/loader.gif" %}">');
  36. },
  37. success: function(data) {
  38. $("#dnscontent").html("<p>Checked domain: " + data.domain + "</p>");
  39. if(data.success) {
  40. for(message of data.result) {
  41. var level = "success";
  42. if(message[0] == "err")
  43. level = "danger";
  44. var msg = message[1];
  45. if(message.length > 2) {
  46. var d = message[2];
  47. msg += addRecord(d, "nameMissing", "Missing names");
  48. msg += addRecord(d, "rrExtra", "Extra records");
  49. msg += addRecord(d, "rrMissing", "Missing records");
  50. //console.log(d);
  51. //if(d["rrMissing"].length > 0) {
  52. // msg += "\n<p>Missing records:<ul>";
  53. // for(var i=0; i<d["rrMissing"].length; i++)
  54. // msg += "<li>" + d["rrMissing"][i].join(" ") + "</li>";
  55. // msg += "</ul></p>";
  56. //}
  57. }
  58. addMessage("#dnscontent", level, msg);
  59. }
  60. } else {
  61. addMessage("#dnscontent", "danger", "Could not get DNS data from API!");
  62. }
  63. }
  64. });
  65. });
  66. </script>
  67. {% endblock %}