Thursday, 23 July 2009

Websiting

This morning I was doing some more work on my photo website. The main problem I had was that my custom XMP File Info panel wasn't saving the Iptc4xmpExt Location details correctly.

It took me quite a while to figure out what the problem was, and even longer to figure out how to fix it. The problem was that if I had a record that already had some Location Shown or Location Created data, if I clicked in any of those fields, and then saved, all the Location Shown or Location Created data would be lost.

To get round the XMP File Info SDK API not handling creation of array elements, what I had done was to make it so that when a LocationCreated or LocationShown element looses focus, I check if any LocationCreated or LocationShown data has been entered/exists, and then if it does, create a XMPTextInputMRU with an xmpArray property and a dataProvider (and of course the correct xmpPath). This then forces the XMP File Info Panel to create the necessary bag element, so that the array elements can be added to it.

The problem with this was that if the Location data already exists, then clicking in a Location field without editing it will cause the LocationCreated or LocationShown bag element to be created, so when the XMP File Info Panel is closed/saved, it will see the empty bag array and save it, thus overwriting the previously existing bag array with all your location data stored in it. It seems that the XMP File Info Panel won't actually attempt to save fields that haven't been edited, which is why the location data gets saved when you first enter it, but won't get saved if you click in a location field (but don't edit it) with existing data.

It took me quite a while to figure out how to only create the bag element when the data is first being entered, but not when the existing data is being edited. Eventually I found that I could just check whether the bag element existed, and if not then create it:
if(!xmpAccess.getPropertyList("Iptc4xmpExt:"+loc).toString())
{
//Create LocationCreated or LocationShown bag element
}


After lunch I went on Animal Crossing, then finished fixing my XMP File Info panel.

I went in the garden for a bit to try and take some photos, but it was too windy and all the plants were blowing about too much to get any photos of the insects on them.

Most of the afternoon and evening I was trying to figure out how to get a table to slideUp/slideDown or toggle() with jQuery, and also get the table width to be (and stay) 100% of the size of it's parent container. I found that my tables weren't wrapping to 100% of their parent container's width because I had put 'display: block' on the table, so removing this fixed the table width problem.

Whenever jQuery would show/hide a table though, it would make the table so it would no longer be 100% of its parent container's width. It seems that you can only change the height of a table if it is set to display block (or at least not whatever the default table display style is), and so this breaks the table's width. The solution was to wrap the table in a div, and then show/hide the div instead of the table.

It took me ages to figure those out though!

Also in the evening, I went out to try and get some sunset photos. It looked quite nice about an hour before sunset, but by the time I had got to the top of Lubenham Hill and set up my tripod (probably about 50mins before sunset), the sun had started to go behind a bank of cloud on the horizon, and was no longer lighting the fields.

Since I was there and had set my tripod and pano head up, I thought I might as well do a pano anyway.

Food
Breakfast: Blood Orange Marmalade toast sandwich; cup o' tea.
Lunch: Sicilian style ham with sliced vine tomato, iceberg lettuce and sliced peppers sandwich; Nectarine; Iced Lemon Madeira Layer cake; Fox's Triple; cup o' tea.
Dinner: Chicken pie; potatoes; peas; carrots; gravy. Pudding was Apricot crumble with custard. Coffee.

No comments: