Number.prototype.roundToDecimalPlace = function(numDecimalPlaces)
{
var currentVal = this;
var multiplier = Math.pow(10, numDecimalPlaces);
var roundedNum = Math.round(currentVal *= multiplier) / multiplier;
return roundedNum;
}
|
|
![]() |
![]() |
![]() |
![]() |
|
||||||||||
|
Function: Number.roundToDecimalPlace — July 31, 2007
// usage: myNum.roundToDecimalPlace(2); // If myNum was 152.15759, will return 152.16
Number.prototype.roundToDecimalPlace = function(numDecimalPlaces) { var currentVal = this; var multiplier = Math.pow(10, numDecimalPlaces); var roundedNum = Math.round(currentVal *= multiplier) / multiplier; return roundedNum; } xgettext woes — July 28, 2007
Boy this was a pain. Here's the UNIX command for generating a .po file from all PHP files in a folder (and subfolders). - Note: the messages.po file needs to exist first. It still produces a bunch of warnings, but I gather they're harmless. Flash Image Scroller Update (1.5) — July 26, 2007
The image scroller now includes code from the Flash / JavaScript Integration Kit written by Christian Cantrell and Mike Chambers from Adobe. This allows for full integration between Flash and javascript - very handy stuff. On a sidenote, Mike and Christian are now on the Adobe AIR team. I actually met Mike very briefly when he came to Vancouver earlier this month on the AIR Bus Tour. Nice chap - and small world! A big thanks to Digital Nemexis for sponsoring this feature. 2008 Presidential Election Candidates on the Issues — July 25, 2007
Some kindly soul has condensed the views of all the presidential candidates on a number of hot button issues into a single table for easy reference. So if you feel particularly strongly about something - like immigration reform or same sex marriage - and want to see how a particular politician sizes up so you can make a rush to judgment, look no further! Chris Dodd wants to ban assault weapons? Bloody hippy. He just lost MY vote. Tutorial: Setting up a PayPal-Enabled Form with Form Tools — July 15, 2007
This was something I promised to write a good year ago, but never managed to find the time. I've tried to make it as clear as possible. Hopefully it'll help out those developers who need to add PayPal-enabled forms on their site (and hopefully this'll placate the folks who keep asking for it!). Function: Array.removeAllOccurences() — July 13, 2007
Removes all elements from an array that have a particular value. Array.prototype.removeAllOccurences= function(value)
{ var newArr = []; for (var i=0; i<this.length; i++) this.length = 0; for (var i=0; i<newArr.length; i++) Next Page » |
![]() |
|||||||||||||
|
![]() |
|||||||||||||