diff options
author | Ryan <ry@tinyclouds.org> | 2009-05-17 17:54:06 +0400 |
---|---|---|
committer | Ryan <ry@tinyclouds.org> | 2009-05-17 17:54:06 +0400 |
commit | d0b59619609fae6d82b95f075ab26c51745a3c25 (patch) | |
tree | a15a3183a392874cddb69ad6f7c06b26297764a7 /website | |
parent | 9c0db09d950c3cd3a6f5403021b9ebd609294fc8 (diff) |
Work on website styling.
Diffstat (limited to 'website')
-rw-r--r-- | website/node.html | 432 | ||||
-rw-r--r-- | website/sh_javascript.min.js | 1 | ||||
-rw-r--r-- | website/sh_main.min.js | 4 | ||||
-rw-r--r-- | website/sh_vim-dark.css | 23 |
4 files changed, 460 insertions, 0 deletions
diff --git a/website/node.html b/website/node.html new file mode 100644 index 00000000000..4c9ff9d7b07 --- /dev/null +++ b/website/node.html @@ -0,0 +1,432 @@ + +<html> +<style> +body { + background: #22252a; + color: #eee; + font-size: 16pt; + line-height: 150%; + font-family: times, Times New Roman, times-roman, georgia, serif; +} +#content { + max-width: 30em; + margin: 0 0 5em 10em; +} +#toc { + position: fixed; + top: 2em; + left: 0; + width: 10em; +} +#toc ol { + list-style: none; + margin: 0; + padding: 0; + padding-left: 1em; +} +#toc ol li { + margin: 0; + padding: 0; +} +#toc a { color: #777; } + +h1, h2, h3, h4 { + margin: 2em 0; +} + +h1 a { color: inherit; } + + +pre, code { + font-family: monospace; + font-size: 13pt; + color: #bab; +} + +pre { + padding-left: 1em; + border-left: 1px solid #444; +} + +dl { +} + +dt { +} + +dd { + margin: 1em 0; + margin-left: 1em; +} + +a { color: #cd5; text-decoration: none; } +a:hover { text-decoration: underline; } + +.highlight { + background: #733; + padding: 0.2em 0; +} + +</style> +<script type="text/javascript" src="sh_main.min.js"></script> +<script type="text/javascript" src="sh_javascript.min.js"></script> +<link type="text/css" rel="stylesheet" href="sh_vim-dark.css"> + +<title>node.js</title> +<body onload="sh_highlightDocument();"> +<div id="toc"> + <ol> + <li><a href="#motivation">Motivation</a></li> + <li><a href="#benchmarks">Benchmarks</a></li> + <li><a href="#download">Download</a></li> + <li><a href="#install">Build</a></li> + <li><a href="#api">API</a> + <ol> + <li><a href="#timers">Timers</a> + <li><a href="#files">File System</a> + <li><a href="#tcp">TCP</a> + <li><a href="#http">HTTP</a> + <ol> + <li><a href="#http_server">Server</a> + <li><a href="#http_client">Client</a> + </ol> + <li><a href="#modules">Modules</a> + </ol> + </li> + </ol> +</div> +<div id="content"> + +<h1><a href="http://tinyclouds.org/node">Node</a></h1> + +<p id="introduction"> Node is a purely asynchronous I/O framework for <a + href="http://code.google.com/p/v8/">V8 javascript</a>. + +<p>This is an example of a web server written with Node which listens on +port 8000 and responds with "Hello World" after waiting two seconds: +<pre class="sh_javascript">new node.http.Server(function (req, res) { + setTimeout(function () { + res.sendHeader(200, [["Content-Type", "text/plain"]]); + res.sendBody("Hello World"); + res.finish(); + }, 2000); +}).listen(8000); +</pre> + + +<p> Check out <a href="#api">the API documentation</a> for more examples. + +<p> Node is free to <a href="#download">download</a>, <a + href="#api">use</a>, and <a href="#modules">build upon</a>.</p> + +<h2 id="motivation">Motivation</h2> + +<h3>Evented Programming Makes More Sense</h3> + +Difference between blocking/non-blocking design + +<p> There are many methods to write internet servers but they can +fundamentally be divided into two camps: evented and threaded; non-blocking +and blocking. A blocking server accepts a connection and launches a new +thread to handle the connection. Because the concurrency is handled by +the thread scheduler, a blocking server can make function calls which +preform full network requests. + +<pre class="sh_javascript">var response = db.execute("SELECT * FROM table"); +// do something</pre> + +<p> An evented server manages its concurrency itself. All connections +are handled in a single thread and callbacks are executed on certain +events: "socket 23 is has data to read", "socket 65's write buffer is +empty". An evented server executes small bits of code but never +<i>blocks</i> the process. In the evented world callbacks are used +instead of functions + +<pre class="sh_javascript">db.execute("SELECT * FROM table", function (response) { + // do something +});</pre> + + +<p><a href="http://duartes.org/gustavo/blog/post/what-your-computer-does-while-you-wait">I/O latency</a> +<pre> +l1 cache ~ 3 +l2 cache ~ 14 + ram ~ 250 + disk ~ 41000000 + network ~ 240000000 +</pre> + +<p>purely evented interfaces rule out a lot of stupidity + +<h3>Evented programs are more efficient</h3> + <ol> + <li>pthread stack size + 2mb default stack size on linux (1mb on windows, 64kb on FreeBSD) + of course this is adjustable + <li>context switching benchmark + <li>Apache vs. Nginx + <li>event machine vs mongrel (neverblock) + </ol> +<h3>The appropriateness of Javascript</h3> + <ol> + <li>No I/O + <p> Javascript is without I/O. In the browser the DOM provides I/O, + but non-browser javascript interpreters have only non-standardized + functions to allow them print to console or access the network. + <li>No Threads + <li>Good compiler + <li>Universality of the language + <p> Contemporary computer infrastructure has two irreplaceable + languages: C and Javascript. C is the language of operating systems. + POSIX, the universal operating system API, is defined in C. So while you + can interface with operating systems in Java and Haskell, those + languages access must make system calls in C. Similarly, Javascript is + the language of the web operating system. In place of POSIX is the + DOM. You can wrap Javascript, you can compile to Javascript, but in the + end browsers must be interfaced with in Javascript. Portable low-level + systems tend to be written in C and portable web-level systems are + written in Javascript. + </ol> + +<h2 id="benchmarks">Benchmarks</h2> + +<p> TODO + +<h2 id="download">Download</h2> + +<p> TODO + +<h2 id="build">Build</h2> + +<pre>./configure +make +make install</pre> + + +<h2 id="api">Application Programming Interface</h2> + +<p>Conventions: Callbacks are object members which are prefixed with +<code class="sh_javascript">on</code>. All methods and members are camel cased. Constructors +always have a capital first letter. + +<h3 id="timers">Timers</h3> + +<p>Timers allow one to schedule execution of a function for a later time. + +<p>Timers in Node work as they do in the browser: +<code class="sh_javascript">setTimeout</code>, +<code class="sh_javascript">setInterval</code>, +<code class="sh_javascript">clearTimeout</code>, +<code class="sh_javascript">clearInterval</code>. +See <a + href="https://developer.mozilla.org/en/DOM/window.setTimeout">Mozilla's + documentation</a> for more information. + +<h3 id="files">File System</h3> + +<h3 id="tcp">TCP</h3> + +<h3 id="http">HTTP (<code class="sh_javascript">node.http</code>)</h3> + +<p> Node provides a web server and client interface. The interface is rather +low-level but complete. For example, it does not parse +<code class="sh_javascript">application/x-www-form-urlencoded</code> message bodies. The interface +does abstract the Transfer-Encoding (i.e. chuncked or identity), Message +boundarys, and Keep-Alive connections. + +<h4 id="http_server">HTTP Server (<code class="sh_javascript">node.http.Server</code>)</h4> +<dl> + <dt><code class="sh_javascript">new Server(request_handler, options)</code></dt> + <dd> + <p>Creates a new web server. The <code class="sh_javascript">options</code> argument accepts + the same values as the options argument for + <code class="sh_javascript">node.tcp.Server</code> does. The options argument is optional. + + <p>The <code class="sh_javascript">request_handler</code> is a function which is called on + each request with a <code class="sh_javascript">Message</code> object argument. + </dd> + + <dt><code class="sh_javascript">server.listen(port, hostname)</code> + <dd> + <p>Begin accepting connections on the specified port and hostname. If the + hostname is omitted, the server will accept connections directed to any + address. + </dd> + + <dt><code class="sh_javascript">server.close()</code> + <dd> + <p>Stops the server. Requests currently in progress will not be + interrupted. + </dd> +</dl> + + +<h4>HTTP Request Message (<code class="sh_javascript">node.http.Message</code>)</h4> + +<p> This object is only created internally—not by the user. It is passed +as an argument to the <code class="sh_javascript">request_handler</code> callback in a web server. + +<p> This object, unlike in other HTTP APIs, is used as an interface for both +the request and response. Members and callbacks reference request data, like +<code class="sh_javascript">msg.method</code> and <code class="sh_javascript">msg.onBody</code>. The methods are for +sending a response to this message. Like <code class="sh_javascript">msg.sendHeader()</code> and +<code class="sh_javascript">msg.sendBody()</code>. +<dl> + <dt><code class="sh_javascript">msg.method</code> + <dd>The request method as a string. Read only. Example: <code class="sh_javascript">"GET"</code>, + <code class="sh_javascript">"DELETE"</code>.</dd> + + <dt><code class="sh_javascript">msg.uri</code> + <dd>The request URI as a string. Read only. + Example: <code class="sh_javascript">"/index.html?hello=world"</code>.</dd> + + <dt><code class="sh_javascript">msg.headers</code> + <dd>The request headers expressed as an array of 2-element arrays. Read only. + Example: +<pre class="sh_javascript"> +[ ["Content-Length", "123"] +, ["Content-Type", "text/plain"] +, ["Connection", "keep-alive"] +, ["Accept", "*/*"] +] +</pre> + + <dt><code class="sh_javascript">msg.http_version</code></dt> + <dd>The HTTP protocol version as a string. Read only. Examples: <code class="sh_javascript">"1.1"</code>, + <code class="sh_javascript">"1.0"</code> + + <dt><code class="sh_javascript">msg.connection</code></dt> + <dd> A reference to the <code class="sh_javascript">node.tcp.Connection</code> object. Read + only. Note that multiple messages can be sent on a single connection. + </dd> + + <dt><code class="sh_javascript">msg.onBody</code></dt> + <dd>Callback. Should be set by the user to be informed of when a piece + of the message body is received. Example: +<pre class="sh_javascript"> +msg.onBody = function (chunk) { + puts("part of the body: " + chunk); +} +</pre> + A chunk of the body is given as the single argument. The transfer-encoding + has been removed. + <p>The body chunk is either a String in the case of utf8 encoding or an + array of numbers in the case of raw encoding. + + <dt><code class="sh_javascript">msg.onBodyComplete</code></dt> + <dd>Callback. Made exactly once for each message. No arguments. After + <code class="sh_javascript">onBodyComplete</code> is executed <code class="sh_javascript">onBody</code> will no longer be called. + </dd> + + <dt><code class="sh_javascript">msg.setBodyEncoding(encoding)</code></dt> + <dd> + Set the encoding for the request body. Either <code class="sh_javascript">"utf8"</code> or + <code class="sh_javascript">"raw"</code>. Defaults to raw. + <big>TODO</big> + + <dt><code class="sh_javascript">msg.sendHeader(status_code, headers)</code></dt> + <dd> + Sends a response header to the request. The status code is a 3-digit + HTTP status code, like <code class="sh_javascript">404</code>. The second argument, + <code class="sh_javascript">headers</code>, should be an array of 2-element arrays, + representing the response headers. + + <p>Example: +<pre class="sh_javascript"> +var body = "hello world"; +msg.sendHeader( 200 + , [ ["Content-Length", body.length] + , ["Content-Type", "text/plain"] + ] + ); +</pre> + This method must only be called once on a message and it must be called + before <code class="sh_javascript">msg.finish()</code> is called. + </dd> + + <dt><code class="sh_javascript">msg.sendBody(chunk)</code></dt> + <dd> + This method must be called after <code class="sh_javascript">sendHeader</code> was called. It + sends a chunk of the response body. This method may be called multiple + times to provide successive parts of the body. + </dd> + + <dt><code class="sh_javascript">msg.finish()</code></dt> + <dd> + This method signals that all of the response headers and body has been + sent; that server should consider this message complete. + The method, <code class="sh_javascript">msg.finish()</code>, MUST be called on each response. + +</dl> + +<h3 id="modules">Modules</h3> + +<p>Node has a simple module loading system. In Node, files and modules are +in one-to-one correspondence. + +<p> As an example, +<code class="sh_javascript">foo.js</code> loads the module <code class="sh_javascript">mjsunit.js</code>. + +<p>The contents of <code class="sh_javascript">foo.js</code>: + +<pre class="sh_javascript"> +include("mjsunit"); +function onLoad () { + assertEquals(1, 2); +} +</pre> +<p>The contents of <code class="sh_javascript">mjsunit.js</code>: + +<pre class="sh_javascript"> +function fail (expected, found, name_opt) { + // ... +} +function deepEquals (a, b) { + // ... +} +<span class="highlight">exports</span>.assertEquals = function (expected, found, name_opt) { + if (!deepEquals(found, expected)) { + fail(expected, found, name_opt); + } +}; +</pre> + +<p>Here the module <code class="sh_javascript">mjsunit.js</code> has exported the function +<code class="sh_javascript">assertEquals()</code>. <code class="sh_javascript">mjsunit.js</code> must be in the +same directory as <code class="sh_javascript">foo.js</code> for <code class="sh_javascript">include()</code> to find it. +The module path is relative to the file calling <code class="sh_javascript">include()</code>. +The module path does not include filename extensions like <code class="sh_javascript">.js</code>. + +<p> <code class="sh_javascript">include()</code> inserts the exported objects +from the specified module into the global namespace. + +<p> Because file loading does not happen instantaneously, and because Node +has a policy of never blocking, the callback <code class="sh_javascript">onLoad()</code> is +provided to notify the user when all the included modules are loaded. +Each file can have its own <code class="sh_javascript">onLoad()</code> callback. +<code class="sh_javascript">onLoad()</code> will always be called exactly once for each file. + +<p> To export an object, add to the special <code + class="highlight">exports</code> object. + +<p> The functions <code class="sh_javascript">fail</code> and <code class="sh_javascript">deepEquals</code> are not +exported and remain private to the module. + +<p> In addition to <code class="sh_javascript">include()</code> a module can use +<code class="sh_javascript">require()</code>. Instead of loading the exported objects into the +global namespace, it will return a namespace object. The exported objects +can only be guaranteed to exist after the <code class="sh_javascript">onLoad()</code> callback is +made. For example: +<pre class="sh_javascript"> +var mjsunit = require("mjsunit"); + +function onLoad () { + mjsunit.assertEquals(1, 2); +} +</pre> + +<p> <code class="sh_javascript">include()</code> and <code class="sh_javascript">require()</code> cannot be used after +<code class="sh_javascript">onLoad()</code> is called. So put them at the beginning of your file. + +</body> +</html> diff --git a/website/sh_javascript.min.js b/website/sh_javascript.min.js new file mode 100644 index 00000000000..d12482ced20 --- /dev/null +++ b/website/sh_javascript.min.js @@ -0,0 +1 @@ +if(!this.sh_languages){this.sh_languages={}}sh_languages.javascript=[[[/\/\/\//g,"sh_comment",1],[/\/\//g,"sh_comment",7],[/\/\*\*/g,"sh_comment",8],[/\/\*/g,"sh_comment",9],[/\b(?:abstract|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|final|finally|for|function|goto|if|implements|in|instanceof|interface|native|new|null|private|protected|prototype|public|return|static|super|switch|synchronized|throw|throws|this|transient|true|try|typeof|var|volatile|while|with)\b/g,"sh_keyword",-1],[/(\+\+|--|\)|\])(\s*)(\/=?(?![*\/]))/g,["sh_symbol","sh_normal","sh_symbol"],-1],[/(0x[A-Fa-f0-9]+|(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?)(\s*)(\/(?![*\/]))/g,["sh_number","sh_normal","sh_symbol"],-1],[/([A-Za-z$_][A-Za-z0-9$_]*\s*)(\/=?(?![*\/]))/g,["sh_normal","sh_symbol"],-1],[/\/(?:\\.|[^*\\\/])(?:\\.|[^\\\/])*\/[gim]*/g,"sh_regexp",-1],[/\b[+-]?(?:(?:0x[A-Fa-f0-9]+)|(?:(?:[\d]*\.)?[\d]+(?:[eE][+-]?[\d]+)?))u?(?:(?:int(?:8|16|32|64))|L)?\b/g,"sh_number",-1],[/"/g,"sh_string",10],[/'/g,"sh_string",11],[/~|!|%|\^|\*|\(|\)|-|\+|=|\[|\]|\\|:|;|,|\.|\/|\?|&|<|>|\|/g,"sh_symbol",-1],[/\{|\}/g,"sh_cbracket",-1],[/\b(?:Math|Infinity|NaN|undefined|arguments)\b/g,"sh_predef_var",-1],[/\b(?:Array|Boolean|Date|Error|EvalError|Function|Number|Object|RangeError|ReferenceError|RegExp|String|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt)\b/g,"sh_predef_func",-1],[/(?:[A-Za-z]|_)[A-Za-z0-9_]*(?=[ \t]*\()/g,"sh_function",-1]],[[/$/g,null,-2],[/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,"sh_url",-1],[/<\?xml/g,"sh_preproc",2,1],[/<!DOCTYPE/g,"sh_preproc",4,1],[/<!--/g,"sh_comment",5],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,"sh_keyword",6,1],[/&(?:[A-Za-z0-9]+);/g,"sh_preproc",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*/g,"sh_keyword",6,1],[/@[A-Za-z]+/g,"sh_type",-1],[/(?:TODO|FIXME|BUG)(?:[:]?)/g,"sh_todo",-1]],[[/\?>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",3]],[[/\\(?:\\|")/g,null,-1],[/"/g,"sh_string",-2]],[[/>/g,"sh_preproc",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",3]],[[/-->/g,"sh_comment",-2],[/<!--/g,"sh_comment",5]],[[/(?:\/)?>/g,"sh_keyword",-2],[/([^=" \t>]+)([ \t]*)(=?)/g,["sh_type","sh_normal","sh_symbol"],-1],[/"/g,"sh_string",3]],[[/$/g,null,-2]],[[/\*\//g,"sh_comment",-2],[/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,"sh_url",-1],[/<\?xml/g,"sh_preproc",2,1],[/<!DOCTYPE/g,"sh_preproc",4,1],[/<!--/g,"sh_comment",5],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z](?:[A-Za-z0-9_:.-]*)/g,"sh_keyword",6,1],[/&(?:[A-Za-z0-9]+);/g,"sh_preproc",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*(?:\/)?>/g,"sh_keyword",-1],[/<(?:\/)?[A-Za-z][A-Za-z0-9]*/g,"sh_keyword",6,1],[/@[A-Za-z]+/g,"sh_type",-1],[/(?:TODO|FIXME|BUG)(?:[:]?)/g,"sh_todo",-1]],[[/\*\//g,"sh_comment",-2],[/(?:<?)[A-Za-z0-9_\.\/\-_~]+@[A-Za-z0-9_\.\/\-_~]+(?:>?)|(?:<?)[A-Za-z0-9_]+:\/\/[A-Za-z0-9_\.\/\-_~]+(?:>?)/g,"sh_url",-1],[/(?:TODO|FIXME|BUG)(?:[:]?)/g,"sh_todo",-1]],[[/"/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]],[[/'/g,"sh_string",-2],[/\\./g,"sh_specialchar",-1]]];
\ No newline at end of file diff --git a/website/sh_main.min.js b/website/sh_main.min.js new file mode 100644 index 00000000000..31d1ba09e07 --- /dev/null +++ b/website/sh_main.min.js @@ -0,0 +1,4 @@ +/* Copyright (C) 2007, 2008 gnombat@users.sourceforge.net */ +/* License: http://shjs.sourceforge.net/doc/gplv3.html */ + +if(!this.sh_languages){this.sh_languages={}}var sh_requests={};function sh_isEmailAddress(a){if(/^mailto:/.test(a)){return false}return a.indexOf("@")!==-1}function sh_setHref(b,c,d){var a=d.substring(b[c-2].pos,b[c-1].pos);if(a.length>=2&&a.charAt(0)==="<"&&a.charAt(a.length-1)===">"){a=a.substr(1,a.length-2)}if(sh_isEmailAddress(a)){a="mailto:"+a}b[c-2].node.href=a}function sh_konquerorExec(b){var a=[""];a.index=b.length;a.input=b;return a}function sh_highlightString(B,o){if(/Konqueror/.test(navigator.userAgent)){if(!o.konquered){for(var F=0;F<o.length;F++){for(var H=0;H<o[F].length;H++){var G=o[F][H][0];if(G.source==="$"){G.exec=sh_konquerorExec}}}o.konquered=true}}var N=document.createElement("a");var q=document.createElement("span");var A=[];var j=0;var n=[];var C=0;var k=null;var x=function(i,a){var p=i.length;if(p===0){return}if(!a){var Q=n.length;if(Q!==0){var r=n[Q-1];if(!r[3]){a=r[1]}}}if(k!==a){if(k){A[j++]={pos:C};if(k==="sh_url"){sh_setHref(A,j,B)}}if(a){var P;if(a==="sh_url"){P=N.cloneNode(false)}else{P=q.cloneNode(false)}P.className=a;A[j++]={node:P,pos:C}}}C+=p;k=a};var t=/\r\n|\r|\n/g;t.lastIndex=0;var d=B.length;while(C<d){var v=C;var l;var w;var h=t.exec(B);if(h===null){l=d;w=d}else{l=h.index;w=t.lastIndex}var g=B.substring(v,l);var M=[];for(;;){var I=C-v;var D;var y=n.length;if(y===0){D=0}else{D=n[y-1][2]}var O=o[D];var z=O.length;var m=M[D];if(!m){m=M[D]=[]}var E=null;var u=-1;for(var K=0;K<z;K++){var f;if(K<m.length&&(m[K]===null||I<=m[K].index)){f=m[K]}else{var c=O[K][0];c.lastIndex=I;f=c.exec(g);m[K]=f}if(f!==null&&(E===null||f.index<E.index)){E=f;u=K;if(f.index===I){break}}}if(E===null){x(g.substring(I),null);break}else{if(E.index>I){x(g.substring(I,E.index),null)}var e=O[u];var J=e[1];var b;if(J instanceof Array){for(var L=0;L<J.length;L++){b=E[L+1];x(b,J[L])}}else{b=E[0];x(b,J)}switch(e[2]){case -1:break;case -2:n.pop();break;case -3:n.length=0;break;default:n.push(e);break}}}if(k){A[j++]={pos:C};if(k==="sh_url"){sh_setHref(A,j,B)}k=null}C=w}return A}function sh_getClasses(d){var a=[];var b=d.className;if(b&&b.length>0){var e=b.split(" ");for(var c=0;c<e.length;c++){if(e[c].length>0){a.push(e[c])}}}return a}function sh_addClass(c,a){var d=sh_getClasses(c);for(var b=0;b<d.length;b++){if(a.toLowerCase()===d[b].toLowerCase()){return}}d.push(a);c.className=d.join(" ")}function sh_extractTagsFromNodeList(c,a){var f=c.length;for(var d=0;d<f;d++){var e=c.item(d);switch(e.nodeType){case 1:if(e.nodeName.toLowerCase()==="br"){var b;if(/MSIE/.test(navigator.userAgent)){b="\r"}else{b="\n"}a.text.push(b);a.pos++}else{a.tags.push({node:e.cloneNode(false),pos:a.pos});sh_extractTagsFromNodeList(e.childNodes,a);a.tags.push({pos:a.pos})}break;case 3:case 4:a.text.push(e.data);a.pos+=e.length;break}}}function sh_extractTags(c,b){var a={};a.text=[];a.tags=b;a.pos=0;sh_extractTagsFromNodeList(c.childNodes,a);return a.text.join("")}function sh_mergeTags(d,f){var a=d.length;if(a===0){return f}var c=f.length;if(c===0){return d}var i=[];var e=0;var b=0;while(e<a&&b<c){var h=d[e];var g=f[b];if(h.pos<=g.pos){i.push(h);e++}else{i.push(g);if(f[b+1].pos<=h.pos){b++;i.push(f[b]);b++}else{i.push({pos:h.pos});f[b]={node:g.node.cloneNode(false),pos:h.pos}}}}while(e<a){i.push(d[e]);e++}while(b<c){i.push(f[b]);b++}return i}function sh_insertTags(k,h){var g=document;var l=document.createDocumentFragment();var e=0;var d=k.length;var b=0;var j=h.length;var c=l;while(b<j||e<d){var i;var a;if(e<d){i=k[e];a=i.pos}else{a=j}if(a<=b){if(i.node){var f=i.node;c.appendChild(f);c=f}else{c=c.parentNode}e++}else{c.appendChild(g.createTextNode(h.substring(b,a)));b=a}}return l}function sh_highlightElement(d,g){sh_addClass(d,"sh_sourceCode");var c=[];var e=sh_extractTags(d,c);var f=sh_highlightString(e,g);var b=sh_mergeTags(c,f);var a=sh_insertTags(b,e);while(d.hasChildNodes()){d.removeChild(d.firstChild)}d.appendChild(a)}function sh_getXMLHttpRequest(){if(window.ActiveXObject){return new ActiveXObject("Msxml2.XMLHTTP")}else{if(window.XMLHttpRequest){return new XMLHttpRequest()}}throw"No XMLHttpRequest implementation available"}function sh_load(language,element,prefix,suffix){if(language in sh_requests){sh_requests[language].push(element);return}sh_requests[language]=[element];var request=sh_getXMLHttpRequest();var url=prefix+"sh_"+language+suffix;request.open("GET",url,true);request.onreadystatechange=function(){if(request.readyState===4){try{if(!request.status||request.status===200){eval(request.responseText);var elements=sh_requests[language];for(var i=0;i<elements.length;i++){sh_highlightElement(elements[i],sh_languages[language])}}else{throw"HTTP error: status "+request.status}}finally{request=null}}};request.send(null)}function sh_highlightDocument(g,k){var b=document.getElementsByTagName("pre");for(var e=0;e<b.length;e++){var f=b.item(e);var a=sh_getClasses(f);for(var c=0;c<a.length;c++){var h=a[c].toLowerCase();if(h==="sh_sourcecode"){continue}if(h.substr(0,3)==="sh_"){var d=h.substring(3);if(d in sh_languages){sh_highlightElement(f,sh_languages[d])}else{if(typeof(g)==="string"&&typeof(k)==="string"){sh_load(d,f,g,k)}else{throw'Found <pre> element with class="'+h+'", but no such language exists'}}break}}}};
\ No newline at end of file diff --git a/website/sh_vim-dark.css b/website/sh_vim-dark.css new file mode 100644 index 00000000000..74d7cefb7b9 --- /dev/null +++ b/website/sh_vim-dark.css @@ -0,0 +1,23 @@ +.sh_sourceCode {
+
+ font-weight: normal;
+ font-style: normal;
+}
+
+.sh_sourceCode .sh_symbol , pre.sh_sourceCode .sh_cbracket {
+ color: #bbd;
+}
+
+.sh_sourceCode .sh_keyword {
+ font-style: italic;
+}
+
+.sh_sourceCode .sh_string, pre.sh_sourceCode .sh_regexp, pre.sh_sourceCode .sh_number
+{
+ color: #daa;
+}
+
+.sh_sourceCode .sh_comment {
+ color: #777;
+}
+
|