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

NOTICE August 12, 2009: If you are having issues with the hosted version of my twitter widget (i.e. you are not linking to a local copy of the javascript file on your own server), it looks like my bandwidth has been exceeded on my googlepages account. Frankly, I can't imagine how that tiny .js file could exceed my bandwidth, but perhaps someone with a very popular site is linking to it. In any case, I'm working to find a permanent, alternate host. For the latest updates on this issue, check back here or follow my Twitter feed.

Oh, and I probably will have to find a paid host, so if you are a user of this widget and would like to help out, a donation would be appreciated (the Donate button is in the right hand column on this page).



UPDATE 1/25/2009: I have received a few feature and bug fix requests. That list is available here. I have a fairly packed schedule through the spring and mid-summer of 2009, so it may be quite some time before I am able to complete these. But you are welcome to download a copy of the code, add these or other features you'd like to see, and fire it back to me. This code is non-commercial, not-for-profit open source, so I will gladly give full credit to whomever contributes code if I decide to include it in the version that is distributed here. And while this is not-for-profit, if you should wish to thank me for the time I've invested in this project, I am happy to accept even the smallest PayPal donation (see the Donate button to the right on this page). ;-) And now back to the original post.

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.