Online Pharmacy

online viagra buy generic cialis in brisbane identify cialis Viagra without Perscription cialis buy online viagra lawyers Discount viagra cialis overnight Viagra Propecia low cost viagra where can one buy cialis cialis order from us buy cialis generic what is the price of viagra buy viagra in uk buy cheap cialis generic levitra viagra viagra pharmacy buy cialis in canada Discount Pfizer Viagra cheap generic viagra buy cheap cialis online Cheapest Viagra Price buy viagra mastercard viagra cialis levitra cialis commercial Buy Onlinecom Phentermine Viagra cheapest place to buy viagra online viagra pill cialis buy without prescription buy viagra no prescription buy cialis now top internet cialis web sites cialis mastercard buy cheap cialis in australia order cialis now Viagra Faq visa viagra viagra mastercard female viagra Viagra Tablet mastercard buy viagra cialis pro buy online viagra how does cialis work venta de cialis viagra cialis buy generic cialis from india Viagra Facts about viagra Cialis Viagra Online buy tadalafil cialis best price viagra buy cialis generic online Buy Viagra Now Online buy cheap cialis ipharmacy is cialis better than viagra No Prescription Viagra where to buy cialis where can i buy viagra from Viagra Pushups cialis soft tabs buy low price viagra where to buy viagra cialis vs. viagra buy cialis australia buy viagra paypal Buy Viagra Onlines best place to buy cialis where buy viagra cialis india sildenafil cialis generico what dose cialis does cialis work what is the generic name for cialis viagra cialis compare cialis levitra viagra buy viagra on line buy cialis paypal In Man Uk Viagra sales cialis buy cheap cialis ciales cialis buy discrete buy generic cialis online cialis women viagra from health store order viagra cialis viagra online buy cialis online viagra cheap price viagra Drug Viagra viagra buy maile order cialis cialis compared to viagra buy cialis online no prescription buy cheap viagra cialis visa Between Difference Levitra Viagra buy cialis visa discount viagra online Cheap Generic India Viagra viagra sale buy viagra where cialis and alcohol order cialis cheap buy cialis american express cialis 10mg cialis small packs cheap viagra uk sell viagra to buy cialis mastercard buy cialis buy canada cialis buy cheap purchase uk viagra viagra low cost mastercard viagra buy viagra visa viagra visa Viagra Alternative buy cialis drug online rx buy cialis cialis experience buy viagra line viagra sale online Very Cheap Viagra natural viagra Deer Viagra where can i buy viagra Viagra Online Shop is levitra better than cialis viagra prescription order viagra viagra for woman order cialis on line cialis generic buy discrete buy cialis soft tabs online chea Viagra Discount low cost cialis viagra best buy order cialis online herbal cialis prescription cialis us pharmacy buy viagra without prescription Cialis Generic Levitra Viagra cialis side effects cialis archive newest Viagra Concerns cialis visa cialis online no presription buying generic cialis buy viagra online cheap buy cialis without prescription buy cialis tablets buy viagra usa american express buy viagra viagra cialis generica what stores sell viagra cialis canada cialis order cialis europe viagra buy generic cialis viagra and cialis cheap discount viagra mastercard cialis buy cialis without a prescription Compare Levitra And Viagra cialis uk cialis sales cialis daily buy viagra Canadas Viagra Commercial buy cialis and viagra viagra mastercard viagra visa side effects of cialis Viagra for Women Cheapest Viagra cialis message board overnight cialis cheap cialis where to buy levitra cialis viagra online generic viagra viagra price buycialisonline liquid cialis Viagra Generika where can i buy cialis online viagra cialis phentermine soma sell viagra online Comparison Viagra Levitra Cialis buy cialis with no prescription cialis professional viagra dosage generic cialis soft online cheapest cialis cialis smile blog buy generic cialis viagra online generic cialis soft cheap generic cialis order cialis cialis mastercard Cialis Compare Levitra Viagra daily cialis buy cialis viagra Cheapest Cheap Viagra buy cialis online now Can Women Take Viagra buy uk viagra order cheap cialis generic cialis india buy cialis cheap Viagra Generic Drug Levitra Viagra paypal buy cialis Viagra Dangers cialis buy next day delivery buy cialis no prescription cialis forum buying cialis best price cialis Buy Viagra Order Viagra cialis for women viagra buy viagra cheap viagra alternatives american express buy cialis cialis to buy new zealand buy cialis line where to buy levitra cialis viagra no prescription paypal buy viagra visa cialis buy cheap generic cialis online cialis pricing Pill Viagra which is better cialis or viagra How Does Viagra Work Cialis Super Viagra buy cialis where cialis thanks blog Viagra Or Cialis buy cialis from icos 3cialis Generic Levitra Viagra generic viagra viagra on line Herbal Viagra Wholesale Generic India Viagra cialis on line Buy Cheap Uk Viagra Compare Cialis Levitra Viagra viagra cialis online buy generic viagra buy cialis online cialis online order viagra canada Cialis Comparison Levitra Viagra cheap viagra usa buy cialis doctor online buy cialis mastercard Levitra Or Viagra viagra online order viagra Buy Line Viagra viagra online order guide soft cialis cialis viagra cheap Soft Tab Viagra Sales Viagra cheap viagra cialis dosage propecia cialis viagra book buy cialis guest jill org site viagra online purchase cialis buy buy viagra online where can i buy cialis cialis mail order cheap viagra online viagra usa viagra buy online cialis confusion buy generic cialis in australian pharmacy where buy cialis visa buy viagra buy viagra online inu purchase viagra cialis clock buy viagra uk buy cialis custom hrt Viagra Sale Uk buycialis viagra cialis generic cialis best price viagra cialis cialis generic Sildenafil Viagra pfizer viagra viagra UK buy discount cialis buy cialis cheap in the uk Viagra Buy Viagra cheap cialis sale online Viagra Womans cialis online buy viagra in the uk viagra generic Viagra Online Purchase viagra for sale viagra generic buy Cialis Levitra Viagra cialis cost buy cialis in singapore visa buy cialis buy viagra now viagra side effects order viagra online Generic Viagra Sale Ciscount Viagra Viagra Com buy cialis on line buy viagra in canada viagra dose viagra soft tabs Viagra Lowest Price Viagra In The Water viagra pills buy viagra american express viagra order cialis daily use buy online order viagra order generic cialis discount cialis Effects Of Viagra where to buy viagra on line cheap sale viagra Viagra Onlines prices cialis Viagra Perscription viagra online ordering cialis for order Cheapest Viagra Prices Online Viagra Sale

:: Archive for the 'Uncategorized' Category ::

A walk on the beach

Posted on October 19th, 2008 in Uncategorized by Greg

Its been a long time since I’ve written anything here…mostly due to a very busy year which included Yenari and me getting married in June. I’ll try my best to be more active (i.e. more than one post a year), but for now, I’ll just provide a link to a little experiment I put together from some pictures from our honeymoon in the Cook Islands. It’s a little slideshow-like page, built with JavaScript:

Walking into the Ocean

Nothing too crazy on the JavaScript side – just playing around with some stuff I hadn’t done before. I wrote about three quarters of this a few months ago and just finished it off this afternoon. I had to write a simple, but hopefully effective, image preloader that has nice callbacks and a decent api. The actual slideshow could be written better, but it works, and that’s all I was going for…


Photos from South Korea, India, and Singapore

Posted on June 10th, 2007 in Uncategorized by Greg

I just got back from 20 days of traveling to South Korea, India, and Singapore. I went to South Korea with Yenari to see her family and friends for about a week. After this I headed to Bangalore (India) for work while Yenari stayed in South Korea a bit longer. On the way back home I had a long layover (9 hours) in Singapore and got a chance to check out the city.

Check out my pictures here: http://picasaweb.google.com/gneustaetter/SouthKoreaIndiaAndSingapore

Scriptaculous Sortables with Ajax Callback

Posted on January 16th, 2007 in Uncategorized by Greg

I haven’t written anything in a long time so I figured it is time to write something up. Because a huge portion of my traffic seems to be related to my scriptaculous examples I’ve put up, I figured I’d add another one that covers the process of updating a database with the results of drag/drop with an Ajax call. Each time the user changes an item’s position in the list it updates the database.

See the example (note: example uses Scriptaculous 1.7 Beta 2)

The methodology behind this is quite simple:

  1. Load the list values from the DB and show them on the screen
  2. Using JavaScript, setup the sortables
  3. Add a JavaScript callback to the drag/drop that points to a function that serializes the list and sends an Ajax request to the server
  4. On the server, loop through the list and update the database with the proper order

To do this I created three main files:

  • index.php – the UI that shows the list and has the JavaScript
  • ajax.php – the page that processes the Ajax request
  • db.php – a simple database class included in both index.php and ajax.php that makes the connection to the DB and has methods to get the current list and to update the list

Reviewing Index.php

Index.php looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?
require('db.php');
$demo = new SortableExample();
$list = $demo->getList();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Scriptaculous 1.7 Sortables Ajax Example</title>
	<link rel="stylesheet" type="text/css" href="style.css">
	<script src="js/prototype.js"></script>
	<script src="js/scriptaculous.js"></script>
	<script>
		Event.observe(window,'load',init,false);
		function init() {
			Sortable.create('listContainer',{tag:'div',onUpdate:updateList});
		}
		function updateList(container) {
			var url = 'ajax.php';
			var params = Sortable.serialize(container.id);
			var ajax = new Ajax.Request(url,{
				method: 'post',
				parameters: params,
				onLoading: function(){$('workingMsg').show()},
				onLoaded: function(){$('workingMsg').hide()}
			});
		}
		function handleResponse(req) {
			// this function will fire after the ajax request is complete...but we have nothing to do here
		}
	</script>
</head>
<body>
 
<h2>Scriptaculous Sortables Demo with Ajax Callback</h2>
Built with Scriptaculous 1.7 Beta 2.  Drag items in the list below.  Each time you update the list an Ajax call is made
that updated the database with the new order.<br><br>
 
<div id="listContainer">
	<?
	foreach($list as $item) {
		?>
		<div id="item_<?=$item['catid'];?>"><?=$item['category'];?></div>
		<?
	}
	?>
</div>
<div id="workingMsg" style="display:none;">Updating database...</div>
 
</body>
</html>

Let’s look at this in reverse order. At the bottom of the file there is a div with id ‘containerDiv’ (line 36). This is the container for our list. Within this is a small snippet of PHP that loops through an associative array and prints out each list item as a div with id ‘item_12′ where 12 is the ID for that record in the database (line 40). Lines 2-4 contain the PHP code that include the db.php file and use it’s class to get the associative array that is used here.

Underneath the container div is another div that has the text ‘Updating database…’ – this div is hidden by default and will be shown while Ajax calls are in progress (line 45).

Now to the JavaScript…it starts off on line 14 with a call to Event.observe that tells the browser to call the init function after the page loads. The init function (line 15) creates a new sortable list on the listContainer element, setting all divs within it to be sortable and setting the updateList function as a callback whenever the list is updated. This means that when the order of items in the list change, this function will be called with the list element passed as an argument. This function will perform the Ajax request to update the database.

The updateList function (line 18) first sets a simple variable for the url used for the Ajax request. Next (line 20) it calls Sortable.serialize, passing the id of the container as an argument, which serializes the list to a format such as listContainer[]=5,listContainer[]=7,listContainer[]=2 – here, the first three items of the list would be the items 5, 7, and 2 and the divs representing these items would have the following id values: item_5, item_7, and item_2. This serialized list is set in the variable ‘params’. Next, on line 21, an Ajax request is opened with Prototype’s Ajax.Request class. It is called with two arguments, the url and an object with various options. The options include the type of request (POST in this example, parameters to pass (the params variable constructed on line 20), and two functions (onLoading/onLoaded) that handle the showing and hiding of the ‘Updating database…’ div. Normally in an Ajax request I’d also add a callback for onComplete to handle the response from the server, but in this case the Ajax response doesn’t really matter to me because it is really only a one way communication in this demo – in a real application I’d have more error handling and would need to handle error conditions.

That’s about it for the index page…not too bad, right?

Reviewing ajax.php

The file ajax.php is a simple file that is designed to receive the Ajax request and call the appropriate methods defined in db.php to update the list. Its contents are shown below:

1
2
3
4
5
6
<?
session_start();
require('db.php');
$demo = new SortableExample();
$demo->updateList($_POST['listContainer']);
?>

Yup, that’s it. Basically it starts off by calling session_start() – I typically call session_start() at the top of pages like this because starting the session sends the right http headers to prevent the file from being cached and I’m too lazy to look up what the right headers are! Next it requires the db.php file, instantiates an object, and calls the updateList method of the object, passing the listContainer variable from the POST request (containing our serialized list). That’s it for the ajax.php page.

Reviewing db.php

The file db.php is a simple database class that connects to the database and has methods to get the list and to update the order of the list. In a ‘real’ application I would definitely have a much cleaner implementation of the database access and would use other DB libraries to connect to the db – I used the simple mysql db functions to minimize on the number of lines needed here. Here are the contents of the file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?
class SortableExample {
	protected $conn;
	protected $user = 'test';
	protected $pass = 'test';
	protected $dbname = 'scriptaculous';
	protected $host = 'localhost';
 
	public function __construct() {
		$this->conn = mysql_connect($this->host, $this->user, $this->pass);
		mysql_select_db($this->dbname,$this->conn);
	}
 
	public function getList() {
		$sql = "SELECT * FROM categories ORDER BY orderid";
		$recordSet = mysql_query($sql,$this->conn);
		$results = array();
		while($row = mysql_fetch_assoc($recordSet)) {
			$results[] = $row;
		}
		return $results;
	}
 
	public function updateList($orderArray) {
		$orderid = 1;
		foreach($orderArray as $catid) {
			$catid = (int) $catid;
			$sql = "UPDATE categories SET orderid={$orderid} WHERE catid={$catid}";
			$recordSet = mysql_query($sql,$this->conn);
			$orderid++;
		}
	}
}
?>

Important note – this file uses PHP 5 syntax in this object…you’d need some changes to get this to run in PHP 4. I’ll skip talking about the constructor (which connects to the database) and the getList function (which…gets the list) in order to focus on the last method, ‘updateList’. This function takes in an array of items, i.e. array(5,7,2), that come from the serialized list. It loops through the list and generates SQL UPDATE queries for each item. Each time it increments $orderid so that the first item has an orderid of 1, the 2nd an orderid of 2, etc. This means that whenever we get the list, as long as the SQL ‘ORDER BY orderid’ clause is used the list will show in the correct order.

Summary

That’s it…hope you enjoyed it. The hopeful moral of the story is…Ajax is easy, and so is drag and drop….especially if you’re using a good library. Personally I think that Prototype is incredibly useful for JavaScript development and Scriptaculous is a good sidekick for effects and drag/drop. I’ve also used the Yahoo YUI widgets at work where we needed to do some more dynamic widgets such as trees – it worked really well. Jack Slocum’s YUI extension is incredibly well done too…though it’s a heavy one in terms of file size! In the end, it comes down to finding the right tool for the job…

Download the sample application if you want to take a closer look….

gCards Forum Up!

Posted on July 3rd, 2006 in PHP, Uncategorized, gCards by Greg

Many folks have complained since I took down the forum that was up for the support of gCards. Now, I’ve got a new forum up, this one powered by Vanilla. Hopefully it’ll do a bit better than the last one.

Check it out

Moved to new webhost

Posted on February 20th, 2006 in Uncategorized by Greg

I moved this site to a new webhost – Dreamhost. Be on the lookout for links that don’t work and other broken stuff – if you find anything please add a comment to this post to let me know and I’ll take care of it.

In the process of moving my stuff from my old host to the new one, I came to learn that my forum for gcards was somewhat hacked…so I’ve decided to take it down (i.e. not reinstall it) for the time being. I may setup Media Wiki in its place or find another forum alternative…

Greg