2010年9月25日星期六

First we loop through all the link elements

Even though he had voted for Obama, McChrystal and his new commander in chief failed from the outset to connect. The general first encountered Obama a week after he took office, when the president met with a dozen senior military officials in a room at the Pentagon known as the Tank. According to sources familiar with the meeting, McChrystal thought Obama looked "uncomfortable and intimidated" by the roomful of military brass. Their first one-on-one meeting took place in the Oval Office four months later, after McChrystal got the Afghanistan job, and it didn't go much better. "It was a 10-minute photo op," says an adviser to McChrystal. "Obama clearly didn't know anything about him, who he was. Here's the guy who's going to run his fucking war, but he didn't seem very engaged. The Boss was pretty disappointed."

Cookies
Now we can change the style sheet. Cool. We have a more personalized page. Excellent. But we don’t have a personalized site. The preference is only applied to the current page; when we leave the current page the preference leaves with us. This situation, however, can be rectified with a cookie.

To store a cookie we need another function to return the current style sheet. We also need two functions to store and read the cookie.

To return the current style sheet we look for an active preferred or alternate style sheet and check its title.

First we loop through all the link elements in the document again. We then check whether the link is a style sheet. If it is, we check whether the style sheet has a title. This tells us that the style sheet is either preferred or alternative.

The last check is to see whether or not the style sheet is active. If all three checks return true, we have the current style sheet and we can return the title.


he other constraint of the physical world is physics itself. The radio spectrum can carry only so many stations, and a coaxial cable so many TV channels. And, of course, there are only 24 hours a day of programming. The curse of broadcast technologies is that they are profligate users of limited resources. The result is yet another instance of having to aggregate large audiences in one geographic area - another high bar, above which only a fraction of potential content rises.

The past century of entertainment has offered an easy solution to these constraints. Hits fill theaters, fly off shelves, and keep listeners and viewers from touching their dials and remotes. Nothing wrong with that; indeed, sociologists will tell you that hits are hardwired into human psychology, the combinatorial effect of conformity and word of mouth. And to be sure, a healthy share of hits earn their place: Great songs, movies, and books attract big, broad audiences.
These style sheets are enabled by default (they are “on” when the page is loaded). They can then be disabled if the user selects an alternate style sheet.

To make a style sheet preferred, the rel attribute is set to “stylesheet” and the style sheet is named with the title attribute.

Several preferred style sheets can be grouped together by giving them identical title attributes. These grouped style sheets are then all enabled and disabled together. If more than one group of preferred style sheets are declared, the first group takes precedence.

To make paul.css preferred, a title attribute is added, giving the default style a name.
This allows the visitor to personalize a site and choose his or her favorite scheme. They can also be used for accessibility.

John Legend is modern R&B's classiest male singer, bringing old-fashioned suavity to hip-hop soul; the Roots are the world's most versatile (and maybe best) band. Together, they have made a brilliantly conceived and executed album, reviving music from the Nixon-era heyday of politically engaged R&B. Bustling through funk, Philly soul and gospel, taking on songs famous (Marvin Gaye's "Wholy Holy") and obscure (Mike James Kirkland's "Hang on in There"), Legend and the Roots capture the old feeling of protest and uplift while updating the sound. They're not imitators — they're heirs.

To specify an alternate style sheet, the rel attribute is set to “alternate stylesheet” and the style sheet is named with a title attribute. As with preferred sheets, these style sheets can also be grouped together by giving them identical title attributes.

Using the previous example again; to make paul.css into an alternate style sheet, the keyword “alternate” is added to the rel attribute.

没有评论:

发表评论