Compartir a través de


Working on the script, and some thoughts

I decided to put the OpenFileNames wrapper on the back burner, and get actual progress done today. I fleshed out a bunch of javascript that allows users to type in multiple file names, or paste them from excel (column & row delimited parsed correctly), and add them to the bottom of the page for later submission... this was functionality that was already required, the browsing dialog is just be a speedier alternative. I did a bit of research today to solve some problems, links and notes below.

This was good that I stopped working on the wrapper... in my 1-on-1 with my manager, Mike decided to punt the browsing functionality. Version two will be a deployed smart client, and he didn't want to force the users to download anything for v1. I also raised the idea (now authorized) of having another spec review, this time of a subset that would just make sure we have all the data-entry fields, options, and tool-tips necessary.

Various scripting links
I wanted to use the VBScript trim function from JavaScript, and found that it was possible, but first ran into the headache-inducing problem that "The first used scripting language determines the language for event handlers." Note: I don't think this is normally a good idea, but in my case I'm creating an IE-only quick mockup (and noted in my code comments that this "hack" is IE only).

I could have used one of the many javascript Trim functions out on the internet, but one of the restrictions to working at Microsoft is that you have to be extremely careful what code you copy & paste off the internet. In fact, you pretty much don't. This is a very real restriction, and employees understand that you just don't take other's IP, and that the implications of infringement is very... very... bad. So... yeah, I didn't feel like implementing my own Trim when VBScript is a few lines away. :)

I also needed to do some replacing of characters, for which regex came to the rescue. This site explains the problems you can run into when working with the end-of-line characters. I ended up doing the following to support the Excel pasting into a TextArea: tempfiles = document.forms[0].FileEntry.value.replace(/(\r\n)/g, '\t').split('\t'); Rows are \r\n delimited, Columns are \t delimited... convert the \r\n's to \t's, split the string into an array based on \t's, and you have an array of file names.

I'm creating HTML on the fly, and was wondering about the why behind the two identifiers (NAME and ID). This thread does a great job of explaining what happened in the W3C, and when NAME is still appropriate.

Finally, I just rediscovered the excellent (in my personal opinion, of course) site of DevGuru. They have very handy quick reference guides; for example, their member sections include enough information to be useful without having to click to each function definition. I used DevGuru and 4 guys from rolla all the time when coding three-tier applications for Universal Studios six years ago. Anyways, I'm itching to try this idea they have for a combo box that doesn't interfere with DIVs. If this works, my tooltips can come in from the shadowy corners of the page, and hover right next to the control they are about. I'm sure they'll be happy.

Some thoughts
You know, I feel like I'm coming across as a programming neophyte in these blogs, not as a developer with 10+ years experience. Now, when I started the blog I didn't intend to wow you with my supreme knowledge or anything, but I didn't expect to be blogging about so many problems and discoveries. Of course, these problems and discoveries will probably be getting much more interesting when I start working on the v2 client... in WinFX.

I suppose that's what happens when you're stretching yourself outside your normal domain, which certainly happens a lot at Microsoft... you discover how much you really have yet to learn. :)

Comments