Search Logger
It's All About Search

In the YUI 3 Gallery: Matt Snider’s Number Module

8:45 pm - March 10, 2010 in Yahoo! User Interface Blog

About the author: Matt SniderMatt Snider is the lead frontend engineer for Mint.com (now a part of Intuit), where he makes extensive use of YUI in the presentation layer. He is also the author of a popular blog on JavaScript. Matt contributed the YUI 2 Storage Utility to YUI and is an active community member; you can see his presentation from YUICONF 2009 on YUI Theater.

Natively, JavaScript has a very limited set of functions for working with numbers located on the global Math object. Mostly these functions are for working with exponents, trigonometry, and rounding. And while these functions are needed and efficient, the Math API has remained unchanged for years, and probably won’t be improved anytime in the near future. So it is up to the developers of JavaScript libraries to create and maintain a component for working with numbers.

The Number component in the YUI 3 Gallery, derived from work originally used on Mint.com, aims to fill in missing number-related functionality. It provides a light-weight set of static functions for working with numbers. The Number component weighs in at about 1.8kb after minification and before gzip; it’s supported by all A-grade browsers.

One of the features in Number that I use the most is the format() function, which injects a formatted number into a string by evaluating the format of the placeholder number in the string. (Note: This is similar to the formatting support Y.DataType.Number currently provides, but rolls up the separate configuration properties which Y.DataType.Number.format accepts into a single formatting pattern string.) The function works with all symbols, but it formats numbers according to the English standard. Here are a few example of how to use format() from its unit test:

var n = 1111.11,
	formatDollars = "$0,0.00'" // use comma and decimal when formatting
	formatPercent = "0.00%", // use decimal when formatting
	formatRound = "0,000", // use comma when formatting
	formatText = "Please add the $0,0.00 to my tab!";

Y.Assert.areEqual("$1,111.11", Y.Number.format(n, formatDollars));
Y.Assert.areEqual("1111.11%", Y.Number.format(n, formatPercent));
Y.Assert.areEqual("1,111", Y.Number.format(n, formatRound));
Y.Assert.areEqual("Please add the $1,111.11 to my tab!", Y.Number.format(n, formatText));

Other useful functions include:

  • random(): provides an easy API for getting random whole numbers;
  • isBetween()/isNotBetween(): simplifies the evaluation of number ranges;
  • radian()/degrees(): when working with the Math trigonometry functions (such as Math.cos()), which expect radians instead of degrees, both radian() and degrees() are useful for converting values.

To use the Number allery component, first include the script:

<script
src="http://yui.yahooapis.com/combo?3.0.0/build/yui/yui-min.js&
gallery-2010.02.22-22/build/gallery-number/gallery-gallery-min.js"></script>

Then include 'gallery-number' in your use() function, to get the following functions:

YUI().use('gallery-number', function(Y) {
	Y.Number = {
		degrees(number),
		number(number, format),
		getPrecision(number),
		isNotBetween(number, number, number, boolean),
		isBetween(number, number, number, boolean),
		isPrime(number),
		radians(number),
		random(number, number),
		roundToPrecision(number, number)
	};
});

These functions were modeled after the native Math functions and, like the Math functions, the functions on Y.Number return NaN if the value provided is not a number. If you would like to contribute to the development of or require new features added to Number, please leave a message on the Forum.

 

Consumer Recalls & Peace of Mind

2:29 pm - March 10, 2010 in My Yahoo! Blog

Child safety seats. Toyota cars. Pringles potato chips. All three have been the subject of recent recalls because of concerns about consumer safety. But if you hadn’t watched the news to learn about the Pringles recall, how would you know whether the snacks in your pantry might make you sick? 

Fortunately you can subscribe to feeds from various consumer watchdogs and monitor them on your My Yahoo! page. Here are some good examples to consider:

You can also explore the sites above for specific recall updates on drugs, dietary supplements, or children’s products, among others.  Subscribing to any of the above feeds will make it much easier to keep tabs on safety information for everyone in your household.
 
Apps mentioned in this post:

Tom
- My Yahoo! Editorial

 

Working with the HTML5 Community

4:23 pm - March 9, 2010 in IEBlog

We’re always excited to engage with members of the W3C including the developers of other browsers as well as the broader web development community to help shape the direction of emerging Web standards, particularly HTML5.  This includes participating in events like TPAC, which we wrote about in November, and on-going engagement with various working groups.  Patrick recently talked about joining the SVG working group, and I’d like to share a brief list of other happenings on the way to making HTML5 well-defined, well-tested, and accessible:

  • Providing feedback on HTML5
    Tony Ross, Internet Explorer Program Manager, and Jonas Sicking of Mozilla, led a discussion about extensibility in HTML5 at TPAC after our initial submission.  While the working group hasn’t resolved the issue yet, we think the event helped inform everyone and generate the different proposals submitted since. 
  • Testing HTML5
    Kris Krueger, Internet Explorer Test Lead, was appointed facilitator of the W3C HTML5 Testing Task Force.  The task force has set up necessary infrastructure like a wiki, Bugzilla, a work item tracker, and CVS repository for test cases.  With that in place, they’ve started to review DOM Level 2 HTML test cases to use as the start of HTML5 testing.  As with CSS2.1, we think a good test suite is critical to ensuring a specification results in interoperable implementations.
  • Ensuring new specifications enable accessibility
    We care deeply about an accessible web so besides implementing accessibility-focused browser features, we’re working with Apple, IBM, and other interested parties to ensure the new HTML5 <canvas> and <video> elements have great accessibility support so everyone can use sites leveraging them.  This work is driven by the Accessibility Task Force.  Together, we’re working on <canvas> HTML prototypes to use as ‘proof of concepts’ to ensure the feature is well-designed, as discussed in a recent teleconference
  • Indexed DB Proposal
    Together with Mozilla, we’re excited about a new design for local storage called Indexed DB.  We think this is a great solution for the web.  Look for another post with more information about this proposal.  In the meantime, you can read the latest working draft
  • DOM Level 3 Events
    Travis Leithead, Internet Explorer Program Manager, continues to help close down open issues with the latest editor’s draft. It’s been awhile since the working group published the last working draft and the group plans to publish an update soon that will improve clarity for implementers and web authors alike. On a recent teleconference, we noted that DOM Level 2 Events was published as a Recommendation nearly 10 years ago; it’s exciting to have the next milestone in sight!

Finally, you can read an interview with Paul Cotton from Microsoft and co-Chair of the W3C HTML Working Group on the W3C Blog.

Adrian Bateman
Program Manager

 

YUI Theater — Douglas Crockford: “Crockford on JavaScript — Episode IV: The Metamorphosis of Ajax” (93 min.)

3:40 pm - March 9, 2010 in Yahoo! User Interface Blog

Douglas Crockford delivers the fourth lecture in his his Crockford on JavaScript lecture series at Yahoo on March 3, 2010.

Last week, Yahoo! JavaScript architect Douglas Crockford delivered the fourth installment of his Crockford on JavaScript series:

  1. Volume One: The Early Years
  2. Chapter 2: And Then There Was JavaScript
  3. Act III: Function the Ultimate
  4. Episode IV: The Metamorphosis of Ajax
  5. Part V: The End of All Things (March 31 — RSVP)

In this session, Douglas tackles the DOM. On the one hand there was JavaScript, he says, and JavaScript is “what made the browser work.”

On the other hand, there was the Document Object Model, also known affectionately as the DOM. It is what most people hate when they say they hate JavaScript. Most of the people who say they hate JavaScript don’t know JavaScript, might have never seen JavaScript, but they’ve felt the DOM alright. If you don’t know what the difference is and you say, “JavaScript is the stupidest thing I’ve ever seen,” you’re not talking about JavaScript, you’re talking about the DOM. The DOM is the browser’s API. It is the interface. It provides JavaScript for manipulating documents.

The DOM may be imperfect, but it’s nonetheless crucial to what frontend engineers do when they write web applications. In this talk, Douglas provides an overview, situated historically, of where the DOM came from, how it achieved ascendance with Ajax, and what the future might hold. In Douglas’s inimitable fashion, this history starts with Sir John Harrington and takes us up to the present day. A few choice words for CSS are among the many applause lines for veteran developers:

I find within the community of people who use CSS great affection for it. They’re totally invested in CSS, they love it. They can’t imagine any other way of doing formatting in a document. It’s it. It’s sort of like watching an episode of Cops where the cops come in and break up the family dispute, and there’s this “CSS ain’t bad, you just don’t understand it like I do. I know it hurts me, but I make mistakes, I’m wrong.” CSS is awful, and it amazes me the way people get invested in it. It’s like once you figure it out, kind of go “oh, OK, I see how I might be able to make it work,” then you flip from hating it to loving it, and despising anybody who hasn’t gone through what you’ve gone through. It doesn’t make sense to me.

If the video embed below doesn’t show up correctly in your RSS reader of choice, be sure to click through to watch the high-resolution version of the video on YUI Theater.

Other Recent YUI Theater Videos:

Subscribing to YUI Theater:

 

YUI 3 Gallery Contest 2010 — Win a Ticket to JSConf 2010

5:12 pm - March 5, 2010 in Yahoo! User Interface Blog

We’re pleased to announce the YUI 3 Gallery Contest 2010. Thanks to our friends at the Yahoo! Developer Network, we have a conference pass to the sold-out JSConf 2010 to offer. We’re pairing that with a $500 gift certificate to Expedia.com to help the prize winner get back and forth to Virginia for the conference.

The prize will go to the person who authors the best new YUI 3 Gallery module between March 5 and March 22 and submits it for community use under YUI’s BSD license. As with any contest, there are lots of rules. We’ve noted some of the big ones on the contest page and you can read the full legal writeup here.

We’re thrilled with what we all as a community have done since late 2009 to make the Gallery a hotbed for YUI 3 growth and innovation. Greg Hinch’s Form module (submitted hours after the Gallery opened), Ryan Grove’s excellent Storage and History modules, Ilyan Peychev’s über-popular Accordion, Julien Lecomte’s SimpleMenu, Stephen Woods’s Timepicker, Adam Moore’s TreeView, Jeff Craig’s Chromahash, Dav’s own YQL module…and dozens more.

We hope you’ll consider doing some YUI 3 hacking over the next few weeks to add to this collection. We’ve listed some resources on the contest page, and there’s a forum thread going with ideas for new modules (please weigh in there even if you’re not going to be writing a module for the contest yourself). And, of course, the current Gallery is a good source of inspiration.

Happy hacking, and we’re looking forward to seeing a YUI Gallery author head out to JSConf next month!

 

IE8 SmartScreen Filter – Protecting Users at Internet Scale

4:44 pm - March 5, 2010 in IEBlog

The RSA 2010 Security Conference is just finishing up here in San Francisco, and I’m struck by how many of the conference sessions and keynotes have warned about the threat that socially engineered malware poses to the security of the Internet. Malware has become the scourge of the Internet, and it’s not just the security experts who are worried—the top story in my morning paper yesterday described how a typical malware attack compromised a financial firm’s network. Our data shows that one out of every 250 downloads is the result of a user being tricked into downloading malware to their PC.

We’re proud of the protection SmartScreen® Filter provides to protect IE8 users from such attacks, and I’d like share some of the latest numbers on our level of protection.

Since we launched IE8 in March 2009, SmartScreen has blocked over 560 million attempts to download malware, recently averaging over 3 million blocks per day! Hosted in datacenters around the world, SmartScreen’s URL Reputation Service (URS) has evaluated over 250 billion URLs to help keep IE8 users safe from malware. Even more impressively, since IE7’s Phishing Filter was introduced in 2005, the URS has processed over 5.7 trillion reputation requests in order to block malicious web sites. Every day, Microsoft receives around 300 million telemetry reports from IE8 users and processes 4.1 billion URLs looking for malicious websites and files. On the back end, our systems and analysts evaluate over 1 terabyte of binaries every day to help identify sites delivering malware.

The Q1 2010 NSS Lab’s test shows that Microsoft’s continued investment in SmartScreen is paying off. Since launch, IE8’s SmartScreen Filter has continued to improve its protection against Socially Engineered Malware threats.

line graph of browsers malware block rate.

IE6 and 7 don’t provide protection against socially-engineered malware. If your family and friends aren’t up-to-date, please encourage them to upgrade to IE 8 for a safer Internet experience.

While IE8 offers the best built-in protection any browser offers against socially engineered malware, you still should follow best-practices to stay safe online. For instance:

  • Enable SmartScreen Filter using IE8’s Safety menu (safety menu icon).
  • Install antivirus and antispyware software from trusted sources and keep it up-to-date. Microsoft Security Essentials is available for free.
  • Turn on your firewall.
  • Enable Automatic Updates for Windows and other Microsoft software using Microsoft Update.
  • Keep your computer's other software, including browser add-ons, up-to-date.
  • Before downloading software, consider the risks and be aware of the fine print. For example, make sure the license agreement does not conceal a warning that you are about to install software with unwanted behavior.

You can read more tips and learn about common Internet attacks over on the Security Tips blog.

Stay safe out there!

Eric Lawrence
Program Manager

 

W3C HTML Working Group Publishes New Drafts

11:56 am - March 5, 2010 in IEBlog

Last week, the W3C HTML Working Group reached a decision to publish several new working drafts and these are now available. The discussion about what to publish and how to structure the HTML5 specification has taken several months. In November, at the TPAC meeting, a request was made for the Microdata section of the specification to be removed. Back in August, I posted about our support for a separate Canvas 2D API specification.

Some people in the community raised concerns about exactly what should be in scope for the HTML working group. Tim Berners-Lee shared his thoughts:

“I agree with the WG chairs that these items -- data and canvas -- are reasonable areas of work for the group.  It is appropriate for the group to publish documents in this area. On the one hand, they elaborate areas touched on in HTML4. On the other, these elaborations are much deeper than the features of HTML4, but also they form separate subsystems, and these subsystems have strong overlaps with other design areas. It is important (a) that the design be modular; (b) that the specifications be kept modular and (c) that the communities of expertise of the respective fields (graphics and data) be involved in the design process.”

We strongly support Tim’s call for modular design and modular specifications in web standards. Large monolithic documents are hard to consume and take longer to stabilise with well thought out engineering decisions. In fact, the decision to take these features from HTML5 and make them separate documents continues the process that started last year as the storage and networking APIs were moved out of HTML5 and into the W3C WebApps working group. Just like good software design, loose coupling and high cohesion are good principles for defining web standards. That doesn’t make them easy to apply and there is still more work to do to reduce the coupling between drafts. The group is working on improving the tools used to generate the documents to improve the cross-references, which will help towards this goal.

Microdata and Canvas 2D are now available as new working drafts alongside the core HTML5 draft. This also sets Microdata on a similar footing to the updated HTML+RDFa draft. You can review the full set of documents published yesterday here:

Adrian Bateman
Program Manager

 

Hello world

9:46 pm - March 4, 2010 in Blogger Buzz
Yahoo CEO Carol Bartz continued to talk about Yahoo’s regrouping strategy at an advertising industry conference earlier this week.
She touched on the topics we covered in our post last week, The Steady, Efficient Decline Of Yahoo. Specifically, she’s counting on an improvement in the economy to drive Yahoo growth, and she claims to have made significant advances in display advertising tools, targeting and analytics. “People still have to display their brand in a more descriptive way than just keywords,” she told Advertising Age.
When asked if Yahoo was any different from AOL, she responded “Generally it’s not different, we’re just a lot bigger. The fact of the matter is, what they’re trying to do at AOL — and I shouldn’t speak for AOL, they’re very capable of speaking for themselves — but I think it’s like a mini Yahoo.”
AOL draws 110 million monthly unique U.S. visitors, says Comscore, compared to 164 million for Yahoo (January 2010).
Bartz also says Yahoo will be making acquisitions to drive content. “This year it’s about what technologies: Do we need to fill in the blanks, what analytics, what tools?” she said.
She added “Well just imagine whether it’s acquiring an audience — a group of female bloggers, or whether it’s acquiring some better analytics tools that help us guide campaigns with our partners, or whether it’s technology.”




And “social” says Bartz, doesn’t begin and end with Facebook: “You know, social is a word that has almost become too narrow. And I think with Facebook’s immense success, all of the sudden that’s the only definition of social. But if you think back to the finance chat rooms, [those] were the beginning of social and people could actually interact. … As we look at social we want people to be on the Yahoo site and have tweets come in and have their Facebook postings come in, so that it’s a very personal place to be that helps them understand what’s going on in their social world.”
In Bartz’s social world, it seems, people are reading Twitter and Facebook messages on Yahoo. But this patchwork strategy of taking a little of this, a little of that isn’t going to excite users and encourage them to spend much time on Yahoo. Despite their massive reach, time on site isn’t going anywhere.
But at least we know where Yahoo stands on things. Little or no product innovation, little or no risk taking. And like I said before, a long, slow, steady decline. And despite Bartz’s last words in the interview, copied below, there is nothing exciting or crazy going on at Yahoo.
For an industry that’s based on creativity and inspiring people, I don’t know why it’s so afraid. I don’t think it should be afraid to just try some crazy new stuff. But when I talk to people about online marketing, they just seem to freeze. … I thought this was going to be a much racier industry that wore black and got out there and rock and rolled and I see it being a little shier. I mean, I’m the crazy lady.
 
 
 
 
 
 
It's All About Search | © clsc.net |
2010.03.1104:02
Tech used here: Valid HTML - Valid CSS - Valid RSS - JavaScript - PHP - Smarty - MySQL - and a partridge in a pear tree.