SWFObject 2.0 and multiple videos on your blog front page

So with as easy as posting videos is from Windows Live Writer, a problem that bugs me is their use of the <embed> tag and its non-compliance to web standards. Of course leave the tag out and many browsers won’t work properly.

Through a couple of pieces of information from multiple places I finally figured it out.

First step is to download swfobject 2.0.

Next is to of course include the swfobject code into your page. Do this by including the following into the <head> of your blog (likely located in header.php or something similar):
<script type="text/javascript" src="swfobject.js"/>

Finally include the following code block where you want your video placed in the post:

<div align="center" id="mov2009081101">
    You need the Flash Player to view this video.
<script type="text/javascript">
    var flashvars = {};
            var params = {};
            var attributes = {};
            attributes.id = "swf2009081101";
            swfobject.embedSWF("http://www.youtube.com/v/2Fb-p5TkAE4&amp;hl=en", "mov2009081101", "425", "355", "9.0.0", false, flashvars, params, attributes);

You will need to replace “mov2009081101” and “swf2009081101” in all places with two different strings unique to the movie. The problem is if you have multiple movies on a page, whether the front page, a category listing, or whatever, duplicate ids will conflict. The ones I included above were simply the date of the blog and a 2 digit enumeration. With all of this done, flash videos should now be viewable for everyone AND your page should pass W3C validation.


Pretty awesome when business areas come together

So as mentioned below, we are doing an inventory project for badger that’s pretty extensive. Basically it will keep recent books in one area sorted by week, and then older books in another area collated together into one mass inventory. pretty simple.

Here’s the trick. I just created a universal order pull list application. Basically you can select any number of orders, click generate, and a list will be created for every item that needs to be pulled. pretty simple hey? It gets even better. This list generator will check the last five weeks and individually flag items for the week they came in if they happened to arrive (either in a new order or a reorder) that week. But we’re not done yet. It color codes them based on a coding system involving color sorted boxes and cycling the oldest colored box into inventory and replacing its contents with books from that week. whew.

But this isn’t really to talk about the workings of the inventory system. This is to talk about how cool (and interesting) it is when something you are really good at (programming in my case) perfectly coincides with something you have only a little experience with (business logistics and physical asset management in this case). I ended up creating a basic physical location based inventory system and programmed a picker application that can work within this system. Most reading this are probably saying “So what?”, but when you look at where I started this whole experiment from and where it’s arrived at now it is really an interesting road. This is something I wouldn’t have even realized I needed two years ago, but now here we are with a full custom built physical inventory management system.


I FINALLY FIGURED OUT A USE FOR AJAX!!!!!!!!!!!!!!!!!!!!!!!!!!

Sorry for the over enthusiastic title, but I am freaking psyched. Beyond psyched. I feel like I’m somewhere between having found the cure for cancer and having found the answer to world peace.

AJAX. Asynchronous Javascript and XML. It’s a technology where using Javascript on a page, you can make asynchronous XML requests back to a script on a site and update the page you are on without having to reload the page. One of the most common uses out there for it is the “suggest a search” feature you see on a number of sites, including the search bar of IE7 and Firefox 2 along with Google’s site. I have been looking for a way to incorporate AJAX into something, anything, I’m working on as it seems like something fun I can play around with. My first thought was to work on an addition to Badger’s search bar but well… I’ll do it but it hardly seems fun to work on something that’s been done to death. Well damn.. what else is there? THAT’S what I’ve figured out.

When I am uploading the invoice for a week to insert inventory, I have to select the title/category these issues are going into. If it’s Batman #600, I have to stick it in the Batman (1940) title/category. I accomplish this with a simple drop down box. It works and works well. However my uploaded invoice appears as one huge editable form with our 100+ books on it simultaneously. Originally I would try and go through the entire invoice and create categories for all newly added titles not previously available on the site. What would frequently (re: always) happen is I would be 60 items down on the invoice and come across a book I missed. Oops. At that point I could either abandon the work on the previous 60 items, or I could stick the book in a placeholder section (usually ’68 heh) and fix it after I saved the upload. After a few weeks of this, I decided I had to come up with a better solution.

Version 2.0 of the invoice upload form simply added a text box. This text box was for generating a new category on the fly. I would enter in the coded new category information and the book would be automatically added to that category. This has worked well, except for a number of instances where multiple SKUs for a single new book might exist (most recently Hack/Slash #1). In this case, to properly create the book initially I would essentially create two categories identically. I then would have to go into the inventory system and move on book over to the same category and delete the duplicate. Still easier than before, but still not perfect.

Then it clicked, and by clicked I mean I honestly think there was a real lightbulb over my head that turned on. With AJAX, I can create new categories on the fly and actually have it update every drop down box on the page. When I come across a book that doesn’t exist, I just create a new category/title for it and say OK, and when I look at the list again the new category will be selectable on that book and every other book on the page. This will be one of the biggest time savers I’ll have done on the maintenance portion of the site.

The other one I can do, though a little more involved, is to dynamically save my progress on the invoice. It can take me up to 2-3 hours to get the invoice completed and uploaded. However that will require quite a bit of work and some new elements added to the database. So I figure I’ll start off small with this upgrade and upon its success move on to the bigger save feature.