Last active
December 18, 2015 08:59
-
-
Save kristopolous/5757818 to your computer and use it in GitHub Desktop.
quick post scrpit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<style> | |
textarea,input { width: 600px} | |
iframe { width: 800px; height: 300px} | |
span { display:inline-block; width: 100px;vertical-align:top} | |
</style> | |
</head> | |
<body> | |
<form method="get" action="post.html" id="form"> | |
<button type="submit">post</button> | |
</form> | |
<div id="urldone"></div> | |
<div id='posttime'></div> | |
<div> <iframe id="result"></iframe> </div> | |
<div id='nowtime'></div> | |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
</body> | |
<script> | |
function gq(variable) { | |
var query = window.location.search.substring(1); | |
var vars = query.split('&'); | |
for (var i = 0; i < vars.length; i++) { | |
var pair = vars[i].split('='); | |
if (decodeURIComponent(pair[0]) == variable) { | |
return decodeURIComponent(pair[1]); | |
} | |
} | |
return ""; | |
} | |
setInterval(function(){ | |
var newnow = new Date(); | |
$("#nowtime").html("Current time: " + (new Date()).toLocaleString() + "<br><b>Delta: </b>" + ((newnow - start) / 1000).toFixed(0) + " s."); | |
}, 1000); | |
var start, end; | |
$(function(){ | |
start=new Date(); | |
$("#posttime").html("Start time: " + start.toLocaleString()); | |
'payload url header'.split(' ').forEach(function(w) { | |
$('<div><span>' + w + '</span></div>').append( | |
$("<input />") | |
.attr({ | |
id: w, | |
name: w | |
}) | |
.val(gq(w)) | |
).prependTo('#form'); | |
}); | |
if(window.location.search.length) { | |
document.title = $("#url").val() + ":" + $("#payload").val(); | |
$("#urldone").html(document.title); | |
var | |
myRequest = new XMLHttpRequest(), | |
header = $("#header").val(); | |
myRequest.onreadystatechange = function(){ | |
if(myRequest.readyState === 4) { | |
document.getElementById("result").contentWindow.document.body.innerHTML = myRequest.response; | |
} | |
} | |
myRequest.open('POST', $("#url").val(), true); | |
if(header) { | |
header = header.split(':'); | |
myRequest.setRequestHeader(header[0], $.trim(header[1])); | |
} | |
myRequest.send($("#payload").val()); | |
} | |
}); | |
</script> |
Author
kristopolous
commented
Jun 13, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment