User:Grrrreat/prototyping/pokingsite: Difference between revisions
(Created page with "<pre> function reposition(){ var counter = jQuery(".counter"); var pokebutton = jQuery("#pokebuttonsubmit"); var position = pokebutton.offset(); jQuery(".counter").css({'po...") |
No edit summary |
||
Line 1: | Line 1: | ||
this: [http://poke.jaspervanloenen.com/ | Poking-Site] | |||
javascript which executes the php functions and inputs them into the body dynamically. | |||
<pre> | <pre> | ||
function reposition(){ | function reposition(){ | ||
Line 7: | Line 11: | ||
} | } | ||
} | } | ||
function countDown(number){ | function countDown(number){ | ||
Line 21: | Line 23: | ||
reposition(); | reposition(); | ||
} | } | ||
} | } | ||
img1 = new Image(); | img1 = new Image(); | ||
Line 66: | Line 69: | ||
}); | }); | ||
</pre> | |||
poke.php to add 1 to the actual count of pokes. | |||
<pre> | |||
<? | |||
$mysql_user = ""; | |||
$mysql_pass = ""; | |||
$mysql_host = "localhost"; | |||
$mysql_dbn = ""; | |||
global $my_local_connection; | |||
$my_local_connection = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Unable to connect to database"); | |||
mysql_select_db($mysql_dbn, $my_local_connection) or die( "Unable to select database"); | |||
mysql_query("UPDATE pokes SET amount=amount+1"); | |||
mysql_close(); | |||
sleep(1); | |||
?> | |||
</pre> | |||
count.php to count the stored pokes and output them as a number | |||
<pre> | |||
<? | |||
$mysql_user = ""; | |||
$mysql_pass = ""; | |||
$mysql_host = "localhost"; | |||
$mysql_dbn = ""; | |||
global $my_local_connection; | |||
$my_local_connection = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Unable to connect to database"); | |||
mysql_select_db($mysql_dbn, $my_local_connection) or die( "Unable to select database"); | |||
$sql = mysql_query("SELECT amount FROM pokes LIMIT 1"); | |||
$row = mysql_fetch_assoc($sql); | |||
echo $row['amount']; | |||
mysql_close(); | |||
?> | |||
</pre> | </pre> |
Revision as of 10:09, 10 May 2012
this: | Poking-Site
javascript which executes the php functions and inputs them into the body dynamically.
function reposition(){ var counter = jQuery(".counter"); var pokebutton = jQuery("#pokebuttonsubmit"); var position = pokebutton.offset(); jQuery(".counter").css({'position':'absolute','left':position.left + pokebutton.outerWidth() - 10}); } } function countDown(number){ $('#btnText').html(number); if(number>0){ var t=setTimeout("countDown("+(number-1)+")",1000); }else{ $('#btnText').html('Poke Me'); $('.pokebutton').removeClass('disabledButton'); $('.buttonshadow').css('background-image', 'url(../img/buttonshadow.png)'); pokerEnabled = true; reposition(); } } img1 = new Image(); img1.src = "../img/buttonshadow-smaller.png"; var pokerEnabled = true; jQuery(document).ready(function() { reposition(); jQuery(window).resize(function() { reposition(); }); $(".what").bind("click", function(){ $('#description').fadeIn(200, function(){ }); var aboutTimeout=setTimeout("hideAbout()",30000); }); $("#close").bind("click", function(){ hideAbout(); clearTimeout(aboutTimeout); }); $.get("count.php", function(data){ $('#totalnumber').html(data); }, "json"); $('#pokebuttonsubmit').click(function(event) { event.preventDefault(); if(pokerEnabled){ $.get("poke.php"); $.get("count.php", function(data){ $('#totalnumber').html(data); }, "json"); $('.pokebutton').addClass('disabledButton'); countDown(9); $('.buttonshadow').css('background-image', 'url(../img/buttonshadow-smaller.png)'); reposition(); } pokerEnabled = false; }); });
poke.php to add 1 to the actual count of pokes.
<? $mysql_user = ""; $mysql_pass = ""; $mysql_host = "localhost"; $mysql_dbn = ""; global $my_local_connection; $my_local_connection = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Unable to connect to database"); mysql_select_db($mysql_dbn, $my_local_connection) or die( "Unable to select database"); mysql_query("UPDATE pokes SET amount=amount+1"); mysql_close(); sleep(1); ?>
count.php to count the stored pokes and output them as a number
<? $mysql_user = ""; $mysql_pass = ""; $mysql_host = "localhost"; $mysql_dbn = ""; global $my_local_connection; $my_local_connection = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die("Unable to connect to database"); mysql_select_db($mysql_dbn, $my_local_connection) or die( "Unable to select database"); $sql = mysql_query("SELECT amount FROM pokes LIMIT 1"); $row = mysql_fetch_assoc($sql); echo $row['amount']; mysql_close(); ?>