I spent WAY too long today fighting an issue that turned out to be fairly obvious in the end.

I’m working on a web-based application that gives our internal users a front-end to our billing system for quick access to support information.  I’ve recently re-worked the whole thing to take advantage of modal windows, which has greatly cut down on a lot of the navigation time needed by our techs to find the information they need.

Anyway, one of the items I’ve had on my list to work on is to make it possible to print the contents of the modal windows.  With the old version of the app, the info would have populated the entire browser window and was easy to print.  With this new system, a window print would obviously print way to much.  In addition, it wouldn’t print everything in the modal window, just what was currently visible due to scrolling.

Rather than re-invent the wheel, I decided to try a jQuery plugin.  After reviewing what was available, I picked jQuery Print Element.  It was a fairly recently released plugin, which hopefully meant it would be compatible with current browsers.  It also had some flexibility in use, which I thought would be helpful.

I downloaded it, added the relevant <link> and Javascript code to implement it, and voila!  When I clicked on my “Print” link, the contents of the modal window appeared in a popup window, and a Print dialog opened.  When I selected to Print or Cancel the dialog, the popup window closed automatically.  Perfect!  Well, almost….

Within the layout of the modal window were a few tables – YES, for tabular data.  The problem was, their font size was much larger than expected.  I used Chrome Inspect Element to look at the CSS and inheritance, and it just didn’t make sense.  My modal window tables were inheriting a font-size of 70% from the main <body> tag and looked normal.  My popup window, in contrast, claimed to be getting a font-size of medium from a user agent stylesheet.  Wierd, especially since when I double-checked my stylesheets there definitely wasn’t any other references to font-size.

I went off on a tangent for awhile looking at the <link> media option, mainly because I’ve never had to worry about it before and it was set differently in my modal window code than in the popup code.  No luck there, but it was worth it to learn more about that feature.

So, right before time to call it a day, I figured out what was wrong.  The HTML generated by the plugin didn’t pay any attention to my DOCTYPE that I used on my main application code.  In fact, it didn’t set DOCTYPE at all, so apparently the browsers were running in “quirks” mode.  In quirks mode tables don’t inherit font-size attributes from their parent tags.

A quick hack to insert the DOCTYPE code into the plugin and things were happy.  Now I just need to go back and build that into the plugin to be automatic and duplicate the DOCTYPE from the main browser window and submit it back to the author.

All in all, a frustrating problem, but when it worked right at the end, it was a sweet victory!

Now, those of you that have been doing web design for years, please don’t make fun of me for this one.  Bear with me, I’ve been a network and unix admin for many more years than I’ve been a web designer.

Anyway, I’ve been working on the new version of my web application at work.  I’ve been integrating cool stuff like jQuery, javascript, modal windows, etc…, that are taking what was an ‘okay’ appication and turning it into something that is user-friendly and ‘easy on the eyes’.

As I develop, I use Chrome and Firefox for debugging.  Chrome is my first choice, primarily for it’s clean interface and it’s speed.  I switch to Firefox if I’m having javascript problems and can’t get the errors in Chrome.  If things work right and look right in Chrome and Firefox, I’m happy.

Yesterday, however, I decided to start showing off the new bells and whistles of the app.  Wouldn’t you know, the first person I asked to take a look was using Internet Explorer.  I use IE for one thing and one thing only, and that’s a particular web interface to a piece of hardware that will only run on IE.  For me, IE is slow and clunky, and it’s toolbar is hard to get used to.  So, she pulled up my new fancy app in IE, and it looked awful.  I had problems with label alignment, div floats, div scrolling – just a big mess.

So, I did some research today, and found a magical solution to my problem – DOCTYPE.  Apparently my lack of DOCTYPE was causing the browsers to go into ‘quirks’ mode (again, you veteran web developers probably already know about ‘quirks’).  I’d read in passing about DOCTYPE and ‘quirks’, but I’d never really dug into it much, thinking it wasn’t something I needed to worry about.

So, I added DOCTYPE to my code, and after fixing a few non-standard tags (that were okay in ‘quirks’), suddenly everything looks great cross-browser.  Needless to say, I’m thrilled.  Now I’ve just got to finish up the rest of the changes, and all my users will get a fresh new-and-improved app to use.

In the web application I’m working on, I have a long list of reports that are available to the end-user.  When they click on a report, I create a modal window and display the output of the report in the window.

As a part of that process, I use jQuery to bind the “click” event of the <a> tags of the report links to a javascript function.  Since I block the normal event, the page doesn’t reload, and I can just use a jQuery post to retrieve the results into the modal window.

Well, that was fine until I started working on some reports that have links WITHIN the report that can be clicked upon to run the report again with modified parameters.  Since those links were created dynamically, I had to have my report function re-bind the click event of all the new links.  Because of how I coded it, I was also re-binding all the main report links.

What I didn’t think about was that since I didn’t unbind the click event from the links first, I was adding another click event to the links, ending up with multiple events triggered on each click.  Normally this would have just been a confusing annoyance.  In my case, however, the reports all open up ODBC connections to the backend database of our billing system.  That database has a limitation on the total number of connections allowed.  Yes, I was maxing out the connections, preventing any new connections to occur.  Not only that, the database in question decided to lock up when the connections maxed out, rather than letting them time out gracefully.  So the billing system tech support had to completely shut down and restart the database to get things going again.

If that weren’t bad enough, the symptoms we were seeing led us in a completely different direction in troubleshooting what we thought was a billing system problem.  It took 2 days and 3 system lockups before I could decipher the problem and realize what was happening.  Even then the logs didn’t 100% match up with what I thought was happening.  However, I adjusted the code to make sure it couldn’t duplicate the click binding, and so far so good.

Anything can happen in the wonderful world of Information Technology – and it probably will.

My latest programming project has been fairly interesting.  Part of the project involved a cron script that opened a telnet session to a remote device, gathered information, and logged all of the info to a text file for review.

The script has since been fleshed out.  Now it pulls a list of devices from a mysql database.  It loops through the devices, gathers the information and saves the data to another table in the database.  A web interface has been created that allows an administrator to make configuration changes to the settings that are stored in the device table.  It also gives the user the current device status and the ability to search for historical information gathered from the devices.

Years ago, I would have ended up with lots of individual scripts, all written in Perl and HTML.  It would have been clunky and ugly, and I would have been unhappy with the results but unsure what to do about it.

These days, I’m able to combine many different tools, all of which have different uses.  The cron script is written in Perl, mainly because the original script was in Perl and I didn’t want to start over on it.  The web interface is in PHP.  I use Javascript to do some neat DHTML stuff, like adding new rows to tables and switching between DIV tags.  The backend databases are Mysql for storing the data and Progress (I pull information from our billing system to cross-reference and find user name and other information).

Yes, those are a lot of different tools, and yes, it’s hard to keep up with all of them and be proficient in all of them.  However, that’s what it takes to be able to produce quality, professional-looking web-based applications.  I know I’m much happier with my final results than I would have been several years ago.

This time it’s just annoying, and I have a workaround.  But, annoying IS annoying.

Progress DB on the back end server.  PHP/Apache using ODBC with unixODBC and DataDirect drivers for Progress.

For whatever reason, I cannot odbc_execute this SQL: “select count(*) from table”.  It errors out with a 158 SQL State 9 every time.  I CAN, however, use isql to test the command and it works fine.  I can use PHP/Apache to run similar commands against MySQL tables.  There’s just something about that combination that isn’t allowing the count() to get through the unixODBC/DataDirect layers.  Not only that, but I’ve never been able to get the LC_MESSAGES worked out for these DataDirect ODBC drivers, so I can’t get the REAL message that goes with that 158 to tell me what’s wrong.

Very frustrating.  For now, until I have time to work on the issue more, I just read in the rows one at a time and increment a counter.  Not exactly the most efficient way of doing things, but it’s getting the job done for now.

Wow, it’s been a long time since my Oracle DBA days.  I’m getting deeper and deeper into my latest project that includes a lot of MySQL DB work, and I need to spend some time looking into things that I long forgot about, like foreign keys, constraints, and indexes. What fun!  I love this stuff! [...]

© 2010 Virtual Adept Suffusion WordPress theme by Sayontan Sinha