fromvega.com

Throwing code to the wind

EasyDrag Update

Hello folks,

it’s just a remark that the EasyDrag plugin for jQuery was finally updated. You can check and download the last version by going to the specific post: http://fromvega.com/wordpress/2007/07/14/easydrag-jquery-plugin/

Thank you for all suggestions and contributions! If I forgot something please let me know!

EasyDrag jQuery Plugin

29/06/08 UPDATE: Handler feature added! Finally I decided to add a little piece of extra functionality to the EasyDrag plugin. It has been constantly requested, so now you can download and test it. I will be releasing it as a final version after some feedback, so please let me know if it works for you.

How does it work?

It’s very simple, first you call the easydrag() method as in the old version and then you call the setHandler() method passing to it the id of the element that will act as the handle. The handle MUST be a child element of the content that will be dragged.

$("#box2").easydrag();
$("#box2").setHandler('handler3');

Files

jquery.easydrag.handler.beta.js

It has been a while since my last post, mainly because I’m currently a little busy with some projects. In one of these projects I had to add a drag-and-drop behavior to some DOM elements, and for that I have created the EasyDrag jQuery plug-in that I’ll share with you now.

Its main purpose is to add the ability to drag and drop almost any DOM element without much effort. So it’s simple to use and you can also attach handlers both to the drag and to the drop events, which permits you to extend the basic functionality to whatever you need.

Read the rest of this entry »

Easy XML with Java - XML Binding

Recently in a Java project that I’m currently working on it was necessary to read remote XML data. Since my Java skills aren’t too strong and that I’ve never used Java and XML together I hit the road to search for help. I quickly found some articles and tutorials about dealing with XML within Java. I was trying to understand some concepts from one of the articles when I glimpsed the article year and to my surprise: 1996. Wow! I wasn’t looking for an history class so I moved on.

I have found other older articles in the way and even have tried on some code until I was pointed to the right direction by some buddies. That’s a big point of confusion to beginners and inexperienced Java developers in my opinion. There is a ton of information about Java out there and we must take care not to get caught by some old and deprecated functionality. But since I got it right let’s stop complaining and go strait to the point!

Read the rest of this entry »

XML Generator DIR

XML Generator DIR is an XML generator that will make a lot easier for you to create XML configuration files. It is focused in the creation of configuration files for image galleries, music players and for any other stuff where you need to list all files in a directory in a simple way.

This script uses a model file to give you freedom defining your XML file. You can create practically any structure you want and let the script populate it for you.

If you need to read records from a database instead of directories in a filesystem you should check the XML Generator DB instead.
Read the rest of this entry »

XML Generator DB

Here is a new flavor of the XML Generator, called XML Generator DB. This version builds XML files based on records from a database table instead of files in a directory.

I was thinking about embedding this functionality into the original script (now called XML Generator DIR to follow the name pattern) but it would add a lot more complexity in its configuration. The usage is pretty similar to the original, the model is the same but with different placeholders.

If you need to list files from directories in a filesystem instead of a database you should check the XML Generator DIR instead.
Read the rest of this entry »

XML Generator 2.0 - PHP & DOM

Update: I have updated and fixed some minor functionalities of this script and also changed its name to XML Generator DIR to differentiate from the new flavor XML Generator DB. Although the usage still the same you should check the new post instead.

So here it is! The 2nd version of the XML generator that will make a lot easier to create XML configuration files. As the previous version this one is focused in the creation of configuration files for image galleries, music players and related stuff where you need to list all files in a directory. The difference is that in this version you can create almost any XML structure in a simpler way.

While writing the 1st-version post I had this idea to use a model file instead of tweaking PHP variables and arrays. Different from before now you have freedom to define your XML file. You can have how many nested tags you want and also you can have attributes.

Writing this script was fun. I used PHP and the DOM library for the job. I won’t be explaining the code in details here because it already has a lot of comments but I may write a post explaining the DOM in more details based on readers feedback.

Read the rest of this entry »

XML Config File Generator with PHP

Although this version may be an interesting study, you should check the new version instead. XML Generator 2.0 is easier and more powerful than the version presented in this post. Check it by clicking here.

This morning a friend of mine came to me asking for a script to automatically generate an XML config file. He needed a script to read directories of images and build an XML file for each one to use along his Flash gallery. It would save him a lot of time so I decided to write one specially for him. Then I realized that creating this type of XML file is a common task that many of us need to do at least once in a lifetime. Who never needed to create an XML for an image gallery or for a music player?

With this assumption in mind I decided to write a little more generic script. However, it’s still limited to the purpose of reading directories of one level only and for tags without attributes. In this post I’ll explain how you can use the XML generator script. I’ll not explain the code in details because I believe the source code is pretty well documented but if you have any doubt about it, please feel free to leave a message. I’ll be glad to help.

Read the rest of this entry »

SimpleXML debug with var_dump() and print_r()

Recently I was using the SimpleXML extension from PHP5 to build a menu based on information contained in an XML file. I was using XPath queries to retrieve specific nodes from the XML tree and the var_dump() and print_r() functions to debug the results.

I thought my XPath queries were all wrong because the output data wasn’t the expected, all tree was returned instead. I tried many variations without success until I realized that something was wrong with the output. I let the debug functions aside and finished the code. And guess what? The code worked fine!

To confirm it I went to the manual to seek for any related information. No official note but I found an user comment about var_export not working as well!

So that’s it. Don’t use var_dump() nor print_r() to debug the content of SimpleXMLElement objects. Instead use print() or echo() on individual elements.

Update: I have also noticed a similar behavior with the DOM library.

Hello! As I promised, I’ll be explaining all the JavaScript code of the auto-complete field in this post. If you haven’t read the previous post where I talk about the auto-complete field take a moment to read it first before continuing.

Now take some cookies because the post is quite long. Be comfortable and let’s start!

Read the rest of this entry »

In the last few days I’ve started using the jQuery JavaScript library. To experiment with this great piece of software I’ve decided to implement an AJAX auto-complete feature. jQuery makes remote scripting a piece of cake and that led me to spend more time coding additional functionalities for the auto-complete field. In this post I’ll explain how to use my auto-complete field and in a following post I’ll explain all the code. So let’s start!

Read the rest of this entry »
« Previous Entries  

Calendar

July 2008
S M T W T F S
« Oct    
 12345
6789101112
13141516171819
20212223242526
2728293031  
AddThis Social Bookmark Button