Skip to content

Commit

Permalink
Small code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed Apr 24, 2014
1 parent 5b51833 commit 7d2833e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
12 changes: 6 additions & 6 deletions public/index.html
Expand Up @@ -82,11 +82,11 @@ <h1>
</fieldset>
</form>
</section>
<div sytle="width":700px;">
<div id="resultImageId" style="float: left; width:128px;"></div>
<div id="resultId" style="float: left; width:372px;"></div>
<div id="tweetId" style="float: left; width:200px; vertical-align:middle;"></div>
<br style="clear: left;"/>
<div>
<div id="resultImageId" style="float: left; margin: 1em;"></div>
<div id="resultId" style="float: left; margin: 1em;"></div>
<div id="tweetId" style="float: left; margin: 1em; vertical-align: middle;"></div>
<br style="clear: both;" />
</div>

<section>
Expand Down Expand Up @@ -208,4 +208,4 @@ <h3>
</body>
<!-- jekyll-theme-demivolte, http://joelpurra.github.io/jekyll-theme-demivolte by Joel Purra, http://joelpurra.com/ -->

</html>
</html>
39 changes: 26 additions & 13 deletions public/resources/javascript/main.js
Expand Up @@ -7,6 +7,18 @@ $(function() {
var instance = createjs.Sound.play(name);
},

// http://stackoverflow.com/questions/1219860/html-encoding-in-javascript-jquery
// http://stackoverflow.com/a/1219983/907779
htmlEncode = function(value) {
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
},

htmlDecode = function(value) {
return $('<div/>').html(value).text();
},

domainLookupFail = function(jqXHR, textStatus, errorThrown) {
// TODO: show error to the user
console.error(jqXHR, textStatus, errorThrown);
Expand All @@ -18,34 +30,35 @@ $(function() {
domainLookupDone = function(data, textStatus, jqXHR) {
// TODO: use data
console.log(data, textStatus, jqXHR);

// Load the success or failure image
var image="";
if (data.isSecure){
image="Success";
var image = "";
if (data.isSecure) {
image = "Success";
} else {
image="Failure";
image = "Failure";
}
var imageString="<img src=resources/image/"+image+".png />";
var imageString = "<img src=resources/image/" + image + ".png />";
$("#resultImageId").empty();
$("#resultImageId").append(imageString);

// Load the results text
var resultString = "<h2>DNSSEC Results</h1>";
resultString += "<ul><li>Domain: " + data.domain + "</li>";
resultString += "<li>DNSSEC Secure: " + data.isSecure + "</li>";
var resultString = "<h2>DNSSEC Results</h2>";
resultString += "<ul>";
resultString += "<li>Domain: " + htmlEncode(data.domain) + "</li>";
resultString += "<li>DNSSEC Secure: " + (data.isSecure === true ? "Yes!" : "No!") + "</li>";
resultString += "</ul>";
$("#resultId").empty();
$("#resultId").append(resultString);

// Load the tweet button
var tweetResult = data.domain;
if (data.isSecure) {
tweetResult+=" has successfully implemented #DNSSEC";
tweetResult += " has successfully implemented #DNSSEC";
} else {
tweetResult+=" has NOT successfully implemented #DNSSEC";
tweetResult += " has NOT successfully implemented #DNSSEC";
}
var tweetString="<p/><h3><a href=http://twitter.com/home/?status=" + encodeURIComponent(tweetResult) + ">Tweet this result</a></h3>";
var tweetString = "<p/><h3><a href=http://twitter.com/home/?status=" + encodeURIComponent(tweetResult) + ">Tweet this result</a></h3>";
$("#tweetId").empty();
$("#tweetId").append(tweetString);

Expand Down Expand Up @@ -100,4 +113,4 @@ $(function() {

$document.on("click", ".has-domains-to-check a", doAjaxOnLinkClick);
}());
});
});

0 comments on commit 7d2833e

Please sign in to comment.