zaqar/samples/html/unsubscriptionConfirmation.html
wanghao 4778f708fa Subscription Confirmation Support-3
This patch is the third part of subscription confirmation feature.
Support to send email to subscriber if confirmation is needed.

Change-Id: I230f5c7fbc9d19554bbcf34ce9b2f3b14230321b
Implements: blueprint subscription-confirmation-support
2017-02-15 18:03:41 +08:00

146 lines
4.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<style>
html, body {
margin: 0; padding: 0;
background: #fff;
color: #333;
font: 12px/15px Verdana, sans-serif;
}
#container {
max-width: 520px;
margin: 30px;
padding: 0px;
}
#content h2 {
font: bold 16px/16px Verdana, sans-serif;
margin: 0;
padding: 0;
margin-bottom: 12px;
}
#header {
height: 40px;
padding-bottom: 0;
color: #e47911;
position:relative;
margin-bottom: 12px;
}
#header h1 {
font-size: 12px;
line-height: 12px;
margin: 0; padding: 0;
position: absolute;
bottom: 0;
right: 0;
}
#content {
padding: 12px;
background: #ecf5fb;
border: 1px solid #c9e1f4;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
p {
margin-top: 0;
margin-bottom: 12px;
}
.error {
color: #900;
}
.success {
color: #090;
}
code {
font-style: normal;
color: #000;
}
abbr {
font-weight: bold;
}
a:visited, a:hover {
color: #004b91;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<h1>OpenStack Zaqar Service</h1>
</div>
<div id="content">
<h2 id="status">Removing subscription...</h2>
<div id="progress">
<noscript><p>Your browser has JavaScript disabled. <i>To confirm a subscription via this page, your browser must have JavaScript enabled.</i></p></noscript>
</div>
</div>
</div>
<script type="text/javascript">
function getParameterByName( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
$(document).ready(function(){
var confirmationUrl = getParameterByName("Url");
var Signature = getParameterByName("Signature");
var Methods = getParameterByName("Methods");
var Paths = getParameterByName("Paths");
var Project = getParameterByName("Project");
var Expires = getParameterByName("Expires");
var Queue = getParameterByName("Queue");
var Confirmed = getParameterByName("Confirm");
var failureString = "<p>Your subscription could not be removed because of an error.</p>";
if (Queue == "") {
$("#status").html("Subscription <i>not</i> removed").addClass("error");
$("#progress").html("<p>Your subscription could not be removed because queue is missing. To unsubscribe, please use the full URL from the message you received.</p>");
} else {
var response = $.ajax({ type: "PUT",
url: "http://127.0.0.1:5678",
dataType: "json",
data: {'confirmed': false},
beforeSend: function(request) {
request.setRequestHeader("Content-type", "application/json");
request.setRequestHeader("URL-Signature", Signature);
request.setRequestHeader("URL-Methods", Methods);
request.setRequestHeader("URL-Paths", Paths);
request.setRequestHeader("X-Project-ID", Project);
request.setRequestHeader("URL-Expires", Expires);
request.setRequestHeader("Confirmation-Url", confirmationUrl);
request.setRequestHeader("Confirm", Confirmed);
},
success: function(data, status, req){
$("#status").html("Subscription removed!").addClass("success");
$("#progress").html("<p>You have removed subscription to the queue:<br /><abbr title=\""
+ Queue
+ "\">"
+ Queue
+ "</abbr>.</p>");
},
error: function(req, status, error){
$("#status").html("Subscription <i>not</i> removed").addClass("error");
$("#progress").html(failureString);
}
});
}
}
);
</script>
</body>
</html>