Skip to content
Browse files

New jquery

  • Loading branch information...
1 parent 3df0ff5 commit d1e026a20d2d957302c04b121e62117e3b167656 @gildean committed Aug 7, 2012
Showing with 41 additions and 22 deletions.
  1. +14 −18 app.js
  2. +10 −1 content/index.html
  3. +17 −3 content/style.css
View
32 app.js
@@ -42,13 +42,17 @@ window.on('ready', function(){
$label = $info.find('span'),
$buttons = $('input, button'),
$results = $('#resultsbox'),
+ $placeholder = $('#placeholder'),
$footer = $('#footer'),
- $footerlabel = $footer.find('span');
+ $footerlabel = $footer.find('span'),
+ $error = $('#error'),
+ $errorlabel = $error.find('span');
$label.text('Select target and blast!');
$footerlabel.text('blaster by: ok 2012');
$('#blaster-form').submit(function(e){
e.preventDefault();
+ $placeholder.css('display', 'none');
$label.text('Blasting!');
$buttons.attr('disabled', true);
var target = $target.val() || 'http://localhost',
@@ -60,9 +64,7 @@ window.on('ready', function(){
port: url.parse(target).port,
path: url.parse(target).path
};
- var Data={};
- var Status=new Array();
- Status.push('<h2>Blasted: ' + target + ' ' + ammo + ' times</h2>');
+ $('<h2>Blasted: ' + target + ' ' + ammo + ' times</h2>').appendTo($results);
var startTime = Date.now();
for(var i = 1; i <= ammo; i++) {
@@ -72,36 +74,30 @@ window.on('ready', function(){
function blaster(i) {
var req = http.get(options, function(res) {
if (i%100===0) {
- Status.push('Request: ' + i + ' STATUS: ' + res.statusCode);
+ $('<p>Request: ' + i + ' STATUS: ' + res.statusCode + '</p>').appendTo($results);
+ $footerlabel.text('Blasting: ' + ((i/ammo)*100).toFixed(1) + ' %');
}
if (i == ammo) {
var endTime = Date.now();
var blastTime = (endTime - startTime)/1000;
- $footerlabel.text('Blasting lasted: ' + blastTime.toFixed(1) + ' s');
- Data=JSON.stringify(Status);
- Data=eval(Data).join(",")
- Data= Data.replace(/,/g,'<p>');
- blastedOut(Data);
+ blastedOut(blastTime);
}
}).on('error', function(e) {
- Status.push('Request: ' + i + ' ERROR: ' + e.message);
+ $('<p>Request: ' + i + ' ERROR: ' + e.message + '</p>').appendTo($results);
if (i == ammo) {
var endTime = Date.now();
var blastTime = (endTime - startTime)/1000;
- $footerlabel.text('ERROR! ERROR! ERROR!');
- Data=JSON.stringify(Status);
- Data=eval(Data).join(",")
- Data= Data.replace(/,/g,'<p>');
- blastedOut(Data, blastTime);
+ $errorlabel.text('ERROR! ERROR! ERROR!');
+ blastedOut(blastTime);
}
});
};
});
- function blastedOut(Data){
+ function blastedOut(blastTime){
$label.text('Ceasefire called');
- $results.html(Data);
$buttons.attr('disabled', false);
+ $footerlabel.text('Blasting lasted: ' + blastTime.toFixed(1) + ' s');
};
});
View
11 content/index.html
@@ -9,13 +9,19 @@
<div id="container">
<header>
<h1>blaster</h1>
+ <button id="delbutton" class="bton">clear</button>
+ <script>
+ $("#delbutton").click(function () {
+ $("#resultsbox").empty();
+ });
+ </script>
</header>
<div id="blastingbox">
<form action="/" method="POST" id="blaster-form">
<input id="target" name="target" type="text" placeholder="URL"/>
<input id="ammo" name="ammo" type="number" placeholder="ammo"/>
<input id="caliber" name="caliber" type="number" placeholder="caliber"/>
- <button type="submit" class="button">blast</button>
+ <button type="submit" class="bton">blast</button>
</form>
<label id="info-target">
<span></span>
@@ -26,6 +32,9 @@
<p id="results"></p>
</div>
<footer>
+ <label id="error">
+ <span></span>
+ </label>
<label id="footer">
<span></span>
</label>
View
20 content/style.css
@@ -50,7 +50,7 @@ input {
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
-.button {
+.bton {
color: #fff;
background-color: #0e0e0e;
box-shadow: inset 0 0 2px #FF3380;
@@ -64,7 +64,7 @@ input {
-webkit-transition: all .3s ease-in-out;
}
-.button:hover {
+.bton:hover {
box-shadow: inset 0 0 100px #FF3380;
cursor: pointer;
}
@@ -120,8 +120,22 @@ footer {
text-align: right;
}
-#footer {
+#footer, #error {
color: #fff;
font-size: 0.9em;
padding: 0 10px;
}
+
+#error {
+float: left;
+}
+
+#delbutton {
+ position: absolute;
+ top: 5px;
+ right: 10px;
+ padding: 5px 15px;
+ width: 100px;
+ border-radius: 0.5em;
+ font-size: 1em;
+}

0 comments on commit d1e026a

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