Posts Tagged ‘Web Development’

Jeff asked about sortable tables…


And how I would do one with Javascript.. so I did. Here's a list of some books I've read semi-recently. The scores are not super well-considered.

show 4 per page
show all

You can have more than one per page, and it's easy to add them. This line of code will do it:
var table = new SortableData( data, headings, settings );

  • data is a list of data objects. Each object corresponds directly to a row in the table. An example of the data object:
    { author: 'Alastair Reynold', score: 8, book: 'Chasm City' }

     
  • headings is an array of data objects. Each describes a column of the table. An example of a heading data object:
    { key: 'author', value: 'Author', type: 'String' }

     
  • settings is an object whose values are used to overwrite the SortableData object's defaults. You can specify fields like page_size, and page. An example of a settings object:
    { page_size: 5 }

     

The SortableData.js file must be included, as it describes the object.

So for each table we instantiate a new SortableData object. That guy takes care of writing and updating HTML, and the paging. But how do we reference the object for the necessary onclick events (clicking a heading to sort by a column, or a page link to view that page)? I chose to do is maintain a static instances array within SortableData. On instantiation, each object assigns itself a unique ID, and adds itself to the instance array.
Static SortableData functions handle the click events. Each function takes, as one of its parameters, a SortableData instance ID and calls the appropriate functions on the instance with that ID. And it even works! First try, in fact!

Then some CSS to style the HTML outputted, and that's it! We're done.

It'd be easy to write a wrapper object that loads data via AJAX, ideally receiving appropriately formatted JSON, but I am pretty lazy. And really, what use do I have for a sortable table?

Another summary? Again? Seriously?

So much random stuff today!

Tacotime wanted a script to redirect visitors to affiliate websites; I made one for him. He wanted it to keep track of how many times it sent people to each site, which meant an interface for managing affiliates – and is how a 30 minute project turns into a 2 hour one. And that extra 1.5 hours is so boring. Oh, well. It’s done now.
Link selection is weighted by past redirects, which results in the interesting side-effect of it being far more likely for new affiliates to be chosen than any other – at least until they catch up.

Javier wanted Bradicon to include 128×128, 96×96, and 64×64 versions in its icons. Adding those involved ~3 lines each. Not much of a change, but how could I be sure it worked? I wrote a function to ouputs the icXOR map as coloured divs. And, man, do browsers hate rendering 800kb of divs! Seems like something they should be optimized for. You know, rendering html? Guess not, though, and tbh I’m pretty disappointed by that.

I don’t know if the additional sizes (also 256×256) are useful to many people, but if they are, I will add them to the live version of Bradicon. So far only two people have asked for that sort of thing, and that ~2 years apart.

I spent some time throwing a little red ball at a wall. It sports a smiley face. Sometimes I even caught it when it bounced back toward me.

On occasions not so rare as you might expect, I share friendship with people IRL. Often it involves a meal of food.
Deciding on restaurants is a ridiculous trial, but that is what it is. I wrote a web app to decide for us. It allows for managing a restaurant list, complete with user-specified weights.

I make a lot of little things. And then forget about them completely. Which is one of the reasons I find keeping a blog useful. Of course sometimes they do not lend themselves easily to examples, or I just don’t deem them important enough to mention. And that is how we come to these boring summary blogs. I’m going to try to limit them in the future, but we’ll see how successful that is. I suspect few. Few successfuls.

I am the best at English sometimes.

blog blog blog blog blog blog bradicon

Over the last few days I’ve been rewriting bradicon’s front end, and just generally doing bradicon-based stuff I should’ve done long ago.

Bradicon2 features a newer version of SWFUpload, which should fix a number of issues with the previous version’s advanced interface.

I’ve combined the advanced and simple interfaces, and really just subtly changed a few things – not at all based on usage information. HTML describes the simple interface which javascript hides it in favour of the advanced interface. Which might work better for anyone who keeps javascript disabled. People always worry about these things but, seriously, who doesn’t have javascript enabled?
Javascript also adds a link which toggles between interface modes.

When an icon is created with the advanced interface, the entire icon list is no longer reloaded (unless it has been marked for reloading, in which case it is).

There are a lot of pages that link to bradicon, and most do so by directly linking to advanced- or simple.php. So as not to break all those links, I’ve created files of those names which header-redirect to index.php. Google might hate that. I’m not sure. But, you know…usability.

The garbage collector is now set to remove empty directories, and any icons, or pngs older than 5 days old. No more ssh and ./clean for me.

One thing I’ve always kind of wanted to be able to check is the number of icons converted. I’d check how many existed before deleting them, but never kept any record. A database now keeps track of the number of icons made each day. This is what we call ‘useless information’, but whatevs. I can look at it and feel accomplishment. As if I manually constructed those icons pixel by pixel and byte by byte in a tiny work shop far into the frozen north.

Information pages and boxes have been added, which will hopefully make it more search-engine and adsense friendly. Who knows if that will work.

The system to actually create icons is exactly the same. It hasn’t been touched at all.

Basically bradicon2 is bradicon1, but looks just slightly different.

Soon I will direct Apache to bradicon2 instead of bradicon, but for now it can be accessed at ico2.bradleygill.com.

Oh! Also I added a donate button because Karl said no one ever uses them.

A Flash gallery frontend

 

I wrote a flash gallery front-end a week or so back. There’s a picture of it above. Just kidding it’s an actual instance! Some of the thumbnails might take a while to load. That is because they are not thumbnails but giant, giant images.

It uses ExternalInterface and Javascript to display the descriptions in the HTML. I’ll post the relevant code with an explanation next time, but let me tell you right now – having more than one gallery per page doesn’t pose a problem ( programmatically ).

The gallery is described by XML, and added to a page with a simple Javascript call.

.