User:Grrrreat/prototyping/pokingsite: Difference between revisions

From XPUB & Lens-Based wiki
(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
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
this: [http://poke.jaspervanloenen.com/ | Poking-Site]
Jasper van Loenen & Bartholomäus Traubeck
javascript which executes the php functions and inputs them into the body dynamically.
<pre>
<pre>
function reposition(){
function reposition(){
Line 7: Line 13:
}
}


function hideAbout(){
$('#description').fadeOut(700, function(){ });
}
}
function countDown(number){
function countDown(number){
Line 21: Line 25:
reposition();
reposition();
}
}
}
}
img1 = new Image();
img1 = new Image();
Line 66: Line 71:


});
});
</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>

Latest revision as of 10:11, 10 May 2012

this: | Poking-Site

Jasper van Loenen & Bartholomäus Traubeck

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();
?>