Skip to content
Browse files

Change statuscode

  • Loading branch information...
1 parent 7b75f80 commit e8531acf1da45cadc2bcde5bccb6b57e561dcc27 @gildean committed Sep 27, 2012
Showing with 112 additions and 40 deletions.
  1. +1 −1 package.json
  2. +61 −30 public/js/queries.js
  3. +43 −2 public/style.css
  4. +1 −1 server.js
  5. +1 −2 views/index.jade
  6. +5 −4 views/view.jade
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "dns-middleware-example",
- "version": "0.1.0-2",
+ "version": "0.1.0-51",
"description": "DNS-lookup middleware example for connect/express",
"homepage": "https://github.com/gildean/dns-middleware-example",
"keywords": [
View
91 public/js/queries.js
@@ -6,38 +6,69 @@ $(function () {
queryServer = $('input[name=server]'),
output = $('#queryoutput'),
status = $('#status'),
- lookuptime = $('#lookuptime');
+ lookuptime = $('#lookuptime'),
+ help = $('#help'),
+ inputelement = $('.inputelement');
+
+ $(document).ready(function () {
+ help.fadeOut(2500);
+ });
+
+ $(inputelement).hover(
+ function () {
+ var helptext = $(this).attr('name');
+ help.fadeOut(200, function () {
+ if (helptext === 'server' || helptext === 'type') {
+ help.text('Input ' + helptext + ' here').fadeIn(300);
+ } else {
+ help.text('Input ' + helptext + ' here (required)').fadeIn(300);
+ }
+ });
+ },
+ function () {
+ help.fadeOut(200);
+ }
+ );
queryform.submit(function (e) {
e.preventDefault();
- output.html('');
- status.text('Resolving!');
- if (query.val()) {
-
- $.post('/', {query: query.val(), type: queryType.val() || 'A', server: queryServer.val() || '8.8.8.8'}, function(data) {
- var obj = JSON.parse(data),
- i;
- status.text('Answer:');
- if (obj.answer.length === 0) {
- output.append('<p>No record found!</p>');
- } else {
- for (i = 0; i < obj.answer.length; i += 1) {
- output.append('<div class="resultbox" id="result' + i + '">');
- var resultBox = $('#result' + i);
- $.each(obj.answer[i], function(key, element) {
- var filterResult = key.toString();
- if (!(filterResult === 'type' || filterResult === 'class')) {
- resultBox.append('<p>' + key + ': ' + element + '</p>');
- }
- });
- };
- }
- lookuptime.text('Lookup time: ' + obj.time + 'ms');
- });
- } else {
- status.text('Enter a query first!');
- return false;
- }
+ output.fadeOut(500).html('').fadeIn(100);
+ status.fadeOut(200, function() {
+ $(this).text('Resolving!').fadeIn(200, function() {
+ if (query.val()) {
+ $.post('/', {query: query.val(), type: queryType.val() || 'A', server: queryServer.val() || '8.8.8.8'}, function(data) {
+ var obj = JSON.parse(data),
+ i;
+ status.fadeOut(200, function () {
+ $(this).text('Answer:');
+ $(this).fadeIn(200, function() {
+ if (obj.answer.length === 0) {
+ output.append('<p>No record found!</p>').hide().fadeIn(500);
+ } else {
+ for (i = 0; i < obj.answer.length; i += 1) {
+ output.append('<div class="resultbox" id="result' + i + '">');
+ var resultBox = $('#result' + i).hide().fadeIn(300);
+ $.each(obj.answer[i], function(key, element) {
+ var filterResult = key.toString();
+ if (!(filterResult === 'type' || filterResult === 'class')) {
+ resultBox.append('<p>' + key + ': ' + element + '</p>');
+ }
+ });
+ };
+ }
+ lookuptime.fadeOut(200, function () {
+ $(this).text('Lookup time: ' + obj.time + 'ms').fadeIn(200);
+ });
+ });
+ });
+ });
+ } else {
+ status.fadeOut(300, function () {
+ $(this).text('Enter a query first!').fadeIn(300);
+ return false;
+ });
+ }
+ });
+ });
});
-
});
View
45 public/style.css
@@ -44,15 +44,34 @@ body, html, #main {
margin: 0 2px;
}
+.inputelement {
+
+}
+
#queryinput {
position: relative;
left: 0;
top: 0;
z-index: 300;
}
+#status {
+ margin: 60px 0 0 10%;
+}
+
+#help {
+ width: 100%;
+ text-align: center;
+ margin: 10px 0 0;
+ padding: 10px 0;
+ background: #00CDCD;
+ color: #FFF;
+ text-shadow: -1px 1px 0 rgba(0,0,0,0.4);
+
+}
+
#queryoutput {
- margin: 60px auto;
+ margin: 10px auto;
width: 75%;
min-width: 250px;
}
@@ -62,6 +81,7 @@ body, html, #main {
border: 1px solid #EBECE4;
padding: 10px;
margin: 2px 0;
+ display: none;
}
#typeselect {
@@ -79,7 +99,7 @@ body, html, #main {
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
- width: 10%;
+ width: 12%;
min-width: 60px;
margin: 0 4px;
}
@@ -98,8 +118,29 @@ body, html, #main {
@media only screen
and (max-width : 767px) {
+* {
+ font: 102.5% Helvetica, DroidSans, Calibri, sans-serif;
+}
+
#header {
position: relative;
min-width: 250px;
+ height: 80px;
+ padding: 10px 0 0;
+}
+
+#pagetitle {
+ top: 40px;
}
+
+.button {
+ width: 25%;
+ margin: 5px;
+}
+
+.textinput {
+ width: 33%;
+ margin: 0 2px;
+}
+
}
View
2 server.js
@@ -18,7 +18,7 @@ app.post('/*', whois, function (req, res) {
});
app.use(function(req, res, next){
- res.send(420, 'Slow down bro.');
+ res.send(418, 'No java here.');
});
server.listen(3009);
View
3 views/index.jade
@@ -15,5 +15,4 @@ html
body
block content
script(src="/js/jquery.js")
- script(src="/js/jquery-ui.js")
- script(src="/js/queries.js")
+ script(src="/js/queries.js")
View
9 views/view.jade
@@ -7,10 +7,10 @@ block content
#queryinput
form(id="queryform")
span
- input.textinput(type="text", name="query", value="google.com", required)
+ input.textinput.inputelement(type="text", name="query", value="google.com", required)
span
- input.textinput(type="text", name="server", value="8.8.8.8")
- select#typeselect(name="type")
+ input.textinput.inputelement(type="text", name="server", value="8.8.8.8")
+ select#typeselect.inputelement(name="type")
option(value="A", selected) A
option(value="AAAA") AAAA
option(value="NS") NS
@@ -22,6 +22,7 @@ block content
option(value="SRV") SRV
span
input.button(type="submit", value="lookup")
+ #help hover inputs for help
+ #status
#queryoutput
- #status
#lookuptime

0 comments on commit e8531ac

Please sign in to comment.
Something went wrong with that request. Please try again.