Saturday, November 29, 2014

jQueryFileTree - an old plugin

I've been on a project at school for some time, it's a lot of fun. I enjoy working with others for a change. The project uses jQuery and we had a need to view directories from the server. Originally I wrote a very messy class that got the job done, but then one day I stumbled on jQueryFileTree.

Over all it was much simpler than my implementation. The only thing I don't like about it is it passes raw html from the connector script. My implementation passed a json object. Still, didn't take much work to get everything changed over. Most importantly, jQueryFileTree's implementation looked prettier... a lot prettier.

My lame file tree.
jQueryFileTree's default.

If there is anything I've learned about working with web interfaces, it's this: noone cares how efficient/useful/pretty/awesome your underlying scripts is, they only look at the surface. It's actually unfair the value placed on aesthetics. Cover some craptacular code with bootstrap, everyone think's it gold.

Why am I even writing about this?

For as much as I like jQueryFileTree, there were a couple of things it couldn't do. Now it can do those things, because open source!

One part of our project didn't need files, only folders. The user selects a folder and magic happens no matter what is inside. I added a Boolean option called 'folderSelect' to handle this behavior. By default it's false, but if set to true files are not displayed and when the user clicks a folder that directory path is passed to the callback.

The other thing we needed was a way to exclude files by name or extension. The new option 'exclude' is an array of strings. Any strings that match a folder or file name is given a hidden class. In contrast 'folderSelect' does not return files at all, this will return the excluded names but not show them. I did this just in case we wanted to have an option to show hidden files. In addition to names, any string that starts with '*.' will exclude by file extension.

jQueryFileTree with these new options can be found at this fork of the original. The exclusion code get's complicated, no doubt there are ways to improve it (I'm all ears if anyone has a suggestion).

Maybe I'll change it up to pass json in the ajax call, and have a way for the user to change up the look. I think that would be better. I don't have a need for that right now though, so I won't be surprised if it doesn't happen.


Elizabeth Johanson said...

I am one of the most experienced UK dissertation writers from England, UK. I have been teaching and helping the students with their academic issues, dissertation proposals, reports, etc. I would love to teach them about this plugin as well.

Unknown said...

Exportclub is an online pakistani men brand collection in pakistan.Our brand is established in 2010.Now,we are one of the best online styles for men summer at an affordable and reasonable price.

Unknown said...

Thanks for sharing this nice post!I have been reading this content since last night.It was really helpful and informative for me and all the readers.We are offering an online gift to karachi at an affordable and reasonable price.

Emma Watson said...

Searching for horse riding gear and apparel? Protective caps, Gloves, Tights, Boots, Whips and the sky is the limit from there! Reasonable costs. horse shops near me

thisisemliyblunt said...

Great service, easy and quick. Would use again, jet2holidays discount code just what we where looking for and very good price.

John said...

Basically, I was looking for an Essay Writing Service in Philadelphia when I landed on your site. I know I have been landed accidentally, but believe me, I am glad to come here because it has provided me very unique information about Jquery. I am sure it will help me in my computer science career.

thisisemliyblunt said...

On the off chance that they don't then your resume will appropriately, Best Discount code site
Kitchen With Dining
Top Brands Shoes For Men And Women
Prepping Up For Summer Skin
Perfect Swimsuit
Blue Sea Holidays
london travel guide
Emporio Armani
Beach Vacations, be going out with the rubbish without a subsequent look.

My Dissertations said...

No worries, we suggest you request My Dissertations to get MBA dissertation help online and we will make sure you get all the rest you need.

John David said...

Indeed, jQueryFileTree has been around for a while and remains a reliable choice for directory tree display. Speaking of longevity and reliability, I recently came across the DPS-275EB-A - Dell Red 275-Watts Power Supply. Despite being around for a considerable time, it's still a robust and efficient power supply, ensuring stable performance for various Dell systems. It's great to see these time-tested components stand the test of time in the tech world.