Skip to content

Commit

Permalink
webpush test
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Jan 26, 2016
1 parent 29d3967 commit 91678a2
Showing 1 changed file with 95 additions and 0 deletions.
95 changes: 95 additions & 0 deletions webpush.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>@PushItBot WebPush</title>

<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body style="padding-top: 50px">
<div class="container">
<form class="form-horizontal" id="pushForm">
<div class="form-group">
<label for="inputToken">Token provided by @PushItBot</label>
<div class="input-group">
<span class="input-group-addon">https://tgbots-fopina.rhcloud.com/pushit/</span>
<input type="text" class="form-control" id="inputToken" placeholder="token">
</div>
</div>
<div class="form-group">
<label for="inputToken">Text to push</label>
<div class="input-group">
<textarea class="form-control" id="inputText" rows="3"></textarea>
</div>
</div>
<div class="form-group">
<label for="formatRadio">Formatting</label>
<span class="input-group" id="formatRadio">
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="" checked="checked"> None
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="Markdown"> Markdown
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="HTML"> HTML
</label>
</span>
</div>
<button type="submit" class="btn btn-primary">Push it!</button>
</form>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$( "#pushForm" ).submit(function() {
var createCORSRequest = function(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// Most browsers.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
// IE8 & IE9
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
// CORS not supported.
xhr = null;
}
return xhr;
};

var url = 'https://3cda0916.ngrok.io/pushit/f7a41cbb9940ad64d0b183913cb8e17a';
var method = 'POST';
var xhr = createCORSRequest(method, url);

xhr.onreadystatechange = function() {
console.log(xhr.readyState);
if (xhr.readyState == 4) {
console.log(xhr.response);
}
};

xhr.onerror = function() {
alert('ERROR');
};

xhr.send();
});
</script>
</body>
</html>

0 comments on commit 91678a2

Please sign in to comment.