Essentials of Javascript - Cultural View

Essentials of Javascript - Cultural View Essentials of Javascript - Cultural View

culturalview.com
from culturalview.com More from this publisher
14.07.2013 Views

BSON 59 BSON Filename extension .bson Type of format Data interchange BSON (pronounced /ˈbiːsɒn/) is a computer data interchange format. It is a binary form for representing simple data structures and associative arrays (called objects or documents). The name "BSON" is based on the term JSON and informally means "Binary JSON". Data types and syntax BSON documents (objects) consist of a well ordered list of elements. Each element consists of a field name, a type, and a value. Field names are strings. Types include: • string • integer • double • date • byte array (binary data) • boolean (true and false) • null • BSON object This is nominally a superset of JSON types (JSON does not have a byte array type, for example), but because of length limitations, some valid JSON values (such as very long strings) are not valid BSON values. Efficiency Compared to JSON, BSON is efficient both in storage space and scan-speed. Large elements in a BSON document are prefixed with a length field to facilitate scanning. See also • JSON • Protocol Buffers • Document-oriented database External links • BSON Specification [1] References [1] http://bsonspec.org

Bookmarklet 60 Bookmarklet A bookmarklet is an applet, a small computer application, stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. The term is a portmanteau of the terms bookmark and applet. Whether bookmarklet utilities are stored as bookmarks or hyperlinks, they are designed to add one-click functionality to a browser or web page. When clicked, a bookmarklet performs some function, one of a wide variety such as a search query or data extraction. Usually the applet is a JavaScript program. Concept Web browsers use URIs for the href attribute of the tag and for bookmarks. The URI scheme, such as http:, file:, or ftp:, specifies the protocol and required form for the rest of the string. Browsers also implement a prefix javascript: that to a parser is just like any other URI. Internally, the browser sees that the protocol is javascript, treats the rest of the string as javascript code which is then executed, and uses the resulting string as the new page. The executing script has access to the current page, which it may inspect and change. If the script returns an undefined type (rather than, say, a string), the browser will not load a new page, with the result that the script simply runs against the current page content. This permits in-place font size and color changes, for example, without a page reload. An anonymous function can be used to force the script to return an undefined type: javascript:(function(){ /* Statements returning a non-undefined type, e.g. assignments */ })(); Usage Bookmarklets are saved and used as normal bookmarks. As such, they are simple "one-click" tools which add functionality to the browser. For example, they can: • Modify the appearance of a web page within the browser (e.g., change font size, background color, etc.). • Extract data from a web page (e.g., hyperlinks, images, text, etc.). • Submit the current page to a blogging service such as Posterous, link-shortening service such as su.pr, or bookmarking service such as Delicious. • Query a search engine, with search term(s) provided by previously selected text, or by a dialog box. • Submit the current page to a link validation service, or translation service. • Set commonly chosen configuration options when the page itself provides no way to do this. "Installation of a bookmarklet" is performed by creating a new bookmark, and pasting the code into the URL destination field. Alternatively, if the bookmarklet is presented as a link, under some browsers it can be dragged and dropped onto the bookmark bar. The bookmarklet can then be run by loading the bookmark normally.

Bookmarklet 60<br />

Bookmarklet<br />

A bookmarklet is an applet, a small computer application, stored as the URL <strong>of</strong> a bookmark in a web browser or as a<br />

hyperlink on a web page. The term is a portmanteau <strong>of</strong> the terms bookmark and applet. Whether bookmarklet<br />

utilities are stored as bookmarks or hyperlinks, they are designed to add one-click functionality to a browser or web<br />

page. When clicked, a bookmarklet performs some function, one <strong>of</strong> a wide variety such as a search query or data<br />

extraction. Usually the applet is a JavaScript program.<br />

Concept<br />

Web browsers use URIs for the href attribute <strong>of</strong> the tag and for bookmarks. The URI scheme, such as http:, file:,<br />

or ftp:, specifies the protocol and required form for the rest <strong>of</strong> the string. Browsers also implement a prefix<br />

javascript: that to a parser is just like any other URI. Internally, the browser sees that the protocol is javascript, treats<br />

the rest <strong>of</strong> the string as javascript code which is then executed, and uses the resulting string as the new page.<br />

The executing script has access to the current page, which it may inspect and change. If the script returns an<br />

undefined type (rather than, say, a string), the browser will not load a new page, with the result that the script simply<br />

runs against the current page content. This permits in-place font size and color changes, for example, without a page<br />

reload.<br />

An anonymous function can be used to force the script to return an undefined type:<br />

javascript:(function(){<br />

/* Statements returning a non-undefined type, e.g. assignments */<br />

})();<br />

Usage<br />

Bookmarklets are saved and used as normal bookmarks. As such, they are simple "one-click" tools which add<br />

functionality to the browser. For example, they can:<br />

• Modify the appearance <strong>of</strong> a web page within the browser (e.g., change font size, background color, etc.).<br />

• Extract data from a web page (e.g., hyperlinks, images, text, etc.).<br />

• Submit the current page to a blogging service such as Posterous, link-shortening service such as su.pr, or<br />

bookmarking service such as Delicious.<br />

• Query a search engine, with search term(s) provided by previously selected text, or by a dialog box.<br />

• Submit the current page to a link validation service, or translation service.<br />

• Set commonly chosen configuration options when the page itself provides no way to do this.<br />

"Installation <strong>of</strong> a bookmarklet" is performed by creating a new bookmark, and pasting the code into the URL<br />

destination field. Alternatively, if the bookmarklet is presented as a link, under some browsers it can be dragged and<br />

dropped onto the bookmark bar. The bookmarklet can then be run by loading the bookmark normally.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!