Wednesday, February 27, 2008

Save yourself the effort of defining the same code for multiple javascript events

If you ever have a situation where you basically want to run the same code for a bunch of different events on an html element like an input, it's a pain in the ass to maintain if you change the logic and need to change all of the event parameters. I discovered you can directly call another event so you don't have to define and maintain the same code in multiple places. I realize you can do something very similar by using addEventListener, but I just thought this was kind of cool.

e.g.
// define the onchange event and call the same code for onmouseover, onmouseout, and onclick

// Now if you make changes to onchange, you don't need to copy those changes to the other events.


<input ... onchange="myFunctionDoYouLikeIt(this, 'valueadded', false, 0); compareSomeValues('placeholder', false, true, 'the google webz');"

onmouseover = "eval(this.onchange + '\;anonymous()\;');"

onmouseout = "eval(this.onchange + '\;anonymous()\;');"

onclick = "eval(this.onchange + '\;anonymous()\;');" />

Friday, February 22, 2008

Combine multiple Twitter feeds on Blogger

This Blogger widget I created is based on the original widget provided by Twitter. This one, however, will let you combine multiple users' feeds into one and sort them by time. This is as opposed to showing your entire timeline, including everyone you follow. Perhaps someone has already written something like this, but damned if I could find it. Constructive criticism is welcome, particularly since this is my first crack at creating a blogger widget.

Configure and add the widget here.

I promise to post more documentation for this feature later, as there are other nifty things you can do to control the style of the output, including creating a "mask" to define the format of your output, and inclusion of data like the user profile, user homepage link, user profile image, etc.

Caveats: The number you are defining in the form does NOT mean that only the last n posts from your pool of users will appear. It means that the last n posts from each user will be shown. For example, you've set the twitter number to 3. User1 posted a single twitter 4 days ago, but User2 posted 4 twitters today alone. You will see the last 3 posts from User1 and the last 3 posts from User2.

Tuesday, February 12, 2008

A warning regarding calculating sales commissions in NetSuite

Are you seeing discrepancies in your sales commission figures? It recently came to our attention that when calculating sales commissions, NetSuite's sales commission module ignores the first line item on a transaction (invoice, sales order, etc) if it is a markup item, discount item, etc. They claim this is by design but cannot produce any existing documentation that would have clued us in on this "useful feature." Unfortunately for us, a large portion of invoices had markup items or discount items on the first line. Since NetSuite continues to insist this is not a bug, I ended up having to write a script to re-sort the item lists for all of our 2008 invoices for sales commissions to be properly calculated. We have verified that this fixes the aforementioned issue. However, I have to wonder what would happen if an invoice ONLY had markup or discount items on it. Sure, you can argue "why on earth would you not have a service or inventory item on your invoice??" Then I would slap you and remind you that it's the principle.