Switched to jQuery event handlers

This commit is contained in:
Dan Bovey 2015-09-28 19:11:48 +01:00
parent c50ac9e462
commit dad5188e19
2 changed files with 30 additions and 20 deletions

View File

@ -65,7 +65,7 @@ define('CONN', (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "")?'http':'ht
<h2 id="loading"><img src="img/loading.gif" /><br/>Loading..</h2> <h2 id="loading"><img src="img/loading.gif" /><br/>Loading..</h2>
<hr class="small"> <hr class="small">
<span style="text-shadow: 0px 0px 12px #000000;" class="subheading">Give it a try! <input id="showcase_url" type="url" placeholder="eg. http://xkcd.com" /> <span style="text-shadow: 0px 0px 12px #000000;" class="subheading">Give it a try! <input id="showcase_url" type="url" placeholder="eg. http://xkcd.com" />
<input id="showcase_button" type="button" onclick="web2pic();" value="GO" /></div> <input id="showcase_button" type="button" value="GO" /></div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,20 +1,30 @@
function web2pic() $(function() {
{ function web2pic(url)
$("#showcase_button").attr("disabled","true"); {
var url = $("#showcase_url").val(); $("#showcase_button").attr("disabled","true");
var urlenc = encodeURIComponent(url); var urlenc = encodeURIComponent(url);
var imageURL = "api.php?js=no&token=0e316498db6211f940951e"+(urlenc)+"8be8cdf7089770&type=$type&viewport=1200x330&url="+urlenc; var imageURL = "http://http2pic.haschek.at/api.php?js=no&token=0e316498db6211f940951e"+(urlenc)+"8be8cdf7089770&type=$type&viewport=1200x330&url="+urlenc;
//$("#intro-header").css('background-image', 'url(\'/img/loading.gif\')'); //$("#intro-header").css('background-image', 'url(\'/img/loading.gif\')');
$("#loading").show(); $("#loading").show();
console.log(imageURL);
$("#preloader").attr('src',imageURL); $("#preloader").attr('src',imageURL);
$("#preloader").load(function() { $("#preloader").load(function() {
$("#intro-header").css('background-image', 'url(\'' + imageURL + '\')'); $("#intro-header").css('background-image', 'url(\'' + imageURL + '\')');
$("#loading").hide(); $("#loading").hide();
$("#showcase_button").removeAttr("disabled");
});
}
$("#showcase_button").click(function() {
web2pic($('#showcase_url').val());
}); });
console.log(imageURL);
setTimeout(function(){$("#showcase_button").removeAttr("disabled");},2000); $("#showcase_url").keypress(function(e) {
} if(e.keyCode === 13) {
web2pic($("#showcase_url").val());
}
});
});