Merge pull request #2 from danbovey/master

Switched to jQuery event handlers
This commit is contained in:
chrisiaut 2015-09-28 21:15:24 +02:00
commit 627a640bde
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>
<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" />
<input id="showcase_button" type="button" onclick="web2pic();" value="GO" /></div>
<input id="showcase_button" type="button" value="GO" /></div>
</div>
</div>
</div>

View File

@ -1,20 +1,30 @@
function web2pic()
{
$("#showcase_button").attr("disabled","true");
var url = $("#showcase_url").val();
var urlenc = encodeURIComponent(url);
var imageURL = "api.php?js=no&token=0e316498db6211f940951e"+(urlenc)+"8be8cdf7089770&type=$type&viewport=1200x330&url="+urlenc;
//$("#intro-header").css('background-image', 'url(\'/img/loading.gif\')');
$(function() {
function web2pic(url)
{
$("#showcase_button").attr("disabled","true");
var urlenc = encodeURIComponent(url);
var imageURL = "api.php?js=no&token=0e316498db6211f940951e"+(urlenc)+"8be8cdf7089770&type=$type&viewport=1200x330&url="+urlenc;
//$("#intro-header").css('background-image', 'url(\'/img/loading.gif\')');
$("#loading").show();
$("#loading").show();
console.log(imageURL);
$("#preloader").attr('src',imageURL);
$("#preloader").load(function() {
$("#intro-header").css('background-image', 'url(\'' + imageURL + '\')');
$("#loading").hide();
$("#preloader").attr('src',imageURL);
$("#preloader").load(function() {
$("#intro-header").css('background-image', 'url(\'' + imageURL + '\')');
$("#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());
}
});
});