Tuesday, June 24, 2008

Anchoring Bookmarklet

Occasionally we find ourselves loading pages with lots of images, and trying to get to a specific piece of the page. The browser will jump to the proper location, which promptly scrolls away while the images load. To solve that problem, I threw together a JavaScript bookmarklet that will snap your window back to the position of whatever element holds the anchor. Here is the code:

var getLocationAnchor = function(url) {
    var i = url.indexOf('#');
    var id = (i >= 0 ? url.substr(i+1) : '');
    return decodeURIComponent(id);
};

var getAnchorNode = function(doc, id) {
    var chkNode = doc.getElementById(id);
    if (chkNode) {
        return chkNode;
    }

    var nodeList = doc.getElementsByName(id);
    for (var i = 0; i < nodeList.length; i++) {
        chkNode = nodeList.item(i);
        if (chkNode.tagName.toLowerCase() == 'a') {
            return chkNode;
        }
    }

    if (nodeList.length) {
        return nodeList.item(0);
    }

    return null;
};

var id = getLocationAnchor(document.location.href);
var node = getAnchorNode(document, id);
if (node) {
    node.scrollIntoView(true);
}

And converted into bookmarklet form, it looks much uglier. So the simple way to do this: bookmark this link.

Posted by Paul at 4:53 PM Perma-link | 0 comments | Links to this post |
Tuesday, June 10, 2008

iTunes content ratings

Purchased content from the iTunes store has embedded tags that identify the content’s rating. If you use a tool like AtomicParsley, you’ll see an output line that looks something like these data:

Atom "----" [com.apple.iTunes;iTunEXTC] contains: us-tv|TV-14|500|V
Atom "----" [com.apple.iTunes;iTunEXTC] contains: mpaa|PG-13|300|For violence and sexuality.

So I’m not here to discuss the ins-and-outs of how to get the correct atoms into your MP4 file; I’ll let AtomicParsley take care of that. However, I’m here to outline exactly what these tags mean to iTunes. Here’s a more accurate description of what those tags contain:

standard|rating|score|reasons

Where the standard tells iTunes which organization’s standards are being described by the rating. For the United States, these are us-tv for TV shows and mpaa for movies. A reference table with known standards, ratings, and scores is below.

The rating field gives the textual name of the rating given to this content. If iTunes does not recognize the string you give as a rating, it will choke on the file and fail to parse other metadata.

The score gives a numerical value which is used by the parental controls to limit access to media. Presumably, this is categorized such that restricted content from differing nations can still be restricted based on this number, even if the rating scales differ.

The reasons field is an arbitrary area where causes for the given rating can be noted. For us-tv ratings, for example, this includes the single-letter codes used to denote the presence of Violence (V), Language (L), Sexual Content (S), Dialogue (D), or Fantasy Violence (FV). For mpaa it seems to be an arbitrary string. iTunes does not expose this data currently, but it may in the future, so it’s a good idea to set it to something meaningful.

Rating Tables

AU: Movie ratings (au-movie)

  • 000: Not Rated
  • 100: G
  • 200: PG
  • 350: M
  • 375: MA 15+
  • 400: R18+
  • ???: Unrated

AU: Television ratings (au-tv)

  • Listed as N/A in iTunes

CA: Movie ratings (ca-movie)

  • 000: Not Rated
  • 100: G
  • 200: PG
  • 325: 14
  • 400: 18
  • 500: R
  • ???: Unrated

CA: Television ratings (ca-tv)

  • 000: Not Rated
  • 100: C
  • 200: C8
  • 300: G
  • 400: PG
  • 500: 14+
  • 600: 18+
  • ???: Unrated

FR: Movie ratings (fr-movie)

  • Listed as N/A in iTunes

FR: Television ratings (fr-tv)

  • 000: Not Rated
  • 100: -10
  • 200: -12
  • 500: -16
  • 600: -18
  • ???: Unrated

DE: Movie ratings (de-movie)

  • Listed as N/A in iTunes

DE: Television ratings (de-tv)

  • 000: Not Rated
  • 100: ab 6 Jarhen
  • 200: ab 12 Jarhen
  • 500: ab 16 Jarhen
  • 600: ab 18 Jarhen
  • ???: Unrated

NZ: Movie ratings (nz-movie)

  • 000: Not Rated
  • 100: G
  • 200: PG
  • 300: M
  • 325: R13
  • 350: R15
  • 375: R16
  • 400: R18
  • 500: R
  • ???: Unrated

UK: Movie ratings (uk-movie)

  • 000: Not Rated
  • 100: U
  • 150: Uc
  • 200: PG
  • 300: 12
  • 325: 12A
  • 350: 15
  • 400: 18
  • 600: E
  • ???: Unrated

UK: Television ratings (uk-tv)

  • 000: Not Rated
  • 500: CAUTION
  • ???: Unrated

US: MPAA ratings (mpaa)

  • 000: Not Rated
  • 100: G
  • 200: PG
  • 300: PG-13
  • 400: R
  • 500: NC-17 (unverified)
  • ???: Unrated

US: Television ratings (us-tv)

  • 000: Not Rated
  • 100: TV-Y
  • 200: TV-Y7
  • 300: TV-G
  • 400: TV-PG
  • 500: TV-14
  • 600: TV-MA (unverified)
  • ???: Unrated
Posted by Paul at 1:23 AM Perma-link | 2 comments | Links to this post |