move demo documents into separate files
This commit is contained in:
parent
8ee1ffab20
commit
426259dc2f
23 changed files with 466 additions and 495 deletions
|
|
@ -39,14 +39,13 @@ define(function(require, exports, module) {
|
|||
|
||||
require("pilot/fixoldbrowsers");
|
||||
require("pilot/plugin_manager");
|
||||
require("pilot/settings");
|
||||
require("pilot/environment");
|
||||
require("demo/demo");
|
||||
|
||||
require("pilot/index");
|
||||
require("ace/defaults");
|
||||
|
||||
var plugins = [ "pilot/index", "ace/defaults" ];
|
||||
var plugins = [ "pilot/index"];
|
||||
var catalog = require("pilot/plugin_manager").catalog;
|
||||
catalog.registerPlugins(plugins).then(function() {
|
||||
var env = require("pilot/environment").create();
|
||||
|
|
|
|||
46
demo/demo.js
46
demo/demo.js
|
|
@ -95,7 +95,7 @@ exports.launch = function(env) {
|
|||
var docs = {};
|
||||
|
||||
// Make the lorem ipsum text a little bit longer.
|
||||
var loreIpsum = document.getElementById("plaintext").innerHTML;
|
||||
var loreIpsum = require("text!demo/docs/plaintext.txt");
|
||||
for (var i = 0; i < 5; i++) {
|
||||
loreIpsum += loreIpsum;
|
||||
}
|
||||
|
|
@ -105,85 +105,83 @@ exports.launch = function(env) {
|
|||
docs.plain.setMode(new TextMode());
|
||||
docs.plain.setUndoManager(new UndoManager());
|
||||
|
||||
docs.js = new EditSession(document.getElementById("jstext").innerHTML);
|
||||
docs.js = new EditSession(require("text!demo/docs/javascript.js"));
|
||||
docs.js.setMode(new JavaScriptMode());
|
||||
docs.js.setUndoManager(new UndoManager());
|
||||
|
||||
docs.css = new EditSession(document.getElementById("csstext").innerHTML);
|
||||
docs.css = new EditSession(require("text!demo/docs/css.css"));
|
||||
docs.css.setMode(new CssMode());
|
||||
docs.css.setUndoManager(new UndoManager());
|
||||
|
||||
docs.scss = new EditSession(document.getElementById("scsstext").innerHTML);
|
||||
docs.scss = new EditSession(require("text!demo/docs/scss.scss"));
|
||||
docs.scss.setMode(new ScssMode());
|
||||
docs.scss.setUndoManager(new UndoManager());
|
||||
|
||||
docs.html = new EditSession(document.getElementById("htmltext").innerHTML);
|
||||
docs.html = new EditSession(require("text!demo/docs/html.html"));
|
||||
docs.html.setMode(new HtmlMode());
|
||||
docs.html.setUndoManager(new UndoManager());
|
||||
|
||||
docs.python = new EditSession(document.getElementById("pythontext").innerHTML);
|
||||
docs.python = new EditSession(require("text!demo/docs/python.py"));
|
||||
docs.python.setMode(new PythonMode());
|
||||
docs.python.setUndoManager(new UndoManager());
|
||||
|
||||
docs.php = new EditSession(document.getElementById("phptext").innerHTML);
|
||||
docs.php = new EditSession(require("text!demo/docs/php.php"));
|
||||
docs.php.setMode(new PhpMode());
|
||||
docs.php.setUndoManager(new UndoManager());
|
||||
|
||||
docs.java = new EditSession(document.getElementById("javatext").innerHTML);
|
||||
docs.java = new EditSession(require("text!demo/docs/java.java"));
|
||||
docs.java.setMode(new JavaMode());
|
||||
docs.java.setUndoManager(new UndoManager());
|
||||
docs.java.addFold("...", new Range(8, 44, 13, 4));
|
||||
|
||||
docs.ruby = new EditSession(document.getElementById("rubytext").innerHTML);
|
||||
docs.ruby = new EditSession(require("text!demo/docs/ruby.rb"));
|
||||
docs.ruby.setMode(new RubyMode());
|
||||
docs.ruby.setUndoManager(new UndoManager());
|
||||
|
||||
docs.csharp = new EditSession(document.getElementById("csharptext").innerHTML);
|
||||
docs.csharp = new EditSession(require("text!demo/docs/csharp.cs"));
|
||||
docs.csharp.setMode(new CSharpMode());
|
||||
docs.csharp.setUndoManager(new UndoManager());
|
||||
|
||||
docs.c_cpp = new EditSession(document.getElementById("cpptext").innerHTML);
|
||||
docs.c_cpp = new EditSession(require("text!demo/docs/cpp.cpp"));
|
||||
docs.c_cpp.setMode(new CCPPMode());
|
||||
docs.c_cpp.setUndoManager(new UndoManager());
|
||||
|
||||
docs.coffee = new EditSession(document.getElementById("coffeetext").innerHTML);
|
||||
docs.coffee = new EditSession(require("text!demo/docs/coffeescript.coffee"));
|
||||
docs.coffee.setMode(new CoffeeMode());
|
||||
docs.coffee.setUndoManager(new UndoManager());
|
||||
|
||||
docs.json = new EditSession(document.getElementById("jsontext").innerHTML);
|
||||
docs.json = new EditSession(require("text!demo/docs/json.json"));
|
||||
docs.json.setMode(new JsonMode());
|
||||
docs.json.setUndoManager(new UndoManager());
|
||||
|
||||
docs.perl = new EditSession(document.getElementById("perltext").innerHTML);
|
||||
docs.perl = new EditSession(require("text!demo/docs/perl.pl"));
|
||||
docs.perl.setMode(new PerlMode());
|
||||
docs.perl.setUndoManager(new UndoManager());
|
||||
|
||||
docs.clojure = new EditSession(document.getElementById("clojuretext").innerHTML);
|
||||
docs.clojure = new EditSession(require("text!demo/docs/clojure.clj"));
|
||||
docs.clojure.setMode(new ClojureMode());
|
||||
docs.clojure.setUndoManager(new UndoManager());
|
||||
|
||||
docs.ocaml = new EditSession(document.getElementById("ocamltext").innerHTML);
|
||||
docs.ocaml = new EditSession(require("text!demo/docs/ocaml.ml"));
|
||||
docs.ocaml.setMode(new OcamlMode());
|
||||
docs.ocaml.setUndoManager(new UndoManager());
|
||||
|
||||
docs.svg = new EditSession(document.getElementById("svgtext").innerHTML.replace("<", "<"));
|
||||
docs.svg = new EditSession(require("text!demo/docs/svg.svg"));
|
||||
docs.svg.setMode(new SvgMode());
|
||||
docs.svg.setUndoManager(new UndoManager());
|
||||
|
||||
docs.textile = new EditSession(document.getElementById("textiletext").innerHTML);
|
||||
docs.textile = new EditSession(require("text!demo/docs/textile.textile"));
|
||||
docs.textile.setMode(new TextileMode());
|
||||
docs.textile.setUndoManager(new UndoManager());
|
||||
|
||||
docs.groovy = new EditSession(document.getElementById("groovy").innerHTML);
|
||||
docs.groovy = new EditSession(require("text!demo/docs/groovy.groovy"));
|
||||
docs.groovy.setMode(new GroovyMode());
|
||||
docs.groovy.setUndoManager(new UndoManager());
|
||||
|
||||
docs.scala = new EditSession(document.getElementById("scala").innerHTML);
|
||||
docs.scala = new EditSession(require("text!demo/docs/scala.scala"));
|
||||
docs.scala.setMode(new ScalaMode());
|
||||
docs.scala.setUndoManager(new UndoManager());
|
||||
|
||||
|
||||
|
||||
|
||||
// Add a "name" property to all docs
|
||||
for (var doc in docs) {
|
||||
|
|
@ -461,7 +459,7 @@ exports.launch = function(env) {
|
|||
var onCheck = function() {
|
||||
callback(!!el.checked);
|
||||
};
|
||||
el.onclick = onCheck;
|
||||
el.onCheckck = onCheck;
|
||||
onCheck();
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +560,7 @@ exports.launch = function(env) {
|
|||
bindKey: {
|
||||
win: "Ctrl-S",
|
||||
mac: "Command-S",
|
||||
sender: "editor|cli"
|
||||
sender: "editor"
|
||||
},
|
||||
exec: function() {
|
||||
alert("Fake Save File");
|
||||
|
|
|
|||
19
demo/docs/clojure.clj
Normal file
19
demo/docs/clojure.clj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(defn parting
|
||||
"returns a String parting in a given language"
|
||||
([] (parting "World"))
|
||||
([name] (parting name "en"))
|
||||
([name language]
|
||||
; condp is similar to a case statement in other languages.
|
||||
; It is described in more detail later.
|
||||
; It is used here to take different actions based on whether the
|
||||
; parameter "language" is set to "en", "es" or something else.
|
||||
(condp = language
|
||||
"en" (str "Goodbye, " name)
|
||||
"es" (str "Adios, " name)
|
||||
(throw (IllegalArgumentException.
|
||||
(str "unsupported language " language))))))
|
||||
|
||||
(println (parting)) ; -> Goodbye, World
|
||||
(println (parting "Mark")) ; -> Goodbye, Mark
|
||||
(println (parting "Mark" "es")) ; -> Adios, Mark
|
||||
(println (parting "Mark", "xy")) ; -> java.lang.IllegalArgumentException: unsupported language xy
|
||||
20
demo/docs/coffeescript.coffee
Normal file
20
demo/docs/coffeescript.coffee
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env coffee
|
||||
|
||||
try
|
||||
throw URIError decodeURI(0xC0ffee * 123456.7e-8 / .9)
|
||||
catch e
|
||||
console.log 'qstring' + "qqstring" + '''
|
||||
qdoc
|
||||
''' + """
|
||||
qqdoc
|
||||
"""
|
||||
|
||||
do ->
|
||||
###
|
||||
herecomment
|
||||
###
|
||||
re = /regex/imgy.test ///
|
||||
heregex # comment
|
||||
///imgy
|
||||
this isnt: `just JavaScript`
|
||||
undefined
|
||||
13
demo/docs/cpp.cpp
Normal file
13
demo/docs/cpp.cpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// compound assignment operators
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main ()
|
||||
{
|
||||
int a, b=3; /* foobar */
|
||||
a = b;
|
||||
a+=2; // equivalent to a=a+2
|
||||
cout << a;
|
||||
return 0;
|
||||
}
|
||||
4
demo/docs/csharp.cs
Normal file
4
demo/docs/csharp.cs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
public void HelloWorld() {
|
||||
//Say Hello!
|
||||
Console.WriteLine("Hello World");
|
||||
}
|
||||
5
demo/docs/css.css
Normal file
5
demo/docs/css.css
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}
|
||||
26
demo/docs/groovy.groovy
Normal file
26
demo/docs/groovy.groovy
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//http://groovy.codehaus.org/Concurrency+with+Groovy
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
def counter = new AtomicInteger()
|
||||
|
||||
synchronized out(message) {
|
||||
println(message)
|
||||
}
|
||||
|
||||
def th = Thread.start {
|
||||
for( i in 1..8 ) {
|
||||
sleep 30
|
||||
out "thread loop $i"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
|
||||
for( j in 1..4 ) {
|
||||
sleep 50
|
||||
out "main loop $j"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
|
||||
th.join()
|
||||
|
||||
assert counter.get() == 12
|
||||
16
demo/docs/html.html
Normal file
16
demo/docs/html.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<html>
|
||||
<head>
|
||||
|
||||
<style type="text/css">
|
||||
.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color:red">Juhu Kinners</h1>
|
||||
</body>
|
||||
</html>
|
||||
15
demo/docs/java.java
Normal file
15
demo/docs/java.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
public class InfiniteLoop {
|
||||
|
||||
/*
|
||||
* This will cause the program to hang...
|
||||
*
|
||||
* Taken from:
|
||||
* http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
double d = Double.parseDouble("2.2250738585072012e-308");
|
||||
|
||||
// unreachable code
|
||||
System.out.println("Value: " + d);
|
||||
}
|
||||
}
|
||||
5
demo/docs/javascript.js
Normal file
5
demo/docs/javascript.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function foo(items) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
alert(items[i] + "juhu");
|
||||
} // Real Tab.
|
||||
}
|
||||
66
demo/docs/json.json
Normal file
66
demo/docs/json.json
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
"query": {
|
||||
"count": 10,
|
||||
"created": "2011-06-21T08:10:46Z",
|
||||
"lang": "en-US",
|
||||
"results": {
|
||||
"photo": [
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5855620975",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "f1f5e8515d",
|
||||
"server": "5110",
|
||||
"title": "7087 bandit cat"
|
||||
},
|
||||
{
|
||||
"farm": "4",
|
||||
"id": "5856170534",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "ff1efb2a6f",
|
||||
"server": "3217",
|
||||
"title": "6975 rusty cat"
|
||||
},
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5856172972",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "51249875@N03",
|
||||
"secret": "6c6887347c",
|
||||
"server": "5192",
|
||||
"title": "watermarked-cats"
|
||||
},
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5856168328",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "0c1cfdf64c",
|
||||
"server": "5078",
|
||||
"title": "7020 mandy cat"
|
||||
},
|
||||
{
|
||||
"farm": "3",
|
||||
"id": "5856171774",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "7f5a3180ab",
|
||||
"server": "2696",
|
||||
"title": "7448 bobby cat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
18
demo/docs/ocaml.ml
Normal file
18
demo/docs/ocaml.ml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(*
|
||||
* Example of early return implementation taken from
|
||||
* http://ocaml.janestreet.com/?q=node/91
|
||||
*)
|
||||
|
||||
let with_return (type t) (f : _ -> t) =
|
||||
let module M =
|
||||
struct exception Return of t end
|
||||
in
|
||||
let return = { return = (fun x -> raise (M.Return x)); } in
|
||||
try f return with M.Return x -> x
|
||||
|
||||
|
||||
(* Function that uses the 'early return' functionality provided by `with_return` *)
|
||||
let sum_until_first_negative list =
|
||||
with_return (fun r ->
|
||||
List.fold list ~init:0 ~f:(fun acc x ->
|
||||
if x >= 0 then acc + x else r.return acc))
|
||||
32
demo/docs/perl.pl
Normal file
32
demo/docs/perl.pl
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
my $num_primes = 0;
|
||||
my @primes;
|
||||
|
||||
# Put 2 as the first prime so we won't have an empty array
|
||||
$primes[$num_primes] = 2;
|
||||
$num_primes++;
|
||||
|
||||
MAIN_LOOP:
|
||||
for my $number_to_check (3 .. 200)
|
||||
{
|
||||
for my $p (0 .. ($num_primes-1))
|
||||
{
|
||||
if ($number_to_check % $primes[$p] == 0)
|
||||
{
|
||||
next MAIN_LOOP;
|
||||
}
|
||||
}
|
||||
|
||||
# If we reached this point it means $number_to_check is not
|
||||
# divisable by any prime number that came before it.
|
||||
$primes[$num_primes] = $number_to_check;
|
||||
$num_primes++;
|
||||
}
|
||||
|
||||
for my $p (0 .. ($num_primes-1))
|
||||
{
|
||||
print $primes[$p], ", ";
|
||||
}
|
||||
print "\n";
|
||||
19
demo/docs/php.php
Normal file
19
demo/docs/php.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
function nfact($n) {
|
||||
if ($n == 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return $n * nfact($n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n\nPlease enter a whole number ... ";
|
||||
$num = trim(fgets(STDIN));
|
||||
|
||||
// ===== PROCESS - Determing the factorial of the input number =====
|
||||
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
|
||||
echo $output;
|
||||
|
||||
?>
|
||||
11
demo/docs/plaintext.txt
Normal file
11
demo/docs/plaintext.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
|
||||
|
||||
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
|
||||
|
||||
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
|
||||
|
||||
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.
|
||||
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
|
||||
18
demo/docs/python.py
Normal file
18
demo/docs/python.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/local/bin/python
|
||||
|
||||
import string, sys
|
||||
|
||||
# If no arguments were given, print a helpful message
|
||||
if len(sys.argv)==1:
|
||||
print 'Usage: celsius temp1 temp2 ...'
|
||||
sys.exit(0)
|
||||
|
||||
# Loop over the arguments
|
||||
for i in sys.argv[1:]:
|
||||
try:
|
||||
fahrenheit=float(string.atoi(i))
|
||||
except string.atoi_error:
|
||||
print repr(i), "not a numeric value"
|
||||
else:
|
||||
celsius=(fahrenheit-32)*5.0/9.0
|
||||
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))
|
||||
12
demo/docs/ruby.rb
Normal file
12
demo/docs/ruby.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
# Program to find the factorial of a number
|
||||
def fact(n)
|
||||
if n == 0
|
||||
1
|
||||
else
|
||||
n * fact(n-1)
|
||||
end
|
||||
end
|
||||
|
||||
puts fact(ARGV[0].to_i)
|
||||
12
demo/docs/scala.scala
Normal file
12
demo/docs/scala.scala
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//http://www.scala-lang.org/node/227
|
||||
/* Defines a new method 'sort' for array objects */
|
||||
object implicits extends Application {
|
||||
implicit def arrayWrapper[A : ClassManifest](x: Array[A]) =
|
||||
new {
|
||||
def sort(p: (A, A) => Boolean) = {
|
||||
util.Sorting.stableSort(x, p); x
|
||||
}
|
||||
}
|
||||
val x = Array(2, 3, 1, 4)
|
||||
println("x = "+ x.sort((x: Int, y: Int) => x < y))
|
||||
}
|
||||
20
demo/docs/scss.scss
Normal file
20
demo/docs/scss.scss
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* style.scss */
|
||||
|
||||
#navbar {
|
||||
$navbar-width: 800px;
|
||||
$items: 5;
|
||||
$navbar-color: #ce4dd6;
|
||||
|
||||
width: $navbar-width;
|
||||
border-bottom: 2px solid $navbar-color;
|
||||
|
||||
li {
|
||||
float: left;
|
||||
width: $navbar-width/$items - 10px;
|
||||
|
||||
background-color: lighten($navbar-color, 20%);
|
||||
&:hover {
|
||||
background-color: lighten($navbar-color, 10%);
|
||||
}
|
||||
}
|
||||
}
|
||||
83
demo/docs/svg.svg
Normal file
83
demo/docs/svg.svg
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<svg
|
||||
width="800" height="600"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
onload="StartAnimation(evt)">
|
||||
|
||||
<title>Test Tube Progress Bar</title>
|
||||
<desc>Created for the Web Directions SVG competition</desc>
|
||||
|
||||
<script type="text/ecmascript"><![CDATA[
|
||||
var timevalue = 0;
|
||||
var timer_increment = 1;
|
||||
var max_time = 100;
|
||||
var hickory;
|
||||
var dickory;
|
||||
var dock;
|
||||
var i;
|
||||
|
||||
function StartAnimation(evt) {
|
||||
hickory = evt.target.ownerDocument.getElementById("hickory");
|
||||
dickory = evt.target.ownerDocument.getElementById("dickory");
|
||||
dock = evt.target.ownerDocument.getElementById("dock");
|
||||
|
||||
ShowAndGrowElement();
|
||||
}
|
||||
function ShowAndGrowElement() {
|
||||
timevalue = timevalue + timer_increment;
|
||||
if (timevalue > max_time)
|
||||
return;
|
||||
// Scale the text string gradually until it is 20 times larger
|
||||
scalefactor = (timevalue * 650) / max_time;
|
||||
|
||||
if (timevalue < 30) {
|
||||
hickory.setAttribute("display", "");
|
||||
hickory.setAttribute("transform", "translate(" + (600+scalefactor*3*-1 ) + ", -144 )");
|
||||
}
|
||||
|
||||
if (timevalue > 30 && timevalue < 66) {
|
||||
dickory.setAttribute("display", "");
|
||||
dickory.setAttribute("transform", "translate(" + (-795+scalefactor*2) + ", 0 )");
|
||||
}
|
||||
if (timevalue > 66) {
|
||||
dock.setAttribute("display", "");
|
||||
dock.setAttribute("transform", "translate(" + (1450+scalefactor*2*-1) + ", 144 )");
|
||||
}
|
||||
|
||||
// Call ShowAndGrowElement again <timer_increment> milliseconds later.
|
||||
setTimeout("ShowAndGrowElement()", timer_increment)
|
||||
}
|
||||
window.ShowAndGrowElement = ShowAndGrowElement
|
||||
]]</script>
|
||||
|
||||
<rect
|
||||
fill="#2e3436"
|
||||
fill-rule="nonzero"
|
||||
stroke-width="3"
|
||||
y="0"
|
||||
x="0"
|
||||
height="600"
|
||||
width="800"
|
||||
id="rect3590"/>
|
||||
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="hickory"
|
||||
display="none">
|
||||
Hickory,</text>
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="dickory"
|
||||
display="none">
|
||||
dickory,</text>
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="dock"
|
||||
display="none">
|
||||
dock!</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
29
demo/docs/textile.textile
Normal file
29
demo/docs/textile.textile
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
h1. Textile document
|
||||
|
||||
h2. Heading Two
|
||||
|
||||
h3. A two-line
|
||||
header
|
||||
|
||||
h2. Another two-line
|
||||
header
|
||||
|
||||
Paragraph:
|
||||
one, two,
|
||||
thee lines!
|
||||
|
||||
p(classone two three). This is a paragraph with classes
|
||||
|
||||
p(#id). (one with an id)
|
||||
|
||||
p(one two three#my_id). ..classes + id
|
||||
|
||||
* Unordered list
|
||||
** sublist
|
||||
* back again!
|
||||
** sublist again..
|
||||
|
||||
# ordered
|
||||
|
||||
bg. Blockquote!
|
||||
This is a two-list blockquote..!
|
||||
|
|
@ -213,476 +213,7 @@
|
|||
|
||||
<div id="editor">
|
||||
</div>
|
||||
<script type="text/editor" id="csharptext">public void HelloWorld() {
|
||||
//Say Hello!
|
||||
Console.WriteLine("Hello World");
|
||||
}</script>
|
||||
<script type="text/editor" id="jstext">function foo(items) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
alert(items[i] + "juhu");
|
||||
} // Real Tab.
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="csstext">.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="scsstext">/* style.scss */
|
||||
|
||||
#navbar {
|
||||
$navbar-width: 800px;
|
||||
$items: 5;
|
||||
$navbar-color: #ce4dd6;
|
||||
|
||||
width: $navbar-width;
|
||||
border-bottom: 2px solid $navbar-color;
|
||||
|
||||
li {
|
||||
float: left;
|
||||
width: $navbar-width/$items - 10px;
|
||||
|
||||
background-color: lighten($navbar-color, 20%);
|
||||
&:hover {
|
||||
background-color: lighten($navbar-color, 10%);
|
||||
}
|
||||
}
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="htmltext"><html>
|
||||
<head>
|
||||
|
||||
<style type="text/css">
|
||||
.text-layer {
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 12px;
|
||||
cursor: text;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1 style="color:red">Juhu Kinners</h1>
|
||||
</body>
|
||||
</html></script>
|
||||
|
||||
<script type="text/editor" id="javatext">public class InfiniteLoop {
|
||||
|
||||
/*
|
||||
* This will cause the program to hang...
|
||||
*
|
||||
* Taken from:
|
||||
* http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
double d = Double.parseDouble("2.2250738585072012e-308");
|
||||
|
||||
// unreachable code
|
||||
System.out.println("Value: " + d);
|
||||
}
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="pythontext">#!/usr/local/bin/python
|
||||
|
||||
import string, sys
|
||||
|
||||
# If no arguments were given, print a helpful message
|
||||
if len(sys.argv)==1:
|
||||
print 'Usage: celsius temp1 temp2 ...'
|
||||
sys.exit(0)
|
||||
|
||||
# Loop over the arguments
|
||||
for i in sys.argv[1:]:
|
||||
try:
|
||||
fahrenheit=float(string.atoi(i))
|
||||
except string.atoi_error:
|
||||
print repr(i), "not a numeric value"
|
||||
else:
|
||||
celsius=(fahrenheit-32)*5.0/9.0
|
||||
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))</script>
|
||||
|
||||
<script type="text/editor" id="phptext"><?php
|
||||
|
||||
function nfact($n) {
|
||||
if ($n == 0) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return $n * nfact($n - 1);
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n\nPlease enter a whole number ... ";
|
||||
$num = trim(fgets(STDIN));
|
||||
|
||||
// ===== PROCESS - Determing the factorial of the input number =====
|
||||
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
|
||||
echo $output;
|
||||
|
||||
?></script>
|
||||
|
||||
<script type="text/editor" id="plaintext">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
|
||||
|
||||
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
|
||||
|
||||
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
|
||||
|
||||
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
|
||||
|
||||
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.
|
||||
|
||||
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="rubytext">#!/usr/bin/ruby
|
||||
|
||||
# Program to find the factorial of a number
|
||||
def fact(n)
|
||||
if n == 0
|
||||
1
|
||||
else
|
||||
n * fact(n-1)
|
||||
end
|
||||
end
|
||||
|
||||
puts fact(ARGV[0].to_i)
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="cpptext">// compound assignment operators
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main ()
|
||||
{
|
||||
int a, b=3; /* foobar */
|
||||
a = b;
|
||||
a+=2; // equivalent to a=a+2
|
||||
cout << a;
|
||||
return 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="coffeetext">#!/usr/bin/env coffee
|
||||
|
||||
try
|
||||
throw URIError decodeURI(0xC0ffee * 123456.7e-8 / .9)
|
||||
catch e
|
||||
console.log 'qstring' + "qqstring" + '''
|
||||
qdoc
|
||||
''' + """
|
||||
qqdoc
|
||||
"""
|
||||
|
||||
do ->
|
||||
###
|
||||
herecomment
|
||||
###
|
||||
re = /regex/imgy.test ///
|
||||
heregex # comment
|
||||
///imgy
|
||||
this isnt: `just JavaScript`
|
||||
undefined</script>
|
||||
|
||||
<script type="text/editor" id="jsontext">{
|
||||
"query": {
|
||||
"count": 10,
|
||||
"created": "2011-06-21T08:10:46Z",
|
||||
"lang": "en-US",
|
||||
"results": {
|
||||
"photo": [
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5855620975",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "f1f5e8515d",
|
||||
"server": "5110",
|
||||
"title": "7087 bandit cat"
|
||||
},
|
||||
{
|
||||
"farm": "4",
|
||||
"id": "5856170534",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "ff1efb2a6f",
|
||||
"server": "3217",
|
||||
"title": "6975 rusty cat"
|
||||
},
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5856172972",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "51249875@N03",
|
||||
"secret": "6c6887347c",
|
||||
"server": "5192",
|
||||
"title": "watermarked-cats"
|
||||
},
|
||||
{
|
||||
"farm": "6",
|
||||
"id": "5856168328",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "0c1cfdf64c",
|
||||
"server": "5078",
|
||||
"title": "7020 mandy cat"
|
||||
},
|
||||
{
|
||||
"farm": "3",
|
||||
"id": "5856171774",
|
||||
"isfamily": "0",
|
||||
"isfriend": "0",
|
||||
"ispublic": "1",
|
||||
"owner": "32021554@N04",
|
||||
"secret": "7f5a3180ab",
|
||||
"server": "2696",
|
||||
"title": "7448 bobby cat"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}</script>
|
||||
|
||||
<script type="text/editor" id="perltext">#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
my $num_primes = 0;
|
||||
my @primes;
|
||||
|
||||
# Put 2 as the first prime so we won't have an empty array
|
||||
$primes[$num_primes] = 2;
|
||||
$num_primes++;
|
||||
|
||||
MAIN_LOOP:
|
||||
for my $number_to_check (3 .. 200)
|
||||
{
|
||||
for my $p (0 .. ($num_primes-1))
|
||||
{
|
||||
if ($number_to_check % $primes[$p] == 0)
|
||||
{
|
||||
next MAIN_LOOP;
|
||||
}
|
||||
}
|
||||
|
||||
# If we reached this point it means $number_to_check is not
|
||||
# divisable by any prime number that came before it.
|
||||
$primes[$num_primes] = $number_to_check;
|
||||
$num_primes++;
|
||||
}
|
||||
|
||||
for my $p (0 .. ($num_primes-1))
|
||||
{
|
||||
print $primes[$p], ", ";
|
||||
}
|
||||
print "\n";
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="ocamltext">(*
|
||||
* Example of early return implementation taken from
|
||||
* http://ocaml.janestreet.com/?q=node/91
|
||||
*)
|
||||
|
||||
let with_return (type t) (f : _ -> t) =
|
||||
let module M =
|
||||
struct exception Return of t end
|
||||
in
|
||||
let return = { return = (fun x -> raise (M.Return x)); } in
|
||||
try f return with M.Return x -> x
|
||||
|
||||
|
||||
(* Function that uses the 'early return' functionality provided by `with_return` *)
|
||||
let sum_until_first_negative list =
|
||||
with_return (fun r ->
|
||||
List.fold list ~init:0 ~f:(fun acc x ->
|
||||
if x >= 0 then acc + x else r.return acc))
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="clojuretext">(defn parting
|
||||
"returns a String parting in a given language"
|
||||
([] (parting "World"))
|
||||
([name] (parting name "en"))
|
||||
([name language]
|
||||
; condp is similar to a case statement in other languages.
|
||||
; It is described in more detail later.
|
||||
; It is used here to take different actions based on whether the
|
||||
; parameter "language" is set to "en", "es" or something else.
|
||||
(condp = language
|
||||
"en" (str "Goodbye, " name)
|
||||
"es" (str "Adios, " name)
|
||||
(throw (IllegalArgumentException.
|
||||
(str "unsupported language " language))))))
|
||||
|
||||
(println (parting)) ; -> Goodbye, World
|
||||
(println (parting "Mark")) ; -> Goodbye, Mark
|
||||
(println (parting "Mark" "es")) ; -> Adios, Mark
|
||||
(println (parting "Mark", "xy")) ; -> java.lang.IllegalArgumentException: unsupported language xy</script>
|
||||
|
||||
<script type="text/editor" id="svgtext"><svg
|
||||
width="800" height="600"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
onload="StartAnimation(evt)">
|
||||
|
||||
<title>Test Tube Progress Bar</title>
|
||||
<desc>Created for the Web Directions SVG competition</desc>
|
||||
|
||||
<script type="text/ecmascript"><![CDATA[
|
||||
var timevalue = 0;
|
||||
var timer_increment = 1;
|
||||
var max_time = 100;
|
||||
var hickory;
|
||||
var dickory;
|
||||
var dock;
|
||||
var i;
|
||||
|
||||
function StartAnimation(evt) {
|
||||
hickory = evt.target.ownerDocument.getElementById("hickory");
|
||||
dickory = evt.target.ownerDocument.getElementById("dickory");
|
||||
dock = evt.target.ownerDocument.getElementById("dock");
|
||||
|
||||
ShowAndGrowElement();
|
||||
}
|
||||
function ShowAndGrowElement() {
|
||||
timevalue = timevalue + timer_increment;
|
||||
if (timevalue > max_time)
|
||||
return;
|
||||
// Scale the text string gradually until it is 20 times larger
|
||||
scalefactor = (timevalue * 650) / max_time;
|
||||
|
||||
if (timevalue < 30) {
|
||||
hickory.setAttribute("display", "");
|
||||
hickory.setAttribute("transform", "translate(" + (600+scalefactor*3*-1 ) + ", -144 )");
|
||||
}
|
||||
|
||||
if (timevalue > 30 && timevalue < 66) {
|
||||
dickory.setAttribute("display", "");
|
||||
dickory.setAttribute("transform", "translate(" + (-795+scalefactor*2) + ", 0 )");
|
||||
}
|
||||
if (timevalue > 66) {
|
||||
dock.setAttribute("display", "");
|
||||
dock.setAttribute("transform", "translate(" + (1450+scalefactor*2*-1) + ", 144 )");
|
||||
}
|
||||
|
||||
// Call ShowAndGrowElement again <timer_increment> milliseconds later.
|
||||
setTimeout("ShowAndGrowElement()", timer_increment)
|
||||
}
|
||||
window.ShowAndGrowElement = ShowAndGrowElement
|
||||
]]></script>
|
||||
|
||||
<rect
|
||||
fill="#2e3436"
|
||||
fill-rule="nonzero"
|
||||
stroke-width="3"
|
||||
y="0"
|
||||
x="0"
|
||||
height="600"
|
||||
width="800"
|
||||
id="rect3590"/>
|
||||
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="hickory"
|
||||
display="none">
|
||||
Hickory,</text>
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="dickory"
|
||||
display="none">
|
||||
dickory,</text>
|
||||
<text
|
||||
style="font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
|
||||
x="50"
|
||||
y="350"
|
||||
id="dock"
|
||||
display="none">
|
||||
dock!</text>
|
||||
</svg></script>
|
||||
<script type="text/editor" id="textiletext">h1. Textile document
|
||||
|
||||
h2. Heading Two
|
||||
|
||||
h3. A two-line
|
||||
header
|
||||
|
||||
h2. Another two-line
|
||||
header
|
||||
|
||||
Paragraph:
|
||||
one, two,
|
||||
thee lines!
|
||||
|
||||
p(classone two three). This is a paragraph with classes
|
||||
|
||||
p(#id). (one with an id)
|
||||
|
||||
p(one two three#my_id). ..classes + id
|
||||
|
||||
* Unordered list
|
||||
** sublist
|
||||
* back again!
|
||||
** sublist again..
|
||||
|
||||
# ordered
|
||||
|
||||
bg. Blockquote!
|
||||
This is a two-list blockquote..!
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="groovy">
|
||||
//http://groovy.codehaus.org/Concurrency+with+Groovy
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
def counter = new AtomicInteger()
|
||||
|
||||
synchronized out(message) {
|
||||
println(message)
|
||||
}
|
||||
|
||||
def th = Thread.start {
|
||||
for( i in 1..8 ) {
|
||||
sleep 30
|
||||
out "thread loop $i"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
|
||||
for( j in 1..4 ) {
|
||||
sleep 50
|
||||
out "main loop $j"
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
|
||||
th.join()
|
||||
|
||||
assert counter.get() == 12
|
||||
</script>
|
||||
|
||||
<script type="text/editor" id="scala">//http://www.scala-lang.org/node/227
|
||||
/* Defines a new method 'sort' for array objects */
|
||||
object implicits extends Application {
|
||||
implicit def arrayWrapper[A : ClassManifest](x: Array[A]) =
|
||||
new {
|
||||
def sort(p: (A, A) => Boolean) = {
|
||||
util.Sorting.stableSort(x, p); x
|
||||
}
|
||||
}
|
||||
val x = Array(2, 3, 1, 4)
|
||||
println("x = "+ x.sort((x: Int, y: Int) => x < y))
|
||||
}</script>
|
||||
<!-- DEVEL-->
|
||||
<script type="text/javascript">
|
||||
var require = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue