commit d2f10f3bbcff173c90d288f6c167d353c4bab33a Author: Araq Date: Fri Jul 17 10:22:09 2015 +0200 first commit diff --git a/1_intro.html b/1_intro.html new file mode 100644 index 0000000..8db6de5 --- /dev/null +++ b/1_intro.html @@ -0,0 +1,1100 @@ + + + + The ultimate introduction + + + + + + + + + +
+ Nimrod logo +
+ +
+

The ultimate introduction

+ +
+
+

What is Nim?

+ +
+
+

Philosophy

+ +
+
+

Why Nim?

+ +
+
+

Uses of Nim

+ +
+
+

URLs

+ + + + +
Websitehttp://nim-lang.org
Mailing listhttp://www.freelists.org/list/nim-dev
Forumhttp://forum.nim-lang.org
Githubhttps://github.com/Araq/Nim
IRCirc.freenode.net/nim
+
+
+

Installation

git clone -b devel git://github.com/nim-lang/Nim.git
+cd Nim
+git clone -b devel --depth 1 git://github.com/nim-lang/csources
+cd csources && sh build.sh
+cd ..
+bin/nim c koch
+./koch boot -d:release
+ +
+
+

Hello World

echo "hello world!"
+
+
+

Hello World

echo "hello world!"
nim c -r hello.nim
+ +
+
+

More Code!

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+
proc decimalToRoman*(number: range[1..3_999]): string =
+  ## Converts a number to a Roman numeral.
+  const romanComposites = {
+    "M": 1000, "CM": 900,
+    "D": 500, "CD": 400, "C": 100,
+    "XC": 90, "L": 50, "XL": 40, "X": 10, "IX": 9,
+    "V": 5, "IV": 4, "I": 1}
+  result = ""
+  var decVal = number.int
+  for key, val in items(romanComposites):
+    while decVal >= val:
+      decVal -= val
+      result.add(key)
+
+echo decimalToRoman(1009) # MIX
+ +
+
+

Nimble

+ +
+
+

Function application

Function application is f(), f(a), f(a, b).

+ +
+
+

Function application

Function application is f(), f(a), f(a, b).

+

And here is the sugar:

+ + + + + + + + +
SugarMeaningExample
f af(a)spawn log("some message")
a.f()f(a)db.fetchRow()
a.ff(a)mystring.len
f a, bf(a, b)echo "hello ", "world"
a.f(b)f(a, b)myarray.map(f)
a.f bf(a, b)db.fetchRow 1
f"\n"f(r"\n")re"\b[a-z*]\b"
+
+
+

Function application

Function application is f(), f(a), f(a, b).

+

And here is the sugar:

+ + + + + + + + +
SugarMeaningExample
f af(a)spawn log("some message")
a.f()f(a)db.fetchRow()
a.ff(a)mystring.len
f a, bf(a, b)echo "hello ", "world"
a.f(b)f(a, b)myarray.map(f)
a.f bf(a, b)db.fetchRow 1
f"\n"f(r"\n")re"\b[a-z*]\b"

BUT: f does not mean f(); myarray.map(f) passes f to map

+ +
+
+

Operators

+ +
+
+

Operators

+
proc `++`(x: var int; y: int = 1; z: int = 0) =
+  x = x + y + z
+
+var g = 70
+++g
+g ++ 7
+g.`++`(10, 20)
+echo g  # writes 108
+ +
+
+

Control flow

+ +
+
+

If vs when

1
+2
+3
+4
+5
+6
+7
+
when defined(posix):
+  proc getCreationTime(file: string): Time =
+    var res: Stat
+    if stat(file, res) < 0'i32:
+      let error = osLastError()
+      raiseOSError(error)
+    return res.st_ctime
+
+
+

Statements vs expressions

Statements require indentation:

+
# no indentation needed for single assignment statement:
+if x: x = false
+
+# indentation needed for nested if statement:
+if x:
+  if y:
+    y = false
+else:
+  y = true
+
+# indentation needed, because two statements follow the condition:
+if x:
+  x = false
+  y = false
+
+
+

Statements vs expressions

Expressions do not:

+
if thisIsaLongCondition() and
+    thisIsAnotherLongCondition(1,
+       2, 3, 4):
+  x = true
+ +
+
+

Builtin types

+ +
+
+

Builtin types

+ +
+
+

Builtin types

+ +
+
+

Builtin types

+ +
+
+

Builtin types

tuple

+ +
1
+2
+3
+4
+5
+6
+7
+8
+9
+
proc `+-`(x, y: int): (int, int) = (x - y, x + y)
+# alternatively
+proc `+-`(x, y: int): tuple[lowerBound, upperBound: int] = (x - y, x + y)
+
+let tup = 100 +- 10
+echo tup[0], " ", tup.upperBound
+
+# tuple unpacking
+let (lower, _) = 100 +- 10
+
+
+

Builtin types

object

+ +
1
+2
+3
+4
+5
+6
+7
+8
+9
+
type
+  Rect = object
+    x, y, w, h: int
+
+# construction:
+let r = Rect(x: 12, y: 22, w: 40, h: 80)
+
+# field access:
+echo r.x, " ", r.y
+
+
+

Builtin types

enums & sets

+
1
+2
+3
+4
+5
+6
+7
+8
+9
+
type
+  SandboxFlag* = enum        ## what the interpreter should allow
+    allowCast,               ## allow unsafe language feature: 'cast'
+    allowFFI,                ## allow the FFI
+    allowInfiniteLoops       ## allow endless loops
+  SandboxFlags* = set[SandboxFlag]
+
+proc runNimCode(code: string; flags: SandboxFlags = {allowCast, allowFFI}) =
+  ...
+
+
+

Builtin types

1
+2
+3
+4
+5
+6
+7
+
#define allowCast (1 << 0)
+#define allowFFI (1 << 1)
+#define allowInfiniteLoops (1 << 1)
+
+void runNimCode(char* code, unsigned int flags = allowCast|allowFFI);
+
+runNimCode("4+5", 700);
+
+
+

Builtin types

ref and ptr

+ + +
+
+

Regular expressions

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
# Model a regular expression
+type
+  RegexKind = enum          ## the regex AST's kind
+    reChar,                 ## character node  "c"
+    reCClass,               ## character class node   "[a-z]"
+    reStar,                 ## star node   "r*"
+    rePlus,                 ## plus node   "r+"
+    reOpt,                  ## option node  "r?"
+    reCat,                  ## concatenation node "ab"
+    reAlt,                  ## alternatives node "a|b"
+    reWordBoundary          ## "\b"
+  
+  RegExpr = ref object
+    case kind: RegexKind
+    of reWordBoundary: discard
+    of reChar:
+      c: char
+    of reCClass:
+      cc: set[char]
+    of reStar, rePlus, reOpt:
+      child0: RegExpr
+    of reCat, reAlt:
+      child1, child2: RegExpr
+
+
+

Equality

1
+2
+3
+4
+5
+6
+7
+8
+9
+
proc `==`(a, b: RegExpr): bool =
+  if a.kind == b.kind:
+    case a.kind
+    of reWordBoundary: result = true
+    of reChar: result = a.c == b.c
+    of reCClass: result = a.cc == b.cc
+    of reStar, rePlus, reOpt: result = `==`(a.child0, b.child0)
+    of reCat, reAlt: result = `==`(a.child1, b.child1) and
+                              `==`(a.child2, b.child2)
+
+
+

Accessors

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+
type
+  HashTable[K, V] = object
+    data: seq[(K, V)]
+
+proc hash[K](k: K): int = 0
+
+proc `[]`*[K, V](x: HashTable[K, V]; k: K): V =
+  result = x.data[hash(k)][1]
+
+proc `[]=`*[K, V](x: var HashTable[K, V]; k: K, v: V) =
+  x.data[hash(k)][1] = v
+
+
+proc initHashTable[K, V](): HashTable[K, V] =
+  result.data = @[]
+
+var tab = initHashTable[string, string]()
+tab["key"] = "abc"  # calls '[]=' accessor
+
+echo tab["key"]     # calls '[]' accessor
+
+
+

Accessors

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+
type
+  HashTable[K, V] = object
+    data: seq[(K, V)]
+
+proc hash[K](k: K): int = 0
+
+proc `[]`*[K, V](x: HashTable[K, V]; k: K): V =
+  result = x.data[hash(k)][1]
+
+proc `[]=`*[K, V](x: var HashTable[K, V]; k: K, v: V) =
+  x.data[hash(k)][1] = v
+
+
+proc initHashTable[K, V](): HashTable[K, V] =
+  result.data = @[]
+
+var tab = initHashTable[string, string]()
+tab["key"] = "abc"  # calls '[]=' accessor
+
+echo tab["key"]     # calls '[]' accessor
+
+# ouch:
+tab["key"].add "xyz"
+
+
+

Accessors

1
+2
+3
+4
+5
+6
+7
+8
+9
+
proc `[]`*[Key, Value](x: var HashTable[Key, Value]; k: Key): var Value =
+  result = x.data[hash(key)]
+
+
+var
+  tab = initHashTable[string, string]()
+
+# compiles :-)
+tab["key"].add "xyz"
+ +
+
+

Distinct

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+
# Taken from system.nim
+const taintMode = compileOption("taintmode")
+
+when taintMode:
+  type TaintedString* = distinct string
+  proc len*(s: TaintedString): int {.borrow.}
+else:
+  type TaintedString* = string
+
+proc readLine*(f: File): TaintedString {.tags: [ReadIOEffect], benign.}
+
+
+

Distinct

1
+2
+3
+
# taintmode_ex
+
+echo readLine(stdin)
nim c -r --taintMode:on taintmode_ex
+ +
+
+

Distinct

1
+2
+3
+
# taintmode_ex
+
+echo readLine(stdin).string
nim c -r --taintMode:on taintmode_ex
+ +
+
+

Distinct

1
+2
+3
+4
+5
+
# taintmode_ex
+
+proc `$`(x: TaintedString): string {.borrow.} # but: defeats the purpose
+
+echo readLine(stdin)
nim c -r --taintMode:on taintmode_ex
+ +
+
+

Module system

1
+2
+3
+4
+5
+
# Module A
+var
+  global*: string = "A.global"
+
+proc p*(x: string) = echo "exported ", x
1
+2
+3
+4
+
# Module B
+import A
+
+echo p(global)
+
+
+

Module system

1
+2
+3
+4
+5
+
# Module A
+var
+  global*: string = "A.global"
+
+proc p*(x: string) = echo "exported ", x
1
+2
+3
+4
+
# Module B
+from A import p
+
+echo p(A.global)
+
+
+

Module system

1
+2
+3
+4
+5
+
# Module A
+var
+  global*: string = "A.global"
+
+proc p*(x: string) = echo "exported ", x
1
+2
+3
+4
+
# Module B
+import A except global
+
+echo p(A.global)
+
+
+

Routines

+ +
+
+

Iterators

1
+2
+3
+4
+5
+6
+7
+8
+
iterator `..<`(a, b: int): int =
+  var i = a
+  while i < b:
+    yield i
+    i += 1
+
+for i in 0..<10:
+  echo i+1, "-th iteration"
+
+
+

Iterators

1
+2
+
for x in [1, 2, 3]:
+  echo x
+
+
+

Iterators

1
+2
+
for x in [1, 2, 3]:
+  echo x

Rewritten to:

+
1
+2
+
for x in items([1, 2, 3]):
+  echo x
+
+
+

Iterators

1
+2
+3
+4
+5
+
iterator items*[IX, T](a: array[IX, T]): T {.inline.} =
+  var i = low(IX)
+  while i <= high(IX):
+    yield a[i]
+    i += 1
+
+
+

Iterators

1
+2
+
for x in [1, 2, 3]:
+  x = 0      # doesn't compile
+
+
+

Iterators

1
+2
+3
+
var a = [1, 2, 3]
+for x in a:
+  x = 0     # doesn't compile
+
+
+

Iterators

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+
iterator mitems*[IX, T](a: var array[IX, T]): var T {.inline.} =
+  var i = low(IX)
+  if i <= high(IX):
+    while true:
+      yield a[i]
+      if i >= high(IX): break
+      i += 1
+
+var a = [1, 2, 3]
+for x in mitems(a):
+  x = 0     # compiles
+
+
+

Parallelism

1
+2
+3
+4
+5
+6
+7
+
import tables, strutils
+
+proc countWords(filename: string): CountTableRef[string] =
+  ## Counts all the words in the file.
+  result = newCountTable[string]()
+  for word in readFile(filename).split:
+    result.inc word
+
+
+

Parallelism

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+
#
+#
+const
+  files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"]
+
+proc main() =
+  var tab = newCountTable[string]()
+  for f in files:
+    let tab2 = countWords(f)
+    tab.merge(tab2)
+  tab.sort()
+  echo tab.largest
+
+main()
+
+
+

Parallelism

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
import threadpool
+
+const
+  files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"]
+
+proc main() =
+  var tab = newCountTable[string]()
+  var results: array[files.len, FlowVar[CountTableRef[string]]]
+  for i, f in files:
+    results[i] = spawn countWords(f)
+  for i in 0..high(results):
+    tab.merge( ^results[i] )
+  tab.sort()
+  echo tab.largest
+
+main()
+ + + +
+ diff --git a/1_intro.rst b/1_intro.rst new file mode 100644 index 0000000..a79d3f5 --- /dev/null +++ b/1_intro.rst @@ -0,0 +1,880 @@ +============================================================ + The ultimate introduction +============================================================ + + +What is Nim? +============ + +- new **systems** programming language +- compiles to C +- garbage collection + manual memory management +- thread local garbage collection +- design goals: efficient, expressive, elegant + +.. + * Nim compiles to C; C++ and Objective-C are also supported + * there is an experimental JavaScript backend + * it provides a soft realtime GC: you can tell it how long it is allowed to run + * the Nim compiler and **all** of the standard library (including the GC) + are written in Nim + * whole program dead code elimination: stdlib carefully crafted to make use + of it; for instance parsers do not use (runtime) regular expressions -> + re engine not part of the executable + * our infrastructure (IDE, build tools, package manager) is + also completely written in Nim + * infix/indentation based syntax + + +Philosophy +========== + +* power +* efficiency +* fun + +.. + Talk about what the plans for Nim were + + + +Why Nim? +======== + +- Major influences: Modula 3, Delphi, Ada, C++, Python, Lisp, Oberon. + +- Development started in 2006 +- First successful bootstrapping in 2008 + - compiler written in Delphi + - converted to Nim via "pas2nim" + + +Uses of Nim +=========== + +- games +- compilers +- operating system development +- scientific computing +- scripting + + +URLs +==== + +============ ================================================ +Website http://nim-lang.org +Mailing list http://www.freelists.org/list/nim-dev +Forum http://forum.nim-lang.org +Github https://github.com/Araq/Nim +IRC irc.freenode.net/nim +============ ================================================ + + + + +Installation +============ + +:: + git clone -b devel git://github.com/nim-lang/Nim.git + cd Nim + git clone -b devel --depth 1 git://github.com/nim-lang/csources + cd csources && sh build.sh + cd .. + bin/nim c koch + ./koch boot -d:release + + + +Hello World +=========== + +.. code-block:: nim + echo "hello world!" + + +Hello World +=========== + +.. code-block:: nim + echo "hello world!" + +:: + nim c -r hello.nim + + + +More Code! +========== + +.. code-block:: nim + :number-lines: + + proc decimalToRoman*(number: range[1..3_999]): string = + ## Converts a number to a Roman numeral. + const romanComposites = { + "M": 1000, "CM": 900, + "D": 500, "CD": 400, "C": 100, + "XC": 90, "L": 50, "XL": 40, "X": 10, "IX": 9, + "V": 5, "IV": 4, "I": 1} + result = "" + var decVal = number.int + for key, val in items(romanComposites): + while decVal >= val: + decVal -= val + result.add(key) + + echo decimalToRoman(1009) # MIX + + +- ``{"M": 1000, "CM": 900}`` sugar for ``[("M": 1000), ("CM": 900)]`` +- ``result`` implicitly available + + +Nimble +====== + +- Live demo. + + +Function application +==================== + +Function application is ``f()``, ``f(a)``, ``f(a, b)``. + + +Function application +==================== + +Function application is ``f()``, ``f(a)``, ``f(a, b)``. + +And here is the sugar: + +=========== ================== =============================== +Sugar Meaning Example +=========== ================== =============================== +``f a`` ``f(a)`` ``spawn log("some message")`` +``a.f()`` ``f(a)`` ``db.fetchRow()`` +``a.f`` ``f(a)`` ``mystring.len`` +``f a, b`` ``f(a, b)`` ``echo "hello ", "world"`` +``a.f(b)`` ``f(a, b)`` ``myarray.map(f)`` +``a.f b`` ``f(a, b)`` ``db.fetchRow 1`` +``f"\n"`` ``f(r"\n")`` ``re"\b[a-z*]\b"`` +=========== ================== =============================== + + +Function application +==================== + +Function application is ``f()``, ``f(a)``, ``f(a, b)``. + +And here is the sugar: + +=========== ================== =============================== +Sugar Meaning Example +=========== ================== =============================== +``f a`` ``f(a)`` ``spawn log("some message")`` +``a.f()`` ``f(a)`` ``db.fetchRow()`` +``a.f`` ``f(a)`` ``mystring.len`` +``f a, b`` ``f(a, b)`` ``echo "hello ", "world"`` +``a.f(b)`` ``f(a, b)`` ``myarray.map(f)`` +``a.f b`` ``f(a, b)`` ``db.fetchRow 1`` +``f"\n"`` ``f(r"\n")`` ``re"\b[a-z*]\b"`` +=========== ================== =============================== + + +**BUT**: ``f`` does not mean ``f()``; ``myarray.map(f)`` passes ``f`` to ``map`` + + +Operators +========= + +* operators are simply sugar for functions +* operator in backticks is treated like an identifier + + :: + `@`(x, y) + x.`@`(y) + `@`(x) + x.`@`() + x.`@` + + +Operators +========= + +* Of course, most of the time binary operators are simply invoked as ``x @ y`` + and unary operators as ``@x``. +* No explicit distinction between binary and unary operators: + +.. code-block:: Nim + proc `++`(x: var int; y: int = 1; z: int = 0) = + x = x + y + z + + var g = 70 + ++g + g ++ 7 + g.`++`(10, 20) + echo g # writes 108 + +* parameters are readonly unless declared as ``var`` +* ``var`` means "pass by reference" (implemented with a hidden pointer) + + +Control flow +============ + + +- The usual control flow statements are available: + * if + * case + * when + * while + * for + * try + * defer + * return + * yield + + +If vs when +========== + +.. code-block:: nim + :number-lines: + + when defined(posix): + proc getCreationTime(file: string): Time = + var res: Stat + if stat(file, res) < 0'i32: + let error = osLastError() + raiseOSError(error) + return res.st_ctime + + + +Statements vs expressions +========================= + +Statements require indentation: + +.. code-block:: nim + # no indentation needed for single assignment statement: + if x: x = false + + # indentation needed for nested if statement: + if x: + if y: + y = false + else: + y = true + + # indentation needed, because two statements follow the condition: + if x: + x = false + y = false + + +Statements vs expressions +========================= + +Expressions do not: + +.. code-block:: nim + + if thisIsaLongCondition() and + thisIsAnotherLongCondition(1, + 2, 3, 4): + x = true + +- Rule of thumb: optional indentation after operators, ``(`` and ``,`` +- ``if``, ``case`` etc also available as expressions + + + +Builtin types +============= + +- ``int`` -- platform dependent (16) 32 or 64 bit signed number + * overflows produce an exception in debug mode; wrap around in release mode + +- ``float`` -- 64 bit floating point number + * float64 an alias for float + * float32 32 bit floating point number + +- ``int8`` / ``int16`` / ``int32`` / ``int64`` + * integer types with a platform independent size + + +Builtin types +============= + +- ``uint`` / ``uint8`` / ``uint16`` / ``uint32`` / ``uint64`` + * like in C, always wrap around; modulo arithmetic + * heavily discouraged: ``for in 0 .. x.len - 3`` + should iterate 0 times when ``x.len == 0``, not 4294967293 times! + * instead: use ``Natural`` + +- ``range[T]`` + * subrange type; quite heavily used in Nim + (``type Natural = range[0..high(int)]``) + +- ``bool`` + + +Builtin types +============= + +- ``array[FixedSize, T]`` + * fixed size in Nim + * value based datatypes + * layout is compatible to C + * create via ``[1, 2, 3]`` construction + +- ``seq[T]`` + * dynamically resizable at runtime + * grow with ``add``, resize with ``setLen`` + * create via ``@`` or ``newSeq``: ``@[1, 2, 3]`` + * allocated on the heap and GC'ed + +- ``openArray[T]`` + * allows to pass ``seq`` or ``array`` to a routine + * internally a (pointer, length) pair + + +Builtin types +============= + +- ``proc (a, b: string) {.closure.}`` + * functions are first class in Nim + * "calling convention" affects type compatibility + * ``closure`` is a special calling convention (closures are GC'ed) + +- ``char`` / ``string`` / ``cstring`` + * ``char`` is simply an octet, ``string`` is almost a ``seq[char]``. + * ``string`` is (usually) allocated on the heap and GC'ed + + +Builtin types +============= + +``tuple`` + +* value based datatypes +* structural typing +* optional field names +* construct with ``()`` + +.. code-block:: Nim + :number-lines: + + proc `+-`(x, y: int): (int, int) = (x - y, x + y) + # alternatively + proc `+-`(x, y: int): tuple[lowerBound, upperBound: int] = (x - y, x + y) + + let tup = 100 +- 10 + echo tup[0], " ", tup.upperBound + + # tuple unpacking + let (lower, _) = 100 +- 10 + + +Builtin types +============= + +``object`` + +* nominal typing +* value based datatypes + +.. code-block:: nim + :number-lines: + + type + Rect = object + x, y, w, h: int + + # construction: + let r = Rect(x: 12, y: 22, w: 40, h: 80) + + # field access: + echo r.x, " ", r.y + + +Builtin types +============= + +enums & sets + +.. code-block:: nim + :number-lines: + + type + SandboxFlag* = enum ## what the interpreter should allow + allowCast, ## allow unsafe language feature: 'cast' + allowFFI, ## allow the FFI + allowInfiniteLoops ## allow endless loops + SandboxFlags* = set[SandboxFlag] + + proc runNimCode(code: string; flags: SandboxFlags = {allowCast, allowFFI}) = + ... + + +Builtin types +============= + +.. code-block:: C + :number-lines: + + #define allowCast (1 << 0) + #define allowFFI (1 << 1) + #define allowInfiniteLoops (1 << 1) + + void runNimCode(char* code, unsigned int flags = allowCast|allowFFI); + + runNimCode("4+5", 700); + + +Builtin types +============= + +``ref`` and ``ptr`` + +* pointers; ``ref`` is a "traced" pointer, ``ptr`` is an "untraced" pointer +* ``string``, ``seq``, ``ref`` and ``closure`` are GC'ed, nothing else +* ``ref object`` an idiom to get reference semantics out of objects + + +Regular expressions +=================== + +.. code-block:: nim + :number-lines: + + # Model a regular expression + type + RegexKind = enum ## the regex AST's kind + reChar, ## character node "c" + reCClass, ## character class node "[a-z]" + reStar, ## star node "r*" + rePlus, ## plus node "r+" + reOpt, ## option node "r?" + reCat, ## concatenation node "ab" + reAlt, ## alternatives node "a|b" + reWordBoundary ## "\b" + + RegExpr = ref object + case kind: RegexKind + of reWordBoundary: discard + of reChar: + c: char + of reCClass: + cc: set[char] + of reStar, rePlus, reOpt: + child0: RegExpr + of reCat, reAlt: + child1, child2: RegExpr + + +Equality +======== + +.. code-block:: nim + :number-lines: + + proc `==`(a, b: RegExpr): bool = + if a.kind == b.kind: + case a.kind + of reWordBoundary: result = true + of reChar: result = a.c == b.c + of reCClass: result = a.cc == b.cc + of reStar, rePlus, reOpt: result = `==`(a.child0, b.child0) + of reCat, reAlt: result = `==`(a.child1, b.child1) and + `==`(a.child2, b.child2) + + +Accessors +========= + +.. code-block:: nim + :number-lines: + + type + HashTable[K, V] = object + data: seq[(K, V)] + + proc hash[K](k: K): int = 0 + + proc `[]`*[K, V](x: HashTable[K, V]; k: K): V = + result = x.data[hash(k)][1] + + proc `[]=`*[K, V](x: var HashTable[K, V]; k: K, v: V) = + x.data[hash(k)][1] = v + + + proc initHashTable[K, V](): HashTable[K, V] = + result.data = @[] + + var tab = initHashTable[string, string]() + tab["key"] = "abc" # calls '[]=' accessor + + echo tab["key"] # calls '[]' accessor + + +Accessors +========= + +.. code-block:: nim + :number-lines: + + type + HashTable[K, V] = object + data: seq[(K, V)] + + proc hash[K](k: K): int = 0 + + proc `[]`*[K, V](x: HashTable[K, V]; k: K): V = + result = x.data[hash(k)][1] + + proc `[]=`*[K, V](x: var HashTable[K, V]; k: K, v: V) = + x.data[hash(k)][1] = v + + + proc initHashTable[K, V](): HashTable[K, V] = + result.data = @[] + + var tab = initHashTable[string, string]() + tab["key"] = "abc" # calls '[]=' accessor + + echo tab["key"] # calls '[]' accessor + + # ouch: + tab["key"].add "xyz" + + +Accessors +========= + +.. code-block:: nim + :number-lines: + + + proc `[]`*[Key, Value](x: var HashTable[Key, Value]; k: Key): var Value = + result = x.data[hash(key)] + + + var + tab = initHashTable[string, string]() + + # compiles :-) + tab["key"].add "xyz" + + +* ``var`` "pass by reference" for parameters +* can also by used for return values + + +Distinct +======== + +.. code-block:: nim + :number-lines: + + # Taken from system.nim + const taintMode = compileOption("taintmode") + + when taintMode: + type TaintedString* = distinct string + proc len*(s: TaintedString): int {.borrow.} + else: + type TaintedString* = string + + proc readLine*(f: File): TaintedString {.tags: [ReadIOEffect], benign.} + + +Distinct +======== + +.. code-block:: nim + :number-lines: + # taintmode_ex + + echo readLine(stdin) + +:: + nim c -r --taintMode:on taintmode_ex + + + +Distinct +======== + +.. code-block:: nim + :number-lines: + # taintmode_ex + + echo readLine(stdin).string + +:: + nim c -r --taintMode:on taintmode_ex + + + +Distinct +======== + +.. code-block:: nim + :number-lines: + # taintmode_ex + + proc `$`(x: TaintedString): string {.borrow.} # but: defeats the purpose + + echo readLine(stdin) + +:: + nim c -r --taintMode:on taintmode_ex + + +Module system +============= + +.. code-block::nim + :number-lines: + + # Module A + var + global*: string = "A.global" + + proc p*(x: string) = echo "exported ", x + + +.. code-block::nim + :number-lines: + + # Module B + import A + + echo p(global) + + +Module system +============= + +.. code-block::nim + :number-lines: + + # Module A + var + global*: string = "A.global" + + proc p*(x: string) = echo "exported ", x + + +.. code-block::nim + :number-lines: + + # Module B + from A import p + + echo p(A.global) + + +Module system +============= + +.. code-block::nim + :number-lines: + + # Module A + var + global*: string = "A.global" + + proc p*(x: string) = echo "exported ", x + + +.. code-block::nim + :number-lines: + + # Module B + import A except global + + echo p(A.global) + + + +Routines +======== + +- ``proc`` +- ``iterator`` +- ``template`` +- ``macro`` +- ``method`` +- ``converter`` +- (``func``) + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + iterator `..<`(a, b: int): int = + var i = a + while i < b: + yield i + i += 1 + + for i in 0..<10: + echo i+1, "-th iteration" + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + for x in [1, 2, 3]: + echo x + + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + for x in [1, 2, 3]: + echo x + + +Rewritten to: + + +.. code-block:: nim + :number-lines: + + for x in items([1, 2, 3]): + echo x + +.. + for i, x in foobar is rewritten to use the pairs iterator + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + iterator items*[IX, T](a: array[IX, T]): T {.inline.} = + var i = low(IX) + while i <= high(IX): + yield a[i] + i += 1 + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + for x in [1, 2, 3]: + x = 0 # doesn't compile + + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + var a = [1, 2, 3] + for x in a: + x = 0 # doesn't compile + + +Iterators +========= + +.. code-block:: nim + :number-lines: + + iterator mitems*[IX, T](a: var array[IX, T]): var T {.inline.} = + var i = low(IX) + if i <= high(IX): + while true: + yield a[i] + if i >= high(IX): break + i += 1 + + var a = [1, 2, 3] + for x in mitems(a): + x = 0 # compiles + + +Parallelism +=========== + +.. code-block::nim + :number-lines: + + import tables, strutils + + proc countWords(filename: string): CountTableRef[string] = + ## Counts all the words in the file. + result = newCountTable[string]() + for word in readFile(filename).split: + result.inc word + + +Parallelism +=========== + +.. code-block::nim + :number-lines: + + # + # + const + files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"] + + proc main() = + var tab = newCountTable[string]() + for f in files: + let tab2 = countWords(f) + tab.merge(tab2) + tab.sort() + echo tab.largest + + main() + + +Parallelism +=========== + +.. code-block::nim + :number-lines: + + import threadpool + + const + files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"] + + proc main() = + var tab = newCountTable[string]() + var results: array[files.len, ***FlowVar[CountTableRef[string]]***] + for i, f in files: + results[i] = ***spawn*** countWords(f) + for i in 0..high(results): + tab.merge(*** ^results[i] ***) + tab.sort() + echo tab.largest + + main() diff --git a/2_meta.html b/2_meta.html new file mode 100644 index 0000000..679cbe0 --- /dev/null +++ b/2_meta.html @@ -0,0 +1,716 @@ + + + + Meta programming + + + + + + + + + +
+ Nimrod logo +
+ +
+

Meta programming

+ +
+
+

Templates

+
# from System.nim
+template `!=` (a, b: untyped): untyped =
+  not (a == b)
+
+assert(5 != 6) # rewritten to: assert(not (5 == 6))
+ +
+
+

Templates

1
+2
+3
+4
+5
+6
+7
+8
+
template html(name, body) =
+  proc name(): string =
+    result = "<html>"
+    body
+    result.add("</html>")
+
+html mainPage:
+  echo "colon syntax to pass statements to template"
+
+
+

Templates

Templates already suffice to implement simple DSLs:

+
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+
html mainPage:
+  head:
+    title "The Nim programming language"
+  body:
+    ul:
+      li "efficient"
+      li "expressive"
+      li "elegant"
+
+echo mainPage()

Produces:

+<html>
+  <head><title>The Nim programming language</title></head>
+  <body>
+    <ul>
+      <li>efficient</li>
+      <li>expressive</li>
+      <li>elegant</li>
+    </ul>
+  </body>
+</html>
+

+ +
+
+

Templates

template html(name, body) =
+  proc name(): string =
+    result = "<html>"
+    body
+    result.add("</html>")
+
+template head(body) =
+  result.add("<head>")
+  body
+  result.add("</head>")
+
+...
+
+template title(x) =
+  result.add("<title>$1</title>" % x)
+
+template li(x) =
+  result.add("<li>$1</li>" % x)
+
+
+

Templates

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+
proc mainPage(): string =
+  result = "<html>"
+  result.add("<head>")
+  result.add("<title>$1</title>" % "The Nim programming language")
+  result.add("</head>")
+  result.add("<body>")
+  result.add("<ul>")
+  result.add("<li>$1</li>" % "efficient")
+  result.add("<li>$1</li>" % "expressive")
+  result.add("<li>$1</li>" % "elegant")
+  result.add("</ul>")
+  result.add("</body>")
+  result.add("</html>")
+
+
+

Macros

+ +
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+
proc toTest(x, y: int) =
+  try:
+    case x
+    of 8:
+      if y > 9: echo "8.1"
+      else: echo "8.2"
+    of 9: echo "9"
+    else: echo "else"
+    echo "no exception"
+  except IoError:
+    echo "IoError"
+
+toTest(8, 10)
+toTest(10, 10)
+
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+
proc toTest(x, y: int) =
+  try:
+    case x
+    of 8:
+      if y > 9: echo "8.1"
+      else: echo "8.2"
+    of 9: echo "9"
+    else: echo "else"
+    echo "no exception"
+  except IoError:
+    echo "IoError"
+
+toTest(8, 10)
+toTest(10, 10)
+
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+
# This is the code our macro will produce!
+
+var
+  track = [("line 9", false), ("line 13", false), ...]
+
+proc toTest(x, y: int) =
+  try:
+    case x
+    of 8:
+      if y > 9:
+        track[0][1] = true
+        echo "8.1"
+      else:
+        track[1][1] = true
+        echo "8.2"
+    of 9:
+      track[2][1] = true
+      echo "9"
+    else:
+      track[3][1] = true
+      echo "foo"
+    echo "no exception"
+  except IoError:
+    track[4][1] = true
+    echo "IoError"
+
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+
toTest(8, 10)
+toTest(1, 2)
+
+proc listCoverage(s: openArray[(string, bool)]) =
+  for x in s:
+    if not x[1]: echo "NOT COVERED ", x[0]
+
+listCoverage(track)
+
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+
import macros
+
+macro cov(n: untyped): untyped =
+  result = n
+  echo treeRepr n
+
+cov:
+  proc toTest(x, y: int) =
+    try:
+      case x
+      of 8:
+        if y > 9: echo "8.1"
+        else: echo "8.2"
+      of 9: echo "9"
+      else: echo "foo"
+      echo "no exception"
+    except IoError:
+      echo "IoError"
+  
+  toTest(8, 10)
+  toTest(10, 10)
+
+
+

Code coverage

...
+      TryStmt
+        StmtList
+          CaseStmt
+            Ident !"x"
+            OfBranch
+              IntLit 8
+              StmtList
+                IfStmt
+                  ElifBranch
+                    Infix
+                      Ident !">"
+                      Ident !"y"
+                      IntLit 9
+                    StmtList [...]
+                  Else
+                    StmtList [...]
+            OfBranch
+              IntLit 9
+              StmtList
+                Command
+                  Ident !"echo"
+                  StrLit 9
+            Else
+              StmtList
+                Command
+                  Ident !"echo"
+                  StrLit foo
+          Command [...]
+        ExceptBranch
+          [...]
+ +
+
+

Code coverage

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+
## Code coverage macro
+
+import macros
+
+proc transform(n, track, list: NimNode): NimNode {.compileTime.} =
+  ...
+
+macro cov(body: untyped): untyped =
+  var list = newNimNode(nnkBracket)
+  let track = genSym(nskVar, "track")
+  result = transform(body, track, list)
+  result = newStmtList(newVarStmt(track, list), result,
+                   newCall(bindSym"listCoverage", track))
+  echo result.toStrLit
+
+
+cov:
+  proc toTest(x, y: int) =
+    ...
+  
+  toTest(8, 10)
+  toTest(10, 10)
+
+
+

Macros

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
proc transform(n, track, list: NimNode): NimNode {.compileTime.} =
+  # recurse:
+  result = copyNimNode(n)
+  for c in n.children:
+    result.add c.transform(track, list)
+  
+  if n.kind in {nnkElifBranch, nnkOfBranch, nnkExceptBranch, nnkElse}:
+    let lineinfo = result[^1].lineinfo
+    
+    template trackStmt(track, i) =
+      track[i][1] = true
+    result[^1] = newStmtList(getAst trackStmt(track, list.len), result[^1])
+    
+    template tup(lineinfo) =
+      (lineinfo, false)
+    list.add(getAst tup(lineinfo))
+
+
+

Macros

Result:

8.1
+no exception
+else
+no exception
+NOT COVERED coverage.nim(42,14)
+NOT COVERED coverage.nim(43,12)
+NOT COVERED coverage.nim(47,6)
+

+ +
+
+

Macros

1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+
proc toTest(x, y: int) =
+  try:
+    case x
+    of 8:
+      if y > 9: echo "8.1"
+      else: echo "8.2"
+    of 9: echo "9"
+    else: echo "else"
+    echo "no exception"
+  except IoError:
+    echo "IoError"
+
+toTest(8, 10)
+toTest(10, 10)
+ + + +
+ diff --git a/2_meta.rst b/2_meta.rst new file mode 100644 index 0000000..c3489eb --- /dev/null +++ b/2_meta.rst @@ -0,0 +1,378 @@ +================================================================= + Meta programming +================================================================= + + +Templates +========= + +* templates are declarative, macros imperative + +.. code-block:: nim + # from System.nim + template `!=` (a, b: untyped): untyped = + not (a == b) + + assert(5 != 6) # rewritten to: assert(not (5 == 6)) + +* more transformations + - ``a > b`` is rewritten to ``b < a``. + - ``a in b`` is rewritten to ``contains(b, a)``. + - ``a notin b`` is rewritten to ``not (a in b)``. + - ``a isnot b`` is rewritten to ``not (a is b)``. + + +Templates +========= + +.. code-block:: nim + :number-lines: + + template html(name, body) = + proc name(): string = + result = "" + body + result.add("") + + html mainPage: + echo "colon syntax to pass statements to template" + + + +Templates +========= + +Templates already suffice to implement simple DSLs: + +.. code-block:: nim + :number-lines: + + html mainPage: + head: + title "The Nim programming language" + body: + ul: + li "efficient" + li "expressive" + li "elegant" + + echo mainPage() + + +Produces:: + + + The Nim programming language + + + + + + +Templates +========= + +.. code-block:: nim + template html(name, body) = + proc name(): string = + result = "" + body + result.add("") + + template head(body) = + result.add("") + body + result.add("") + + ... + + template title(x) = + result.add("$1" % x) + + template li(x) = + result.add("
  • $1
  • " % x) + + +Templates +========= + +.. code-block:: nim + :number-lines: + + proc mainPage(): string = + result = "" + result.add("") + result.add("$1" % "The Nim programming language") + result.add("") + result.add("") + result.add("") + result.add("") + result.add("") + + +Macros +====== + +* imperative AST to AST transformations +* Turing complete +* ``macros`` module provides an API for dealing with Nim ASTs + + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: echo "8.2" + of 9: echo "9" + else: echo "else" + echo "no exception" + except IoError: + echo "IoError" + + toTest(8, 10) + toTest(10, 10) + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: ***echo "8.2"*** + of 9: ***echo "9"*** + else: echo "else" + echo "no exception" + except IoError: + ***echo "IoError"*** + + toTest(8, 10) + toTest(10, 10) + + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + # This is the code our macro will produce! + + var + track = [("line 9", false), ("line 13", false), ...] + + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: + track[0][1] = true + echo "8.1" + else: + track[1][1] = true + echo "8.2" + of 9: + track[2][1] = true + echo "9" + else: + track[3][1] = true + echo "foo" + echo "no exception" + except IoError: + track[4][1] = true + echo "IoError" + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + + toTest(8, 10) + toTest(1, 2) + + proc listCoverage(s: openArray[(string, bool)]) = + for x in s: + if not x[1]: echo "NOT COVERED ", x[0] + + listCoverage(track) + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + + import macros + + macro cov(n: untyped): untyped = + result = n + echo treeRepr n + + cov: + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: echo "8.2" + of 9: echo "9" + else: echo "foo" + echo "no exception" + except IoError: + echo "IoError" + + toTest(8, 10) + toTest(10, 10) + + +Code coverage +============= + +:: + ... + TryStmt + StmtList + CaseStmt + Ident !"x" + OfBranch + IntLit 8 + StmtList + IfStmt + ElifBranch + Infix + Ident !">" + Ident !"y" + IntLit 9 + StmtList [...] + Else + StmtList [...] + OfBranch + IntLit 9 + StmtList + Command + Ident !"echo" + StrLit 9 + Else + StmtList + Command + Ident !"echo" + StrLit foo + Command [...] + ExceptBranch + [...] + + + +Code coverage +============= + +.. code-block:: nim + :number-lines: + + ## Code coverage macro + + import macros + + proc transform(n, track, list: NimNode): NimNode {.compileTime.} = + ... + + macro cov(body: untyped): untyped = + var list = newNimNode(nnkBracket) + let track = genSym(nskVar, "track") + result = transform(body, track, list) + result = newStmtList(newVarStmt(track, list), result, + newCall(bindSym"listCoverage", track)) + echo result.toStrLit + + + cov: + proc toTest(x, y: int) = + ... + + toTest(8, 10) + toTest(10, 10) + + +Macros +====== + +.. code-block:: nim + :number-lines: + + proc transform(n, track, list: NimNode): NimNode {.compileTime.} = + # recurse: + result = copyNimNode(n) + for c in n.children: + result.add c.transform(track, list) + + if n.kind in {nnkElifBranch, nnkOfBranch, nnkExceptBranch, nnkElse}: + let lineinfo = result[^1].lineinfo + + template trackStmt(track, i) = + track[i][1] = true + result[^1] = newStmtList(getAst trackStmt(track, list.len), result[^1]) + + template tup(lineinfo) = + (lineinfo, false) + list.add(getAst tup(lineinfo)) + + +Macros +====== + +Result:: + 8.1 + no exception + else + no exception + NOT COVERED coverage.nim(42,14) + NOT COVERED coverage.nim(43,12) + NOT COVERED coverage.nim(47,6) + + +Macros +====== + +.. code-block:: nim + :number-lines: + + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: ***echo "8.2"*** + of 9: ***echo "9"*** + else: echo "else" + echo "no exception" + except IoError: + ***echo "IoError"*** + + toTest(8, 10) + toTest(10, 10) + + diff --git a/3_effects.html b/3_effects.html new file mode 100644 index 0000000..c3bebe2 --- /dev/null +++ b/3_effects.html @@ -0,0 +1,747 @@ + + + + Effect system + + + + + + + + + +
    + Nimrod logo +
    + +
    +

    Effect system

    + +
    +
    +

    NoSideEffect

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +
    cov:
    +  proc toTest(x, y: int): int {.noSideEffect.} =
    +    case x
    +    of 8:
    +      if y > 9: 8+1
    +      else: 8+2
    +    of 9: 9
    +    else: 100
    +
    +# Error: 'toTest' can have side-effects
    +
    +
    +

    NoSideEffect

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +
    var
    +  track = [("line 9", false), ("line 13", false), ...]
    +
    +proc toTest(x, y: int): int {.noSideEffect.} =
    +  case x
    +  of 8:
    +    if y > 9:
    +      track[0][1] = true
    +  ...
    +
    +
    +

    NoSideEffect

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +
    var
    +  track = [("line 9", false), ("line 13", false), ...]
    +
    +proc setter(x: int) =
    +  track[x][1] = true
    +
    +type HideEffects = proc (x: int) {.noSideEffect, raises: [], tags: [].}
    +
    +proc toTest(x, y: int): int =
    +  case x
    +  of 8:
    +    if y > 9:
    +      cast[HideEffects](setter)(0)
    +  ...
    +
    +
    +

    Effect System

    + +
    +
    +

    Exceptions

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    +
    import strutils
    +
    +proc readFromFile() {.raises: [].} =
    +  # read the first two lines of a text file that should contain numbers
    +  # and tries to add them
    +  var
    +    f: File
    +  if open(f, "numbers.txt"):
    +    try:
    +      var a = readLine(f)
    +      var b = readLine(f)
    +      echo("sum: " & $(parseInt(a) + parseInt(b)))
    +    except OverflowError:
    +      echo("overflow!")
    +    except ValueError:
    +      echo("could not convert string to integer")
    +    except IOError:
    +      echo("IO error!")
    +    except:
    +      echo("Unknown exception!")
    +    finally:
    +      close(f)
    +
    +
    +

    Tags

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +
    type
    +  TagA = object of RootEffect
    +  TagB = object of RootEffect
    +
    +proc a() {.tags: [TagA].} = discard
    +proc b() {.tags: [TagB].} = discard
    +
    +proc x(input: int) {.tags: [ ? ].} =
    +  if input < 0: a()
    +  else: b()
    +
    +
    +

    Tags

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +
    type
    +  TagA = object of RootEffect
    +  TagB = object of RootEffect
    +
    +proc a() {.tags: [TagA].} = discard
    +proc b() {.tags: [TagB].} = discard
    +
    +proc x(input: int) {.tags: [TagA, TagB].} =
    +  if input < 0: a()
    +  else: b()
    +
    +
    +

    Tags

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +
    proc execProcesses(commands: openArray[string],
    +                   beforeRunEvent: proc (command: string) = nil): int
    +  {.tags: [ExecIOEffect].}
    +  ## executes the commands in parallel. The highest return value of
    +  ## all processes is returned. Runs `beforeRunEvent` before running each
    +  ## command.
    +
    +proc echoCommand(command: string) {.tags: [WriteIOEffect].} =
    +  echo command
    +
    +proc compose*() =
    +  execProcesses(["gcc -o foo foo.c",
    +                 "gcc -o bar bar.c",
    +                 "gcc -o baz baz.c"],
    +                 echoCommand)
    +
    +
    +

    GC safety

    + +
    +
    +

    GC safety

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +
    import tables, strutils, threadpool
    +
    +const
    +  files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"]
    +
    +var tab = newCountTable[string]()
    +
    +proc countWords(filename: string) =
    +  ## Counts all the words in the file.
    +  for word in readFile(filename).split:
    +    tab.inc word
    +
    +for f in files:
    +  spawn countWords(f)
    +sync()
    +tab.sort()
    +echo tab.largest
    +
    +
    +

    GC safety

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +
    import threadpool, tables, strutils
    +
    +{.pragma isolated, threadvar.}
    +
    +var tab {.isolated.}: CountTable[string]
    +
    +proc rawPut(key: string) =
    +  inc(tab, key)
    +
    +proc put(key: string) =
    +  pinnedSpawn 0, rawPut(key)
    +
    +proc rawGet(): string =
    +  tab.sort()
    +  result = tab.largest()[0]
    +
    +proc getMax(): string =
    +  let flow = pinnedSpawn(0, rawGet())
    +  result = ^flow
    +
    +proc main =
    +  pinnedSpawn 0, (proc () = tab = initCountTable[string]())
    +  for x in split(readFile("readme.txt")):
    +    put x
    +  echo getMax()
    +
    +main()
    +
    +
    +

    Guards and locks

    + +
    +
    +

    Data race

    A data race occurs when:

    + + +
    +
    +

    Guards fight data races

    +
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +
    var glock: Lock
    +var gdata {.guard: glock.}: int
    +
    +proc invalid =
    +  # invalid: unguarded access:
    +  echo gdata
    +
    +proc valid =
    +  # valid access:
    +  {.locks: [glock].}:
    +    echo gdata
    +
    +
    +

    Guards fight data races

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +
    template lock(a: Lock; body: untyped) =
    +  pthread_mutex_lock(a)
    +  {.locks: [a].}:
    +    try:
    +      body
    +    finally:
    +      pthread_mutex_unlock(a)
    +
    +
    +

    Guards fight data races

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +
    var dummyLock {.compileTime.}: int
    +var atomicCounter {.guard: dummyLock.}: int
    +
    +template atomicRead(x): expr =
    +  {.locks: [dummyLock].}:
    +    memoryReadBarrier()
    +    x
    +
    +echo atomicRead(atomicCounter)
    +
    +
    +

    Deadlocks

    A deadlock occurs when:

    + +

    Solution?

    + +
    +
    +

    Deadlocks

    A deadlock occurs when:

    + +

    Solution?

    + + +
    +
    +

    Locking levels fight deadlocks

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +
    var a, b: Lock[2]
    +var x: Lock[1]
    +# invalid locking order: Lock[1] cannot be acquired before Lock[2]:
    +{.locks: [x].}:
    +  {.locks: [a].}:
    +    ...
    +# valid locking order: Lock[2] acquired before Lock[1]:
    +{.locks: [a].}:
    +  {.locks: [x].}:
    +    ...
    +
    +# invalid locking order: Lock[2] acquired before Lock[2]:
    +{.locks: [a].}:
    +  {.locks: [b].}:
    +    ...
    +
    +# valid locking order, locks of the same level acquired at the same time:
    +{.locks: [a, b].}:
    +  ...
    +
    +
    +

    Locking levels fight deadlocks

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +13
    +
    template multilock(a, b: ptr Lock; body: stmt) =
    +  if cast[ByteAddress](a) < cast[ByteAddress](b):
    +    pthread_mutex_lock(a)
    +    pthread_mutex_lock(b)
    +  else:
    +    pthread_mutex_lock(b)
    +    pthread_mutex_lock(a)
    +  {.locks: [a, b].}:
    +    try:
    +      body
    +    finally:
    +      pthread_mutex_unlock(a)
    +      pthread_mutex_unlock(b)
    +
    +
    +

    Locking levels fight deadlocks

    1
    +2
    +3
    +4
    +5
    +6
    +
    proc p() {.locks: 3.} = discard
    +
    +var a: Lock[4]
    +{.locks: [a].}:
    +  # p's locklevel (3) is strictly less than a's (4) so the call is allowed:
    +  p()
    + + + +
    + diff --git a/3_effects.rst b/3_effects.rst new file mode 100644 index 0000000..6d9bd7c --- /dev/null +++ b/3_effects.rst @@ -0,0 +1,415 @@ +============= +Effect system +============= + + +NoSideEffect +============ + +.. code-block:: nim + :number-lines: + + cov: + proc toTest(x, y: int): int {.noSideEffect.} = + case x + of 8: + if y > 9: 8+1 + else: 8+2 + of 9: 9 + else: 100 + + # Error: 'toTest' can have side-effects + + + +NoSideEffect +============ + +.. code-block:: nim + :number-lines: + + var + track = [("line 9", false), ("line 13", false), ...] + + proc toTest(x, y: int): int {.noSideEffect.} = + case x + of 8: + if y > 9: + track[0][1] = true + ... + + + +NoSideEffect +============ + +.. code-block:: nim + :number-lines: + + var + track = [("line 9", false), ("line 13", false), ...] + + proc setter(x: int) = + track[x][1] = true + + type HideEffects = proc (x: int) {.noSideEffect, raises: [], tags: [].} + + proc toTest(x, y: int): int = + case x + of 8: + if y > 9: + cast[HideEffects](setter)(0) + ... + + +Effect System +============= + +- tracks side effects +- tracks exceptions +- tracks "tags": ReadIOEffect, WriteIoEffect, TimeEffect, + ReadDirEffect, **ExecIOEffect** +- tracks locking levels; deadlock prevention at compile-time + +.. + Think of ``(T, E)`` as opposed to ``E[T]``. + + +Exceptions +========== + +.. code-block:: nim + :number-lines: + + import strutils + + proc readFromFile() {.raises: [].} = + # read the first two lines of a text file that should contain numbers + # and tries to add them + var + f: File + if open(f, "numbers.txt"): + try: + var a = readLine(f) + var b = readLine(f) + echo("sum: " & $(parseInt(a) + parseInt(b))) + except OverflowError: + echo("overflow!") + except ValueError: + echo("could not convert string to integer") + except IOError: + echo("IO error!") + except: + echo("Unknown exception!") + finally: + close(f) + +.. + - describe inference algorithm + + proc noRaise(x: proc()) {.raises: [].} = + # unknown call that might raise anything, but valid: + x() + + proc doRaise() {.raises: [IOError].} = + raise newException(IOError, "IO") + + proc use() {.raises: [].} = + # doesn't compile! Can raise IOError! + noRaise(doRaise) + + +Tags +==== + +.. code-block:: nim + :number-lines: + type + TagA = object of RootEffect + TagB = object of RootEffect + + proc a() {.tags: [TagA].} = discard + proc b() {.tags: [TagB].} = discard + + proc x(input: int) {.tags: [ ? ].} = + if input < 0: a() + else: b() + +.. + Just demonstrate 'doc2' here + + +Tags +==== + +.. code-block:: nim + :number-lines: + type + TagA = object of RootEffect + TagB = object of RootEffect + + proc a() {.tags: [TagA].} = discard + proc b() {.tags: [TagB].} = discard + + proc x(input: int) {.tags: [TagA, TagB].} = + if input < 0: a() + else: b() + + +Tags +==== + +.. code-block:: nim + :number-lines: + + proc execProcesses(commands: openArray[string], + beforeRunEvent: proc (command: string) = nil): int + {.tags: [ExecIOEffect].} + ## executes the commands in parallel. The highest return value of + ## all processes is returned. Runs `beforeRunEvent` before running each + ## command. + + proc echoCommand(command: string) {.tags: [WriteIOEffect].} = + echo command + + proc compose*() = + execProcesses(["gcc -o foo foo.c", + "gcc -o bar bar.c", + "gcc -o baz baz.c"], + echoCommand) + + + +GC safety +========= + +- a ``spawn``'ed proc must be ``gcsafe`` +- ``gcsafe``: Does not access global variables containing GC'ed memory +- ``noSideEffect``: Does not access global variables +- ``noSideEffect`` implies ``gcsafe`` + + +GC safety +========= + +.. code-block:: nim + :number-lines: + + import tables, strutils, threadpool + + const + files = ["data1.txt", "data2.txt", "data3.txt", "data4.txt"] + + var tab = newCountTable[string]() + + proc countWords(filename: string) = + ## Counts all the words in the file. + for word in readFile(filename).split: + tab.inc word + + for f in files: + spawn countWords(f) + sync() + tab.sort() + echo tab.largest + + +GC safety +========= + +.. code-block:: nim + :number-lines: + + import threadpool, tables, strutils + + {.pragma isolated, threadvar.} + + var tab {.isolated.}: CountTable[string] + + proc rawPut(key: string) = + inc(tab, key) + + proc put(key: string) = + pinnedSpawn 0, rawPut(key) + + proc rawGet(): string = + tab.sort() + result = tab.largest()[0] + + proc getMax(): string = + let flow = pinnedSpawn(0, rawGet()) + result = ^flow + + proc main = + pinnedSpawn 0, (proc () = tab = initCountTable[string]()) + for x in split(readFile("readme.txt")): + put x + echo getMax() + + main() + + + +Guards and locks +================ + +- common low level concurrency mechanisms like locks, atomic instructions or + condition variables are available +- guards fight data races +- locking levels fight deadlocks + + +Data race +========= + +A data race occurs when: + +- two or more threads access the same memory location concurrently +- at least one of the accesses is for writing +- the threads are not using any exclusive locks to control their accesses + + +Guards fight data races +======================= + +- Object fields and global variables can be annotated via a ``guard`` pragma +- Access then has to be within a ``locks`` section: + +.. code-block:: nim + :number-lines: + + var glock: Lock + var gdata {.guard: glock.}: int + + proc invalid = + # invalid: unguarded access: + echo gdata + + proc valid = + # valid access: + {.locks: [glock].}: + echo gdata + + +Guards fight data races +======================= + +.. code-block:: nim + :number-lines: + + template lock(a: Lock; body: untyped) = + pthread_mutex_lock(a) + {.locks: [a].}: + try: + body + finally: + pthread_mutex_unlock(a) + + +Guards fight data races +======================= + +.. code-block:: nim + :number-lines: + + var dummyLock {.compileTime.}: int + var atomicCounter {.guard: dummyLock.}: int + + template atomicRead(x): expr = + {.locks: [dummyLock].}: + memoryReadBarrier() + x + + echo atomicRead(atomicCounter) + + +Deadlocks +========= + +A deadlock occurs when: + +- thread A acquires lock L1 +- thread B acquires lock L2 +- thread A tries to acquire lock L2 +- thread B tries to acquire lock L1 + +Solution? + + +Deadlocks +========= + +A deadlock occurs when: + +- thread A acquires lock L1 +- thread B acquires lock L2 +- thread A tries to acquire lock L2 +- thread B tries to acquire lock L1 + +Solution? + +- enforce L1 is always acquired before L2 + + + +Locking levels fight deadlocks +============================== + +.. code-block:: nim + :number-lines: + + var a, b: Lock[2] + var x: Lock[1] + # invalid locking order: Lock[1] cannot be acquired before Lock[2]: + {.locks: [x].}: + {.locks: [a].}: + ... + # valid locking order: Lock[2] acquired before Lock[1]: + {.locks: [a].}: + {.locks: [x].}: + ... + + # invalid locking order: Lock[2] acquired before Lock[2]: + {.locks: [a].}: + {.locks: [b].}: + ... + + # valid locking order, locks of the same level acquired at the same time: + {.locks: [a, b].}: + ... + + + +Locking levels fight deadlocks +============================== + +.. code-block:: nim + :number-lines: + + template multilock(a, b: ptr Lock; body: stmt) = + if cast[ByteAddress](a) < cast[ByteAddress](b): + pthread_mutex_lock(a) + pthread_mutex_lock(b) + else: + pthread_mutex_lock(b) + pthread_mutex_lock(a) + {.locks: [a, b].}: + try: + body + finally: + pthread_mutex_unlock(a) + pthread_mutex_unlock(b) + + +Locking levels fight deadlocks +============================== + +.. code-block:: nim + :number-lines: + + proc p() {.locks: 3.} = discard + + var a: Lock[4] + {.locks: [a].}: + # p's locklevel (3) is strictly less than a's (4) so the call is allowed: + p() diff --git a/4_cppinterop.html b/4_cppinterop.html new file mode 100644 index 0000000..92d671c --- /dev/null +++ b/4_cppinterop.html @@ -0,0 +1,576 @@ + + + + Interfacing with C/C++ + + + + + + + + + +
    + Nimrod logo +
    + +
    +

    Interfacing with C/C++

    + +
    +
    +

    Interfacing with C

    2 options

    + + +
    +
    +

    Dynlib import

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +
    type
    +  GtkWidget = object
    +    data: cint
    +    binary: cfloat
    +    compatible: char
    +
    +proc gtk_image_new(): ptr GtkWidget
    +  {.cdecl, dynlib: "libgtk-x11-2.0.so", importc.}
    +
    +
    +

    Header import

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +
    type
    +  GtkWidget {.importc: "GtkWidget_t", header: "<gtk.h>".} = object
    +    data {.importc: "Data".}: cint
    +    binary {.importc: "Binary".}: cfloat
    +    compatible: char
    +
    +proc gtk_image_new(): ptr GtkWidget
    +  {.cdecl, header: "<gtk.h>", importc.}
    +
    +{.passC: staticExec("pkg-config --cflags gtk").}
    +{.passL: staticExec("pkg-config --libs gtk").}
    +
    +
    +

    Header import

    1
    +2
    +3
    +4
    +
    proc printf(formatstr: cstring)
    +  {.header: "<stdio.h>", importc: "printf", varargs.}
    +
    +printf("%s%s", "Nim strings ", "converted to cstring for you")
    +
    +
    +

    Data exchange with C

    + + + + + + + +
    C typeNim type
    intcint
    unsigned longculong
    floatcfloat
    int x[4]array[4, cint]
    int*ptr int
    char*cstring
    char**cstringArray = ptr array [0..ArrayDummySize, cstring]
    +
    +
    +

    Data exchange with C

    1
    +2
    +3
    +4
    +5
    +6
    +
    int sum(int* x, size_t len) {
    +  int result = 0;
    +  for (size_t i = 0; i < len; i++)
    +    result += x[i];
    +  return result;
    +}
    +
    +
    +

    Data exchange with C

    1
    +2
    +3
    +4
    +5
    +6
    +
    int sum(int* x, size_t len) {
    +  int result = 0;
    +  for (size_t i = 0; i < len; i++)
    +    result += x[i];
    +  return result;
    +}
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +
    proc sum(x: ptr cint; len: int): cint
    +  {.importc: "sum", cdecl, header: "foo.h".}
    +
    +proc callSum =
    +  var x = @[1.cint, 2, 3, 4]
    +  echo sum(addr x[0], x.len)
    +  
    +  var y = [1.cint, 2, 3, 4]
    +  echo sum(addr y[0], y.len)
    +
    +
    +

    CodegenDecl pragma

    1
    +2
    +3
    +4
    +5
    +
    var
    +  a {.codegenDecl: "$# progmem $#".}: int
    +
    +proc myinterrupt() {.codegenDecl: "__interrupt $# $#$#".} =
    +  echo "realistic interrupt handler"
    +
    +
    +

    Wrapping C++

    1
    +2
    +3
    +4
    +5
    +6
    +
    class Foo {
    +public:
    +  int value;
    +  int GetValue() { return value; }
    +  int& SetValue(int x) { field = x; return &field; }
    +};
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +
    type
    +  Foo* {.importcpp: "Foo", header: "file.h".} = object
    +    value*: cint
    +
    +proc getValue*(this: var Foo): cint
    +  {.importcpp: "GetValue", header: "file.h".}
    +proc setValue*(this: var Foo; x: cint): var cint
    +  {.importcpp: "SetValue", header: "file.h".}
    +
    +
    +

    Wrapping C++

    1
    +2
    +3
    +4
    +5
    +6
    +
    class Foo {
    +public:
    +  int value;
    +  int GetValue() { return value; }
    +  int& SetValue(int x) { field = x; return &field; }
    +};
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +
    type
    +  Foo* {.importcpp: "Foo", header: "file.h".} = object
    +    value*: cint
    +
    +proc getValue*(this: var Foo): cint
    +  {.importcpp: "#.GetValue(@)", header: "file.h".}
    +proc setValue*(this: var Foo; x: cint): var cint
    +  {.importcpp: "#.SetValue(@)", header: "file.h".}
    +
    +
    +

    Constructors

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +
    class Foo {
    +public:
    +  int value;
    +  int GetValue() { return value; }
    +  int& SetValue(int x) { field = x; return &field; }
    +  
    +  Foo(int x): field(x) {}
    +};
    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +
    type
    +  Foo* {.importcpp: "Foo", header: "file.h".} = object
    +    value*: cint
    +
    +proc getValue*(this: var Foo): cint
    +  {.importcpp: "#.GetValue(@)", header: "file.h".}
    +proc setValue*(this: var Foo; x: cint): var cint
    +  {.importcpp: "#.SetValue(@)", header: "file.h".}
    +
    +proc constructFoo*(x: cint): Foo
    +  {.importcpp: "Foo(@)", header: "file.h".}
    +
    +
    +

    Constructors

    1
    +2
    +3
    +
    Foo foo = Foo(1, 2, 3);
    +
    +auto foo = Foo(1, 2, 3);
    +
    +
    +

    Constructors

    1
    +2
    +3
    +
    Foo foo = Foo(1, 2, 3);
    +// Calls copy constructor!
    +auto foo = Foo(1, 2, 3);
    +
    +
    +

    Constructors

    1
    +2
    +3
    +4
    +5
    +
    Foo foo = Foo(1, 2, 3);
    +// Calls copy constructor!
    +auto foo = Foo(1, 2, 3);
    +
    +Foo foo(1, 2, 3);
    +
    +
    +

    Constructors

    1
    +2
    +
    proc constructFoo*(x: cint): Foo
    +  {.importcpp: "Foo(@)", header: "file.h", constructor.}
    1
    +2
    +3
    +4
    +5
    +6
    +
    proc newFoo(a, b: cint): ptr Foo {.importcpp: "new Foo(@)".}
    +
    +let x = newFoo(3, 4)
    +
    +
    +proc cnew*[T](x: T): ptr T {.importcpp: "(new '*0#@)", nodecl.}
    +
    +
    +

    Generics

    For example:

    +
    1
    +2
    +3
    +4
    +5
    +
    type Input {.importcpp: "System::Input".} = object
    +proc getSubsystem*[T](): ptr T
    +  {.importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}
    +
    +let x: ptr Input = getSubsystem[Input]()

    Produces:

    +
    1
    +
    x = SystemManager::getSubsystem<System::Input>()
    +
    +
    +

    Emit pragma

    1
    +2
    +3
    +4
    +5
    +6
    +7
    +8
    +9
    +10
    +11
    +12
    +
    {.emit: """
    +static int cvariable = 420;
    +""".}
    +
    +{.push stackTrace:off.}
    +proc embedsC() =
    +  var nimVar = 89
    +  # use backticks to access Nim symbols within an emit section:
    +  {.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimVar`);""".}
    +{.pop.}
    +
    +embedsC()
    +
    +
    +

    Questions?

    + + + +
    + diff --git a/4_cppinterop.rst b/4_cppinterop.rst new file mode 100644 index 0000000..4451ddc --- /dev/null +++ b/4_cppinterop.rst @@ -0,0 +1,340 @@ +====================== +Interfacing with C/C++ +====================== + + +Interfacing with C +================== + +2 options + +- via ``dynlib`` +- via ``header`` + + +Dynlib import +============= + +.. code-block:: Nim + :number-lines: + type + GtkWidget = object + data: cint + binary: cfloat + compatible: char + + proc gtk_image_new(): ptr GtkWidget + {.cdecl, dynlib: "libgtk-x11-2.0.so", importc.} + + + +Header import +============= + +.. code-block:: + :number-lines: + + type + GtkWidget {.importc: "GtkWidget_t", header: "".} = object + data {.importc: "Data".}: cint + binary {.importc: "Binary".}: cfloat + compatible: char + + proc gtk_image_new(): ptr GtkWidget + {.cdecl, header: "", importc.} + + {.passC: staticExec("pkg-config --cflags gtk").} + {.passL: staticExec("pkg-config --libs gtk").} + + + +Header import +============= + +.. code-block:: + :number-lines: + + proc printf(formatstr: cstring) + {.header: "", importc: "printf", varargs.} + + printf("%s%s", "Nim strings ", "converted to cstring for you") + + +Data exchange with C +==================== + +================= ========================================================== +C type Nim type +================= ========================================================== +``int`` ``cint`` +``unsigned long`` ``culong`` +``float`` ``cfloat`` +``int x[4]`` ``array[4, cint]`` +``int*`` ``ptr int`` +``char*`` ``cstring`` +``char**`` ``cstringArray = ptr array [0..ArrayDummySize, cstring]`` +================= ========================================================== + + +Data exchange with C +==================== + +.. code-block:: C + :number-lines: + + int sum(int* x, size_t len) { + int result = 0; + for (size_t i = 0; i < len; i++) + result += x[i]; + return result; + } + + +Data exchange with C +==================== + +.. code-block:: C + :number-lines: + + int sum(int* x, size_t len) { + int result = 0; + for (size_t i = 0; i < len; i++) + result += x[i]; + return result; + } + +.. code-block:: Nim + :number-lines: + + proc sum(x: ptr cint; len: int): cint + {.importc: "sum", cdecl, header: "foo.h".} + + proc callSum = + var x = @[1.cint, 2, 3, 4] + echo sum(addr x[0], x.len) + + var y = [1.cint, 2, 3, 4] + echo sum(addr y[0], y.len) + + + +CodegenDecl pragma +================== + + +.. code-block:: nim + :number-lines: + + var + a {.codegenDecl: "$# progmem $#".}: int + + proc myinterrupt() {.codegenDecl: "__interrupt $# $#$#".} = + echo "realistic interrupt handler" + + + + + +Wrapping C++ +============ + +.. code-block:: C++ + :number-lines: + + class Foo { + public: + int value; + int GetValue() { return value; } + int& SetValue(int x) { field = x; return &field; } + }; + +.. code-block:: Nim + :number-lines: + + type + Foo* {.importcpp: "Foo", header: "file.h".} = object + value*: cint + + proc getValue*(this: var Foo): cint + {.importcpp: "GetValue", header: "file.h".} + proc setValue*(this: var Foo; x: cint): var cint + {.importcpp: "SetValue", header: "file.h".} + + +Wrapping C++ +============ + +.. code-block:: C++ + :number-lines: + + class Foo { + public: + int value; + int GetValue() { return value; } + int& SetValue(int x) { field = x; return &field; } + }; + +.. code-block:: Nim + :number-lines: + + type + Foo* {.importcpp: "Foo", header: "file.h".} = object + value*: cint + + proc getValue*(this: var Foo): cint + {.importcpp: "#.GetValue(@)", header: "file.h".} + proc setValue*(this: var Foo; x: cint): var cint + {.importcpp: "#.SetValue(@)", header: "file.h".} + + + +Constructors +============ + +.. code-block:: C++ + :number-lines: + + class Foo { + public: + int value; + int GetValue() { return value; } + int& SetValue(int x) { field = x; return &field; } + + Foo(int x): field(x) {} + }; + +.. code-block:: Nim + :number-lines: + + type + Foo* {.importcpp: "Foo", header: "file.h".} = object + value*: cint + + proc getValue*(this: var Foo): cint + {.importcpp: "#.GetValue(@)", header: "file.h".} + proc setValue*(this: var Foo; x: cint): var cint + {.importcpp: "#.SetValue(@)", header: "file.h".} + + proc constructFoo*(x: cint): Foo + {.importcpp: "Foo(@)", header: "file.h".} + + +Constructors +============ + +.. code-block:: C++ + :number-lines: + + Foo foo = Foo(1, 2, 3); + + auto foo = Foo(1, 2, 3); + + +Constructors +============ + +.. code-block:: C++ + :number-lines: + + Foo foo = Foo(1, 2, 3); + // Calls copy constructor! + auto foo = Foo(1, 2, 3); + + +Constructors +============ + +.. code-block:: C++ + :number-lines: + + Foo foo = Foo(1, 2, 3); + // Calls copy constructor! + auto foo = Foo(1, 2, 3); + + Foo foo(1, 2, 3); + + +Constructors +============ + +.. code-block:: Nim + :number-lines: + + proc constructFoo*(x: cint): Foo + {.importcpp: "Foo(@)", header: "file.h", constructor.} + + +.. code-block:: nim + :number-lines: + + proc newFoo(a, b: cint): ptr Foo {.importcpp: "new Foo(@)".} + + let x = newFoo(3, 4) + + + proc cnew*[T](x: T): ptr T {.importcpp: "(new '*0#@)", nodecl.} + + + +Generics +======== + +For example: + +.. code-block:: nim + :number-lines: + + type Input {.importcpp: "System::Input".} = object + proc getSubsystem*[T](): ptr T + {.importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.} + + let x: ptr Input = getSubsystem[Input]() + +Produces: + +.. code-block:: C + :number-lines: + + x = SystemManager::getSubsystem() + + + +Emit pragma +=========== + +.. code-block:: Nim + :number-lines: + + {.emit: """ + static int cvariable = 420; + """.} + + {.push stackTrace:off.} + proc embedsC() = + var nimVar = 89 + # use backticks to access Nim symbols within an emit section: + {.emit: """fprintf(stdout, "%d\n", cvariable + (int)`nimVar`);""".} + {.pop.} + + embedsC() + + +.. + A tour through the standard library + ----------------------------------- + + - system module: basic arithmetic and IO + - strutils module; Unicode module + - OS and osproc modules + - sequtils and algorithm + - tables and sets + - linked lists, queues + + - watchpoints + - tracing + - lexer generation + - ORM + + +Questions? +========== diff --git a/build.nim b/build.nim new file mode 100644 index 0000000..527ed9c --- /dev/null +++ b/build.nim @@ -0,0 +1,43 @@ + +import strutils, os, re + +proc main(file: string) = + discard execShellCmd("nim rst2html $1.rst" % file) + + const + patternA = "***" & + "(.*)" & + "***" + + proc writeln(buf: var string; x: string) = buf.add x & "\n" + + proc tline(line: string): string = + result = line.replacef(re(patternA.replace("***", r"\*\*\*"), {}), + "$1") + result = result.replacef(re(patternA.replace("***", r"\+\+\+"), {}), + "$1") + result = result.replacef(re(patternA.replace("***", r"\=\=\="), {}), + "$1") + + var f = "" + var count = 0 + for line in lines("$1.html" % file): + if line.contains("") + f.writeln("
    ") + f.writeln(line.tline) + elif line.contains("

    ") + let a = line.replace("

    ", "

    ") + f.writeln(a.tline) + elif line.contains(""): + f.writeln("
    ") + f.writeln(line.tline) + else: + f.writeln(line.tline) + writeFile("$1.html" % file, f) + +for x in os.walkFiles("*.rst"): + main(x.splitFile.name) diff --git a/livedemo/codegendecl.nim b/livedemo/codegendecl.nim new file mode 100644 index 0000000..8d12120 --- /dev/null +++ b/livedemo/codegendecl.nim @@ -0,0 +1,7 @@ + +var + a {.codegenDecl: "$# progmem $#".}: int + +proc myinterrupt() {.codegenDecl: "$# __interrupt $#$# __attribute__(weirdo)", + exportc: "nim_interrupt".} = + echo "realistic interrupt handler" diff --git a/livedemo/coverage.nim b/livedemo/coverage.nim new file mode 100644 index 0000000..4c38c9f --- /dev/null +++ b/livedemo/coverage.nim @@ -0,0 +1,76 @@ + +## Code coverage macro + +import macros + +proc transform(n, guard, list: NimNode): NimNode {.compileTime.} = + # recurse: + result = copyNimNode(n) + for c in n.children: + result.add c.transform(guard, list) + + if n.kind in {nnkElifBranch, nnkOfBranch, nnkExceptBranch, nnkElifExpr, + nnkElseExpr, nnkElse, nnkForStmt, nnkWhileStmt}: + let lineinfo = result[^1].lineinfo + + template track(guard, i) = + guard[i][1] = true + result[^1] = newStmtList(getAst track(guard, list.len), result[^1]) + + template tup(lineinfo) = + (lineinfo, false) + list.add(getAst tup(lineinfo)) + +proc listCoverage(s: openArray[(string, bool)]) = + for x in s: + if not x[1]: echo "NOT EXECUTED ", x[0] + +macro cov(p: untyped): untyped = + var list = newNimNode(nnkBracket) + let guard = genSym(nskVar, "guard") + result = transform(p, guard, list) + result = newStmtList(newVarStmt(guard, list), result, + newCall(bindSym"listCoverage", guard)) + + +cov: + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: echo "8.2" + of 9: echo "9" + else: echo "else" + echo "no IoError" + except IoError: + echo "IoError" + toTest(8, 10) + toTest(10, 10) + + +when false: + cov: + proc toTest(x: int): int = + if x > 0: result = 88 + else: result = 99 + + proc toTestE(x: int): int = + (if x > 0: 88 else: 99) + + proc toTestTry(x: int) = + try: + case x + of 8: echo "8" + of 9: echo "9" + else: echo "foo" + echo "Try it" + except IoError: + echo "IoError" + + echo toTest 89 + echo toTest(-89) + + echo toTestE 89 + toTestTry(8) + # echo toTestE(-89) diff --git a/livedemo/coverage2.nim b/livedemo/coverage2.nim new file mode 100644 index 0000000..b8ef147 --- /dev/null +++ b/livedemo/coverage2.nim @@ -0,0 +1,64 @@ + +import macros + +type HideEffects = proc (x: int) {.raises: [], noSideEffect, tags: [].} + +proc wrap(n: NimNode; setter, i: NimNode): NimNode {.compileTime.} = + # XXX better insert as last statement, but move before 'break', 'return' etc. + template callSetterProc(setter, i) = + cast[HideEffects](setter)(i) + result = newTree(nnkStmtList, getAst callSetterProc(setter, i), n) + +proc transform(n, setter, data: NimNode): NimNode {.compileTime.} = + # recurse: + result = copyNimNode(n) + for c in n.children: + result.add c.transform(setter, data) + if n.kind in {nnkElifBranch, nnkOfBranch, nnkExceptBranch, nnkElifExpr, + nnkElseExpr, nnkElse, nnkForStmt, nnkWhileStmt}: + let index = newLit(data.len) + data.add(newTree(nnkPar, newLit(result[^1].lineinfo), bindSym"false")) + result[^1] = result[^1].wrap(setter, index) + +proc listCoverage(s: openArray[(string, bool)]) = + for x in s: + if not x[1]: echo "NOT EXECUTED ", x[0] + +macro cov(p: untyped): untyped = + var data = newNimNode(nnkBracket) + let guard = genSym(nskVar, "guard") + let setter = genSym(nskProc, "guardSetter") + template setterProc(name, guard) = + proc name(x: int) = + guard[x][1] = true + + result = transform(p, setter, data) + result = newTree(nnkStmtList, newVarStmt(guard, data), + getAst setterProc(setter, guard), + result, + newCall(bindSym"listCoverage", guard)) + +cov: + proc toTest(x: int): int {.noSideEffect.} = + if x > 0: result = 88 + else: result = 99 + + proc toTestE(x: int): int = + (if x > 0: 88 else: 99) + + proc toTestTry(x: int) = + try: + case x + of 8: echo "8" + of 9: echo "9" + else: echo "foo" + echo "Try it" + except IoError: + echo "IoError" + + echo toTest 89 + echo toTest(-89) + + echo toTestE 89 + toTestTry(8) +# echo toTestE(-89) diff --git a/livedemo/demo.html b/livedemo/demo.html new file mode 100644 index 0000000..dd2ff2c --- /dev/null +++ b/livedemo/demo.html @@ -0,0 +1,291 @@ + + + + Module demo + + + + + + + + + +
    + Nimrod logo +
    + +

    Module demo

    +
    + +
    +
    + +
    +

    Procs

    +
    +
    proc compose() {.raises: [], tags: [ExecIOEffect, WriteIOEffect].}
    +
    + +
    +
    proc compose2() {.raises: [], tags: [ExecIOEffect].}
    +
    + +
    + +
    + +
    + + + diff --git a/livedemo/demo.nim b/livedemo/demo.nim new file mode 100644 index 0000000..1253795 --- /dev/null +++ b/livedemo/demo.nim @@ -0,0 +1,22 @@ + +import macros + +macro cov(n: untyped): untyped = + result = n + echo treeRepr n + +cov: + proc toTest(x, y: int) = + try: + case x + of 8: + if y > 9: echo "8.1" + else: echo "8.2" + of 9: echo "9" + else: echo "foo" + echo "no exception" + except IoError: + echo "IoError" + + toTest(8, 10) + toTest(10, 10) diff --git a/livedemo/file.c2nim b/livedemo/file.c2nim new file mode 100644 index 0000000..23d660c --- /dev/null +++ b/livedemo/file.c2nim @@ -0,0 +1,5 @@ + +#cpp +#header + +#nep1 diff --git a/livedemo/file.h b/livedemo/file.h new file mode 100644 index 0000000..43e3b6b --- /dev/null +++ b/livedemo/file.h @@ -0,0 +1,27 @@ + +#def WXDLLIMPEXP_CORE + +#define constantA 1 +#define constantB 2 + + +namespace Name { + + + +template +class WXDLLIMPEXP_CORE Foo { +public: + T value = {. NimConstant + 78 shr 9 .}; + T GetValue() { return value; } + T& SetValue(int x) { field = x; return &field; } + + Foo(T x): field(x) {} + ~Foo() {} + + bool operator==(Foo& const other) const; + bool operator!=(Foo other); +}; + +} + diff --git a/livedemo/file.nim b/livedemo/file.nim new file mode 100644 index 0000000..e01465a --- /dev/null +++ b/livedemo/file.nim @@ -0,0 +1,17 @@ +const + constantA* = 1 + constantB* = 2 + +type + Foo* {.importcpp: "Name::Foo", header: "file.h".}[T] = object + value* {.importc: "value".}: T = NimConstant + 78 shr 9 + + +proc getValue*[T](this: var Foo[T]): T {.importcpp: "GetValue", header: "file.h".} +proc setValue*[T](this: var Foo[T]; x: cint): var T {.importcpp: "SetValue", + header: "file.h".} +proc constructFoo*[T](x: T): Foo[T] {.constructor, importcpp: "Name::Foo(@)", + header: "file.h".} +proc destroyFoo*[T](this: var Foo[T]) {.importcpp: "#.~Foo()", header: "file.h".} +proc `==`*[T](this: Foo[T]; other: Foo[T]): bool {.noSideEffect, importcpp: "(# == #)", + header: "file.h".} \ No newline at end of file diff --git a/livedemo/options.c2nim b/livedemo/options.c2nim new file mode 100644 index 0000000..498dba2 --- /dev/null +++ b/livedemo/options.c2nim @@ -0,0 +1,8 @@ + +#cpp +#header +#nep1 + +#discardableprefix Set + + diff --git a/logo2.png b/logo2.png new file mode 100644 index 0000000..faf2a41 Binary files /dev/null and b/logo2.png differ diff --git a/nimdoc.cfg b/nimdoc.cfg new file mode 100644 index 0000000..fbb9852 --- /dev/null +++ b/nimdoc.cfg @@ -0,0 +1,323 @@ +# This is the config file for the documentation generator. +# (c) 2015 Andreas Rumpf +# Feel free to edit the templates as you need. + +split.item.toc = "20" +# too long entries in the table of contents wrap around +# after this number of characters + + +doc.listing_start = """
    """
    +doc.listing_end = """
    """ +doc.listing_button = """""" + +doc.section = """ +
    +

    $sectionTitle

    +
    +$content +
    +""" + +doc.section.toc = """ +
  • + $sectionTitle +
      + $content +
    +
  • +""" + +doc.item = """ +
    $header
    +
    +$desc +
    +""" + +doc.item.toc = """ +
  • $name
  • +""" + +doc.toc = """ +""" + +doc.body_toc = """ +
    +$tableofcontents +
    +
    +$moduledesc +$content +
    +""" + +doc.body_no_toc = """ +$moduledesc +$content +""" + +doc.file = """ + + + $title + + + + + + + + + +
    + Nimrod logo +
    + +

    $title

    +$content + + +""" diff --git a/slidy2/Overview.html b/slidy2/Overview.html new file mode 100644 index 0000000..a5903ab --- /dev/null +++ b/slidy2/Overview.html @@ -0,0 +1,912 @@ + + + + +HTML Slidy + + + + + + + + + +
    + +
    +slanted W3C logo +
    +
    + + + + + + + + + + + + + +Cover page images (keys)
    +

    HTML Slidy: Slide Shows in HTML and XHTML

    + +

    Dave Raggett, +<dsr@w3.org>
    +
    +
    +
    +
    Hit the space bar or swipe left for next slide

    +
    + +
    +

    Slide Shows in HTML and XHTML

    + +
      +
    • You can now create accessible slide shows with ease
    • + +
    • Works across browsers and is operated like PowerPoint + +
        +
      • Advance to next slide with mouse click, space bar or swipe left
      • + +
      • Move forward/backward between slides with Cursor Left, +Cursor Right, Pg Up and Pg Dn +keys, or swipe left or right
      • + +
      • Home key for first slide, End + key for last slide
      • + +
      • The "C" key for an automatically generated +table of contents, or click on "contents" on the toolbar or +swipe up or down
      • + +
      • Function F11 to go full screen and back
      • + +
      • The "F" key toggles the display of the footer
      • + +
      • The "A" key toggles display of current vs all +slides + +
          +
        • Try it now to see how to include notes for handouts (this is +explained in the notes following this slide)
        • +
        +
      • + +
      • Font sizes automatically adapt to browser window size + +
          +
        • use S and B keys for +manual control (or < and >, or the - and ++ keys on the number pad
        • +
        • Use CSS to set a relative font size on a given slide to make +the content bigger or smaller than on other slides
        • +
        +
      • + +
      • Switching off JavaScript reveals all slides
      • +
      +
    • + +
    • Now move to next slide to see how it works
    • +
    + + +
    + +
    +

    For handouts, its often useful to include extra notes using a +div element with class="handout" following each slide, as in:

    + +
    +<div class="slide"> 
    + ... your slide content ...
    +</div>
    +
    +<div class="handout">
    + ... stuff that only appears in the handouts ...
    +</div>
    +
    +
    + +
    +

    What you need to do

    + + + +
    +<?xml version="1.0" encoding="utf-8"?>
    +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    +<head> 
    +  <title>Slide Shows in XHTML</title> 
    +  <meta name="copyright" 
    +   content="Copyright &#169; 2005 your copyright notice" /> 
    +  <link rel="stylesheet" type="text/css" media="screen, projection, print" 
    +   href="http://www.w3.org/Talks/Tools/Slidy2/styles/slidy.css" /> 
    +  <script src="http://www.w3.org/Talks/Tools/Slidy2/scripts/slidy.js" 
    +   charset="utf-8" type="text/javascript"></script> 
    +  <style type="text/css"> 
    +    <!-- your custom style rules --> 
    +  </style> 
    +</head>
    +<body>
    +   ... your slides marked up in XHTML ...
    +</body>
    +</html>
    +
    +
    + +
    +

    To get the W3C Blue Style

    + +

    The head element should include the following link to the style +sheet:

    + +
    +<link rel="stylesheet" type="text/css" media="screen, projection, print"
    + href="http://www.w3.org/Talks/Tools/Slidy2/styles/w3c-blue.css" /> 
    +
    + +

    The body element's content should start with the following +markup:

    + +
    +<div class="background"> 
    +  <img id="head-icon" alt="graphic with four colored squares"
    +    src="http://www.w3.org/Talks/Tools/Slidy2/graphics/icon-blue.png" /> 
    +  <object id="head-logo" title="W3C logo" type="image/svg+xml"
    +    data="http://www.w3.org/Talks/Tools/Slidy2/graphics/w3c-logo-white.svg"><img
    +   src="http://www.w3.org/Talks/Tools/Slidy2/graphics/w3c-logo-white.gif" 
    +   alt="W3C logo" id="head-logo-fallback" /></object>
    +</div> 
    +
    + +

    This adds the logos on the top left and right corners of the +slide.

    + +

    You are of course welcome to create your own slide designs. +You can provide different styles and backgrounds for +different slides (more details later).

    + +

    Use the meta element with name="copyright" +for use in the slide show footer:

    + +
    +<meta name="copyright" 
    +content="Copyright &#169; 2005-2009 W3C (MIT, ERCIM, Keio)" /> 
    +
    +
    + +
    +

    Upgrading from previous versions of Slidy

    + +
      +
    • This uses a new version of the HTML Slidy script
    • +
    • It is designed to work better with other scripts, +e.g. for UI controls within your slides +
        +
      • Only adds one global name "w3c_slidy"
      • +
      • Doesn't interfere with other scripts that set event handers +such as onload on body element
      • +
      +
    • +
    • Works for slides delivered as text/html and application/xhtml+xml
    • +
    • New presentation timer feature
    • +
    • Initial prompt on first slide to help newcomers to Slidy
    • +
    • Better support for styling slides and printing them
    • +
    • Requires additional style rules, so new script won't work +with old presentations without changes to their style sheets + +
    • +
    • But old presentations will work unchanged as they refer to +the old script!
    • +
    +
    + +
    +

    To use it off-line

    + +
      +
    • You can download slidy.zip and unzip +it to create a Slidy directory on your machine
    • + +
    • If you have cvs access to the W3C site you can check out the Slidy +directory
    • + +
    • Remember to periodically check for updates
    • + +
    • You then have two choices: + +
        +
      1. Use relative URIs depending on your local setup to access the +appropriate files. Use the same directory structure as on the W3C +server, ie, ".../2005/Talks/...".
      2. + +
      3. Run a Web server on your machine so that the directory above +can be accessed via http://localhost/Talks/Tools/Slidy2 +and use the URIs of the form "/Talks/Tools/Slidy2/styles/slidy.css", +"/Talks/Tools/Slidy2/scripts/slidy.js".
      4. +
    • + +
    • In both cases you can then publish your files on the W3C server +unchanged.
    • + +
    • NOTE Internet Explorer on Windows XP now disables +scripting for web pages loaded directly from the local file system, +a work around is to use another browser, e.g. Firefox or Opera
    • + +
    • Please feel free to create your own designs, and help us to build +a gallery of Slidy styles.
    • + +
    • My Google TechTalk (1st Feb 2006) +uses a notebook themed style
    • +
    +
    + +
    +

    Timing Your Presentation

    + +
      +
    • Sometimes it is handy to know just how much time you have to +left to finish your presentation
    • +
    • To get this feature, add the following markup to the +content of the head element, replacing 5 by the duration +of your presentation in minutes +
      <meta name="duration" content="5" />
      +
    • +
    • The time left in minutes and seconds is shown in the footer +next to the slide number
    • +
    • The clock starts to run when you move away from the first slide
    • +
    • Moving back to the first slide pauses the clock
    • +
    + + +
    + +
    +

    Generate a Title Page

    + +

    If you want a separate title page with the W3C blue style, the +first slide should be as follows:

    + +
    +<div class="slide cover"> 
    + <img src="http://www.w3.org/Talks/Tools/Slidy2/graphics/keys.jpg" 
    +  alt="Cover page images (keys)" class="cover" /> 
    + <br clear="all" />            
    + <h1>HTML Slidy: Slide Shows in XHTML</h1> 
    + <p><a href="http://www.w3.org/People/Raggett/">Dave Raggett,</a> 
    + <a href="mailto:dsr@w3.org">dsr@w3.org</a></p> 
    +</div> 
    +
    + +

    The w3c-blue.css +style sheet looks for the classes "slide" and "cover" on div +and img elements using the CSS selector div.slide.cover

    + +

    This technique can be used to assign your slides to different +classes with a different appearence for each such class.

    + +

    Slidy also allows you to use different background markup for +different slides, based upon shared class names, as in "foo" below. +Backgrounds without additional class names are always shown except +when the slide isn't transparent. You may need to tweak your +custom style sheet.

    + +
    +<div class="background foo">
    +   ... background content ...
    +<div>
    +
    +...
    +
    +<div class="slide foo">
    +   ... slide content ...
    +<div>
    +
    +
    + +
    +

    Incremental display of slide contents

    + +

    For incremental display, use class="incremental", for +instance:

    + +
      +
    • First bullet point
    • + +
    • Second bullet point
    • + +
    • Third bullet point
    • +
    + +

    which is marked up as follows:

    + +
    +<ul class="incremental"> 
    +  <li>First bullet point</li> 
    +  <li>Second bullet point</li> 
    +  <li>Third bullet point</li> 
    +</ul> 
    + 
    +<p class="incremental">which is marked up as follows:</p> 
    + 
    +<pre class="incremental"> 
    + ... 
    +</pre> 
    +
    + +
    +

    An element is incrementally revealed if its parent element has +class="incremental" or if itself has that attribute. Text nodes are +not elements and are revealed when their parent element is revealed. +You can use class="incremental" on any element except for <br />. +Use class="non-incremental" to override the effect of setting the +parent element's class to incremental.

    + +

    Note: you will see a red asterisk on the left of the toolbar +when there is still something more to reveal.

    +
    +
    + +
    +

    Create outline lists with hidden content

    + +

    You can make your bullet points or numbered list items +into outlines that you can expand or collapse

    + +
      +
    • Just add class="outline" to the ul or ol +element. Click on this list item for more details. + +
        +
      • The Slidy script will then treat the list +as an outline list.
      • +
      • Clicking on outline list items will expand/collapse +block-level elements within that list item.
      • +
      • Click on the above to make this list item +collapse again.
      • +
      +
    • +
    • Users will then see expand/collapse icons as appropriate +and may click anywhere on the list item to change its state. +This particular list item can't be expanded or collapsed.
    • +
    • Add class="expand" to any li elements that +you want to start in an expanded state. + +
        +
      • By default Slidy hides all the block level elements within the +outline list items unless you have specified class="expand".
      • +
      • Such pre-expanded items can be collapsed by clicking on them.
      • +
      +
    • +
    • Note expand/collapse icon highlighting requires browser +support for :hover which isn't supported by IE6. + +
        +
      • Microsoft says it will be supported by IE7 along with +many fixes for other CSS woes in IE6.
      • +
      +
    • +
    + +
    +<ol class='outline'>
    +  <!-- topic 1 starts collapsed -->
    +  <li>Topic 1
    +    <ol>
    +        <li>subtopic a</li>
    +        <li>subtopic b</li>
    +    </ol>
    +  </li>
    +  <!-- topic 2 starts expanded -->
    +  <li class="expand">Topic 2
    +    <ol>
    +        <li>subtopic c</li>
    +        <li>subtopic d</li>
    +    </ol>
    +  </li>
    +</ol>
    +
    +
    + + +
    +

    Make your images scale with the browser window size

    + +

    For adaptive layout, use percentage widths on images, together +with CSS positioning:

    + +
      +
    • CSS positioning is simpler and more reliable than using +tables
    • +
    + +
    +<div class="slide"> 
    +  <h1>Analysts - "Open standards programming will become 
    +  mainstream, focused around VoiceXML"</h1> 
    +  <!-- use CSS positioning and scaling for adaptive layout --> 
    +  <img src="trends.png" width="50%" style="float:left" 
    +   alt="projected growth of VoiceXML" /> 
    +
    +  <blockquote style="float:right;width: 35%"> 
    +    VoiceXML will dominate the voice environment, due to its 
    +    flexibility and eventual multimodal capabilities 
    +  </blockquote><br clear="all" /> 
    + 
    +  <p style="text-align:center">Source Data Monitor, March 
    +  2004</p> 
    +</div> 
    +
    + +

    To work around a CSS rendering bug in IE relating +to margins, you can set display:inline on floated elements.

    +
    + +
    +

    Incremental display of layered images

    + +

    These can be marked up using CSS relative positioning, e.g.

    + +
    +<div class="incremental" 
    + style="margin-left: 4em; position: relative"> 
    +  <img src="graphics/face1.gif" alt="face" 
    +   style="position: static; vertical-align: bottom"/> 
    +  <img src="graphics/face2.gif" alt="eyes" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +  <img src="graphics/face3.gif" alt="nose" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +  <img src="graphics/face4.gif" alt="mouth" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +</div> 
    +
    + +

    You should also use transparent GIF +images to avoid the IE/Win bug for alpha channel in PNG. A fix is +expected in IE 7. A work around is +available on skyzyx.com. My thanks to ACID2 for the +graphics.

    + +
    +"face" +eyes +mouth
    +
    + +
    +

    How to center content vertically and horizontally

    +
    +
    +

    Within the div element for your slide:

    +
    +<div class="vbox"></div>
    +<div class="hbox">
    +Place the content here
    +</div>
    +
    +

    and style it with the following:

    +
    +div.vbox {
    +  float: left;
    +  height: 40%; width: 50%;
    +  margin-top: -220px;
    +}
    +div.hbox {
    +  width:60%;  margin-top: 0;
    +  margin-left:auto; margin-right:auto;
    +  height: 60%;
    +  border:1px solid silver;
    +  background:#F0F0F0;
    +  overflow:auto;
    +  text-align:left;
    +  clear:both;
    +}
    +
    + +

    The above styling is included in w3c-blue.css, +which is designed to be used with slidy.css, but you +are encouraged to develop your own style sheet with your own look and feel.

    +
    +
    + +
    +

    Include SVG Content

    + +

    Inclusion of SVG content can be done using the object element, +for example:

    + +
    Indian Office logo
    + +

    has been achieved by:

    + +
    +<object data="graphics/example.svg" type="image/svg+xml" 
    +  width="50%" height="10%" title="Indian Office logo"> 
    +    <img src="graphics/example.png" width="50%" 
    +          alt="Indian Office logo" /> 
    +</object> 
    +
    + +

    This ensures that the enclosed png is displayed when the browser +has no plugin installed or can't display SVG directly. Providing +such a fall back is very important! Don't forget the alt text for +people who can't see the image.

    + +

    However, there are caveats, see the next slide!

    +
    + +
    +

    Caveats with SVG+object

    + +

    Adobe has recently withdrawn support for its SVG Viewer, so you are +recommended to consider alternatives. +If you still using the Adobe SVG viewer you should be aware of bugs +when using the it with IE, Namely:

    + +
      +
    • Most modern browsers generally support SVG SVG Tiny 1.1 or better +natively without the need for a plugin
    • + +
    • If you need to use Internet Explorer you are advised to upgrade +to IE9 which includes native support for SVG.
    • + +
    • Patches to Internet Explorer mean that the Adobe SVG Viewer +version 3.03 no longer works with IE6. You are therefore recommended +to uninstall version 3.03 and instead install Adobe SVG Viewer +6.0 preview if this is available to to you.
    • + +
    • IE6 makes a copy of the SVG file on the local disc +when displaying it; but doesn't pass the original URI to the plugin
    • + +
    • As a result relative references from within the SVG to external +resources (scripts, CSS, images, other SVG) will break.
    • + +
    • The work around is to use absolute references within your SVG.
    • + +
    • On Windows, the Adobe SVG plugin doesn't respect the CSS z-index +property, and if used on backgrounds will always show through other +content
    • +
    +
    + +
    +

    Additional Remarks

    + +
      +
    • Slides are auto-numbered on the slide show footer
    • + +
    • You can link into the middle of a slide +show: + +
        +
      • It works out which slide you want and hides the rest
      • + +
      • You can even link between slides in the same slide show
      • + +
      • Individual sides can be addressed with the syntax #(slide +number),
        +e.g. slide 3 of this presentation is: http://www.w3.org/Talks/Tools/Slidy#(3) +
          +
        • Previous versions of Slidy used square brackets, which will +also work.
        • +
      • +
      • Note that the browser's back/forward buttons may not work as +you might expect due to browser problems.
      • +
      +
    • + +
    • Adding "title" to the list of classes for div elements that serve +as title pages will render the corresponding entry in the table of +contents in bold italic text (press "C" now for an example)
    • + +
    • If your slides have more content than normal, use a meta +element to request a smaller font + +
        +
      • the following requests fonts to be one step smaller than +the Slidy default for the current window width, and positive +integers will make the fonts correspondingly larger
      • +
      + +
      +<meta name="font-size-adjustment" content="-1" /> 
      +
      + +
        +
      • Slidy uses JavaScript to dynamically set the font size on the +body element, but it is okay to specify relative font changes on +other elements within your own style sheet, e.g.
      • +
      +
      div.slide.large { font-size: 200% }
      +
    • + +
    • You are encouraged to ensure your markup is valid. HTML Tidy can be used +to find and correct common markup problems
    • + +
    • The slide show script and style sheet can be used freely under +W3C's software +licensing and document +use policies
    • +
    • At XTech2006 +I gave this presentation +on Slidy +(Paper).
    • +
    +
    + +
    +

    Localization and automatic translation

    + +

    Slidy now includes support for localization

    + + "es":this.strings_es, + "ca":this.strings_ca, + "cs":this.strings_cs, + "nl":this.strings_nl, + "de":this.strings_de, + "pl":this.strings_pl, + "fr":this.strings_fr, + "hu":this.strings_hu, + "it":this.strings_it, + "el":this.strings_el, + "jp":this.strings_ja, + "zh":this.strings_zh, + "ru":this.strings_ru, + "sv":this.strings_sv + +
      +
    • The tool bar is localized according to the language of the presentation
    • +
    • This is taken from the xml:lang or lang attributes on the html element
    • +
    • The help file is +selected based upon your browser's language preferences
    • +
    • As of 29th July 2010, the languages supported are: English, +Spanish, Catalonian, Czech, Dutch, German, Polish, French, +Hungarian, Italian, Greek, Japanese, Chinese, Russian and +Swedish
    • +
    • If you would like to contribute localizations for other languages, +please get in touch with Dave Raggett <dsr@w3.org>
    • +
    • The following illustrates what was used for Spanish
    • +
    +
    +// for each language there is an associative array
    +  strings_es: {
    +    "slide":"pág.",
    +    "help?":"Ayuda",
    +    "contents?":"Índice",
    +    "table of contents":"tabla de contenidos",
    +    "Table of Contents":"Tabla de Contenidos",
    +    "restart presentation":"Reiniciar presentación",
    +    "restart?":"Inicio"
    +  },
    +  help_es:
    +    "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
    +    "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.",
    +
    + +

    Note: Slidy now works with current slides translated into French. Use +right mouse button to open frame without Google header. To disable +automatic translation of the content of particular elements add +class="notranslate", see breaking the language barrier.

    +
    + +
    +

    Future Plans

    + +

    Recent additions have included a table of contents, and a way to +hide and reveal content in the spirit of outline lists. The +script has been rewritten to make it easier to combine with other +scripts, e.g. for UI controls, and support swipes for navigation on +touch screen devices. Further work is anticipated on the +following:

    + +
      +
    • Collecting a gallery of good looking slide themes +
        +
      • Opportunities for graphics designers!
      • +
      +
    • +
    • Bob Ferris has worked on a +number of UI extensions which could be incorporated into the +W3C slidy script.
    • +
    • Getting SVG Tiny to work on IE without need for SVG plugin +
        +
      • Using scripts to dynamically convert SVG Tiny to VML
      • +
      • Note that IE9 introduces native SVG support, so it may +no longer be worth working on SVG to VML for rendering of SVG
      • +
      +
    • +
    • Pre-alpha version of wysiwyg slide editor (see screenshot) +
        +
      • Using contentEditable when available, otherwise +falling back to textarea and plain text conventions
      • +
      • Using XMLHttpRequest to dynamically reflect changes to server
      • +
      +
    • +
    • Mechanism for remotely driving Slidy as part of distributed meetings +
        +
      • Using XMLHttpRequest to listen for navigation commands
      • +
      • Using VoIP for accompanying audio and teleconferencing
      • +
      • Synchronizing recorded spoken presentation with currently viewed slide
      • +
      +
    • +
    • Filters from PowerPoint and Open Office + +
    • +
    + +

    If you have comments, suggestions for improvements, or would +like to volunteer your help with further work on Slidy, +please contact Dave Raggett <dsr@w3.org>

    +
    + +
    +

    Acknowledgements

    + +
      +
    • My thanks to everyone who sent in bug reports and feature +requests
    • +
    • Opera Software for implementing CSS @media projection and +promoting the idea of using the Web for presentations with +Opera +Show
    • +
    • Tantek Çelik for his +pioneering work on applying JavaScript for slide presentations on +other browsers
    • +
    • Eric Meyer for taking this further with the excellent S5
    • +
    • W3C's slidemaker +tool, which uses a perl script to split an html file up into +one file per slide with navigation buttons
    • +
    • Early versions of HTML +Tidy which supported a means to create presentations via splitting +html files on h2 elements
    • +
    • Many sites with advice on JavaScript work arounds for browser +variations
    • +
    • Microsoft for pioneering contentEditable and XMLHTTP which +both provide tremendous opportunities for Web applications
    • +
    • Microsoft Office which provided the impetus for creating +Slidy as a Web-based alternative to the ubiquitous use of PowerPoint
    • +
    + +

    Note that while Slidy and +S5 were developed independently, both support the use of the +class values "slide" and "handout" for div elements. Slidy doesn't +support the "layout" class featured in S5 and Opera Show, but +instead provides a more flexible alternative with the "background" +class, which enables different backgrounds on different slides.

    +
    + +
    +

    Acknowledgements

    + +

    The following people have contributed localizations:

    + +
      +
    • Emmanuelle Gutiérrez y Restrepo, Spanish
    • +
    • Joan V. Baz, Catalan
    • +
    • Jakub Vrána, Czech
    • +
    • Ruud Steltenpool, Dutch
    • +
    • Beat Vontobel, German
    • +
    • Krzysztof Kotowicz, Polish
    • +
    • Tamas Horvath, Hungarian
    • +
    • Creso Moraes, Brazilian Portuguese
    • +
    • Giuseppe Scollo, Italian
    • +
    • Konstantinos Koukopoulos, Greek
    • +
    • Yoshikazu Sawa (澤 義和), Japanese
    • +
    • Shelley Shyan, Chinese
    • +
    • Andrew Pantyukhin, Russian
    • +
    • Saasha Metsärantala, Swedish
    • +
    + +

    The following people have contributed bug reports:

    + +
      +
    • Steve Robertson
    • +
    • Ivan Herman
    • +
    • Steve Bratt
    • +
    • Peter Patel-Schneider
    • +
    • Matthew Coller
    • +
    • Rune Heggtveit
    • +
    • Gopal Venkatesan
    • +
    • Cay Horstmann
    • +
    • Schuyler Duveen
    • +
    • Matteo Nannini
    • +
    • Ralph Swick
    • +
    • Jakub Vrána
    • +
    • Philip Bolt
    • +
    • Jon Frost
    • +
    • Jonathan Chetwynd
    • +
    • Nicolas Frisby
    • +
    + +

    Douglas Crockford for jsmin +which was used to minify the script before compressing it with gzip.

    +
    + + diff --git a/slidy2/Overview.xhtml b/slidy2/Overview.xhtml new file mode 100644 index 0000000..a5903ab --- /dev/null +++ b/slidy2/Overview.xhtml @@ -0,0 +1,912 @@ + + + + +HTML Slidy + + + + + + + + + +
    + +
    +slanted W3C logo +
    +
    + + + + + + + + + + + + + +Cover page images (keys)
    +

    HTML Slidy: Slide Shows in HTML and XHTML

    + +

    Dave Raggett, +<dsr@w3.org>
    +
    +
    +
    +
    Hit the space bar or swipe left for next slide

    +
    + +
    +

    Slide Shows in HTML and XHTML

    + +
      +
    • You can now create accessible slide shows with ease
    • + +
    • Works across browsers and is operated like PowerPoint + +
        +
      • Advance to next slide with mouse click, space bar or swipe left
      • + +
      • Move forward/backward between slides with Cursor Left, +Cursor Right, Pg Up and Pg Dn +keys, or swipe left or right
      • + +
      • Home key for first slide, End + key for last slide
      • + +
      • The "C" key for an automatically generated +table of contents, or click on "contents" on the toolbar or +swipe up or down
      • + +
      • Function F11 to go full screen and back
      • + +
      • The "F" key toggles the display of the footer
      • + +
      • The "A" key toggles display of current vs all +slides + +
          +
        • Try it now to see how to include notes for handouts (this is +explained in the notes following this slide)
        • +
        +
      • + +
      • Font sizes automatically adapt to browser window size + +
          +
        • use S and B keys for +manual control (or < and >, or the - and ++ keys on the number pad
        • +
        • Use CSS to set a relative font size on a given slide to make +the content bigger or smaller than on other slides
        • +
        +
      • + +
      • Switching off JavaScript reveals all slides
      • +
      +
    • + +
    • Now move to next slide to see how it works
    • +
    + + +
    + +
    +

    For handouts, its often useful to include extra notes using a +div element with class="handout" following each slide, as in:

    + +
    +<div class="slide"> 
    + ... your slide content ...
    +</div>
    +
    +<div class="handout">
    + ... stuff that only appears in the handouts ...
    +</div>
    +
    +
    + +
    +

    What you need to do

    + + + +
    +<?xml version="1.0" encoding="utf-8"?>
    +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    +<head> 
    +  <title>Slide Shows in XHTML</title> 
    +  <meta name="copyright" 
    +   content="Copyright &#169; 2005 your copyright notice" /> 
    +  <link rel="stylesheet" type="text/css" media="screen, projection, print" 
    +   href="http://www.w3.org/Talks/Tools/Slidy2/styles/slidy.css" /> 
    +  <script src="http://www.w3.org/Talks/Tools/Slidy2/scripts/slidy.js" 
    +   charset="utf-8" type="text/javascript"></script> 
    +  <style type="text/css"> 
    +    <!-- your custom style rules --> 
    +  </style> 
    +</head>
    +<body>
    +   ... your slides marked up in XHTML ...
    +</body>
    +</html>
    +
    +
    + +
    +

    To get the W3C Blue Style

    + +

    The head element should include the following link to the style +sheet:

    + +
    +<link rel="stylesheet" type="text/css" media="screen, projection, print"
    + href="http://www.w3.org/Talks/Tools/Slidy2/styles/w3c-blue.css" /> 
    +
    + +

    The body element's content should start with the following +markup:

    + +
    +<div class="background"> 
    +  <img id="head-icon" alt="graphic with four colored squares"
    +    src="http://www.w3.org/Talks/Tools/Slidy2/graphics/icon-blue.png" /> 
    +  <object id="head-logo" title="W3C logo" type="image/svg+xml"
    +    data="http://www.w3.org/Talks/Tools/Slidy2/graphics/w3c-logo-white.svg"><img
    +   src="http://www.w3.org/Talks/Tools/Slidy2/graphics/w3c-logo-white.gif" 
    +   alt="W3C logo" id="head-logo-fallback" /></object>
    +</div> 
    +
    + +

    This adds the logos on the top left and right corners of the +slide.

    + +

    You are of course welcome to create your own slide designs. +You can provide different styles and backgrounds for +different slides (more details later).

    + +

    Use the meta element with name="copyright" +for use in the slide show footer:

    + +
    +<meta name="copyright" 
    +content="Copyright &#169; 2005-2009 W3C (MIT, ERCIM, Keio)" /> 
    +
    +
    + +
    +

    Upgrading from previous versions of Slidy

    + +
      +
    • This uses a new version of the HTML Slidy script
    • +
    • It is designed to work better with other scripts, +e.g. for UI controls within your slides +
        +
      • Only adds one global name "w3c_slidy"
      • +
      • Doesn't interfere with other scripts that set event handers +such as onload on body element
      • +
      +
    • +
    • Works for slides delivered as text/html and application/xhtml+xml
    • +
    • New presentation timer feature
    • +
    • Initial prompt on first slide to help newcomers to Slidy
    • +
    • Better support for styling slides and printing them
    • +
    • Requires additional style rules, so new script won't work +with old presentations without changes to their style sheets + +
    • +
    • But old presentations will work unchanged as they refer to +the old script!
    • +
    +
    + +
    +

    To use it off-line

    + +
      +
    • You can download slidy.zip and unzip +it to create a Slidy directory on your machine
    • + +
    • If you have cvs access to the W3C site you can check out the Slidy +directory
    • + +
    • Remember to periodically check for updates
    • + +
    • You then have two choices: + +
        +
      1. Use relative URIs depending on your local setup to access the +appropriate files. Use the same directory structure as on the W3C +server, ie, ".../2005/Talks/...".
      2. + +
      3. Run a Web server on your machine so that the directory above +can be accessed via http://localhost/Talks/Tools/Slidy2 +and use the URIs of the form "/Talks/Tools/Slidy2/styles/slidy.css", +"/Talks/Tools/Slidy2/scripts/slidy.js".
      4. +
    • + +
    • In both cases you can then publish your files on the W3C server +unchanged.
    • + +
    • NOTE Internet Explorer on Windows XP now disables +scripting for web pages loaded directly from the local file system, +a work around is to use another browser, e.g. Firefox or Opera
    • + +
    • Please feel free to create your own designs, and help us to build +a gallery of Slidy styles.
    • + +
    • My Google TechTalk (1st Feb 2006) +uses a notebook themed style
    • +
    +
    + +
    +

    Timing Your Presentation

    + +
      +
    • Sometimes it is handy to know just how much time you have to +left to finish your presentation
    • +
    • To get this feature, add the following markup to the +content of the head element, replacing 5 by the duration +of your presentation in minutes +
      <meta name="duration" content="5" />
      +
    • +
    • The time left in minutes and seconds is shown in the footer +next to the slide number
    • +
    • The clock starts to run when you move away from the first slide
    • +
    • Moving back to the first slide pauses the clock
    • +
    + + +
    + +
    +

    Generate a Title Page

    + +

    If you want a separate title page with the W3C blue style, the +first slide should be as follows:

    + +
    +<div class="slide cover"> 
    + <img src="http://www.w3.org/Talks/Tools/Slidy2/graphics/keys.jpg" 
    +  alt="Cover page images (keys)" class="cover" /> 
    + <br clear="all" />            
    + <h1>HTML Slidy: Slide Shows in XHTML</h1> 
    + <p><a href="http://www.w3.org/People/Raggett/">Dave Raggett,</a> 
    + <a href="mailto:dsr@w3.org">dsr@w3.org</a></p> 
    +</div> 
    +
    + +

    The w3c-blue.css +style sheet looks for the classes "slide" and "cover" on div +and img elements using the CSS selector div.slide.cover

    + +

    This technique can be used to assign your slides to different +classes with a different appearence for each such class.

    + +

    Slidy also allows you to use different background markup for +different slides, based upon shared class names, as in "foo" below. +Backgrounds without additional class names are always shown except +when the slide isn't transparent. You may need to tweak your +custom style sheet.

    + +
    +<div class="background foo">
    +   ... background content ...
    +<div>
    +
    +...
    +
    +<div class="slide foo">
    +   ... slide content ...
    +<div>
    +
    +
    + +
    +

    Incremental display of slide contents

    + +

    For incremental display, use class="incremental", for +instance:

    + +
      +
    • First bullet point
    • + +
    • Second bullet point
    • + +
    • Third bullet point
    • +
    + +

    which is marked up as follows:

    + +
    +<ul class="incremental"> 
    +  <li>First bullet point</li> 
    +  <li>Second bullet point</li> 
    +  <li>Third bullet point</li> 
    +</ul> 
    + 
    +<p class="incremental">which is marked up as follows:</p> 
    + 
    +<pre class="incremental"> 
    + ... 
    +</pre> 
    +
    + +
    +

    An element is incrementally revealed if its parent element has +class="incremental" or if itself has that attribute. Text nodes are +not elements and are revealed when their parent element is revealed. +You can use class="incremental" on any element except for <br />. +Use class="non-incremental" to override the effect of setting the +parent element's class to incremental.

    + +

    Note: you will see a red asterisk on the left of the toolbar +when there is still something more to reveal.

    +
    +
    + +
    +

    Create outline lists with hidden content

    + +

    You can make your bullet points or numbered list items +into outlines that you can expand or collapse

    + +
      +
    • Just add class="outline" to the ul or ol +element. Click on this list item for more details. + +
        +
      • The Slidy script will then treat the list +as an outline list.
      • +
      • Clicking on outline list items will expand/collapse +block-level elements within that list item.
      • +
      • Click on the above to make this list item +collapse again.
      • +
      +
    • +
    • Users will then see expand/collapse icons as appropriate +and may click anywhere on the list item to change its state. +This particular list item can't be expanded or collapsed.
    • +
    • Add class="expand" to any li elements that +you want to start in an expanded state. + +
        +
      • By default Slidy hides all the block level elements within the +outline list items unless you have specified class="expand".
      • +
      • Such pre-expanded items can be collapsed by clicking on them.
      • +
      +
    • +
    • Note expand/collapse icon highlighting requires browser +support for :hover which isn't supported by IE6. + +
        +
      • Microsoft says it will be supported by IE7 along with +many fixes for other CSS woes in IE6.
      • +
      +
    • +
    + +
    +<ol class='outline'>
    +  <!-- topic 1 starts collapsed -->
    +  <li>Topic 1
    +    <ol>
    +        <li>subtopic a</li>
    +        <li>subtopic b</li>
    +    </ol>
    +  </li>
    +  <!-- topic 2 starts expanded -->
    +  <li class="expand">Topic 2
    +    <ol>
    +        <li>subtopic c</li>
    +        <li>subtopic d</li>
    +    </ol>
    +  </li>
    +</ol>
    +
    +
    + + +
    +

    Make your images scale with the browser window size

    + +

    For adaptive layout, use percentage widths on images, together +with CSS positioning:

    + +
      +
    • CSS positioning is simpler and more reliable than using +tables
    • +
    + +
    +<div class="slide"> 
    +  <h1>Analysts - "Open standards programming will become 
    +  mainstream, focused around VoiceXML"</h1> 
    +  <!-- use CSS positioning and scaling for adaptive layout --> 
    +  <img src="trends.png" width="50%" style="float:left" 
    +   alt="projected growth of VoiceXML" /> 
    +
    +  <blockquote style="float:right;width: 35%"> 
    +    VoiceXML will dominate the voice environment, due to its 
    +    flexibility and eventual multimodal capabilities 
    +  </blockquote><br clear="all" /> 
    + 
    +  <p style="text-align:center">Source Data Monitor, March 
    +  2004</p> 
    +</div> 
    +
    + +

    To work around a CSS rendering bug in IE relating +to margins, you can set display:inline on floated elements.

    +
    + +
    +

    Incremental display of layered images

    + +

    These can be marked up using CSS relative positioning, e.g.

    + +
    +<div class="incremental" 
    + style="margin-left: 4em; position: relative"> 
    +  <img src="graphics/face1.gif" alt="face" 
    +   style="position: static; vertical-align: bottom"/> 
    +  <img src="graphics/face2.gif" alt="eyes" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +  <img src="graphics/face3.gif" alt="nose" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +  <img src="graphics/face4.gif" alt="mouth" 
    +    style="position: absolute; left: 0; top: 0" /> 
    +</div> 
    +
    + +

    You should also use transparent GIF +images to avoid the IE/Win bug for alpha channel in PNG. A fix is +expected in IE 7. A work around is +available on skyzyx.com. My thanks to ACID2 for the +graphics.

    + +
    +"face" +eyes +mouth
    +
    + +
    +

    How to center content vertically and horizontally

    +
    +
    +

    Within the div element for your slide:

    +
    +<div class="vbox"></div>
    +<div class="hbox">
    +Place the content here
    +</div>
    +
    +

    and style it with the following:

    +
    +div.vbox {
    +  float: left;
    +  height: 40%; width: 50%;
    +  margin-top: -220px;
    +}
    +div.hbox {
    +  width:60%;  margin-top: 0;
    +  margin-left:auto; margin-right:auto;
    +  height: 60%;
    +  border:1px solid silver;
    +  background:#F0F0F0;
    +  overflow:auto;
    +  text-align:left;
    +  clear:both;
    +}
    +
    + +

    The above styling is included in w3c-blue.css, +which is designed to be used with slidy.css, but you +are encouraged to develop your own style sheet with your own look and feel.

    +
    +
    + +
    +

    Include SVG Content

    + +

    Inclusion of SVG content can be done using the object element, +for example:

    + +
    Indian Office logo
    + +

    has been achieved by:

    + +
    +<object data="graphics/example.svg" type="image/svg+xml" 
    +  width="50%" height="10%" title="Indian Office logo"> 
    +    <img src="graphics/example.png" width="50%" 
    +          alt="Indian Office logo" /> 
    +</object> 
    +
    + +

    This ensures that the enclosed png is displayed when the browser +has no plugin installed or can't display SVG directly. Providing +such a fall back is very important! Don't forget the alt text for +people who can't see the image.

    + +

    However, there are caveats, see the next slide!

    +
    + +
    +

    Caveats with SVG+object

    + +

    Adobe has recently withdrawn support for its SVG Viewer, so you are +recommended to consider alternatives. +If you still using the Adobe SVG viewer you should be aware of bugs +when using the it with IE, Namely:

    + +
      +
    • Most modern browsers generally support SVG SVG Tiny 1.1 or better +natively without the need for a plugin
    • + +
    • If you need to use Internet Explorer you are advised to upgrade +to IE9 which includes native support for SVG.
    • + +
    • Patches to Internet Explorer mean that the Adobe SVG Viewer +version 3.03 no longer works with IE6. You are therefore recommended +to uninstall version 3.03 and instead install Adobe SVG Viewer +6.0 preview if this is available to to you.
    • + +
    • IE6 makes a copy of the SVG file on the local disc +when displaying it; but doesn't pass the original URI to the plugin
    • + +
    • As a result relative references from within the SVG to external +resources (scripts, CSS, images, other SVG) will break.
    • + +
    • The work around is to use absolute references within your SVG.
    • + +
    • On Windows, the Adobe SVG plugin doesn't respect the CSS z-index +property, and if used on backgrounds will always show through other +content
    • +
    +
    + +
    +

    Additional Remarks

    + +
      +
    • Slides are auto-numbered on the slide show footer
    • + +
    • You can link into the middle of a slide +show: + +
        +
      • It works out which slide you want and hides the rest
      • + +
      • You can even link between slides in the same slide show
      • + +
      • Individual sides can be addressed with the syntax #(slide +number),
        +e.g. slide 3 of this presentation is: http://www.w3.org/Talks/Tools/Slidy#(3) +
          +
        • Previous versions of Slidy used square brackets, which will +also work.
        • +
      • +
      • Note that the browser's back/forward buttons may not work as +you might expect due to browser problems.
      • +
      +
    • + +
    • Adding "title" to the list of classes for div elements that serve +as title pages will render the corresponding entry in the table of +contents in bold italic text (press "C" now for an example)
    • + +
    • If your slides have more content than normal, use a meta +element to request a smaller font + +
        +
      • the following requests fonts to be one step smaller than +the Slidy default for the current window width, and positive +integers will make the fonts correspondingly larger
      • +
      + +
      +<meta name="font-size-adjustment" content="-1" /> 
      +
      + +
        +
      • Slidy uses JavaScript to dynamically set the font size on the +body element, but it is okay to specify relative font changes on +other elements within your own style sheet, e.g.
      • +
      +
      div.slide.large { font-size: 200% }
      +
    • + +
    • You are encouraged to ensure your markup is valid. HTML Tidy can be used +to find and correct common markup problems
    • + +
    • The slide show script and style sheet can be used freely under +W3C's software +licensing and document +use policies
    • +
    • At XTech2006 +I gave this presentation +on Slidy +(Paper).
    • +
    +
    + +
    +

    Localization and automatic translation

    + +

    Slidy now includes support for localization

    + + "es":this.strings_es, + "ca":this.strings_ca, + "cs":this.strings_cs, + "nl":this.strings_nl, + "de":this.strings_de, + "pl":this.strings_pl, + "fr":this.strings_fr, + "hu":this.strings_hu, + "it":this.strings_it, + "el":this.strings_el, + "jp":this.strings_ja, + "zh":this.strings_zh, + "ru":this.strings_ru, + "sv":this.strings_sv + +
      +
    • The tool bar is localized according to the language of the presentation
    • +
    • This is taken from the xml:lang or lang attributes on the html element
    • +
    • The help file is +selected based upon your browser's language preferences
    • +
    • As of 29th July 2010, the languages supported are: English, +Spanish, Catalonian, Czech, Dutch, German, Polish, French, +Hungarian, Italian, Greek, Japanese, Chinese, Russian and +Swedish
    • +
    • If you would like to contribute localizations for other languages, +please get in touch with Dave Raggett <dsr@w3.org>
    • +
    • The following illustrates what was used for Spanish
    • +
    +
    +// for each language there is an associative array
    +  strings_es: {
    +    "slide":"pág.",
    +    "help?":"Ayuda",
    +    "contents?":"Índice",
    +    "table of contents":"tabla de contenidos",
    +    "Table of Contents":"Tabla de Contenidos",
    +    "restart presentation":"Reiniciar presentación",
    +    "restart?":"Inicio"
    +  },
    +  help_es:
    +    "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " +
    +    "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.",
    +
    + +

    Note: Slidy now works with current slides translated into French. Use +right mouse button to open frame without Google header. To disable +automatic translation of the content of particular elements add +class="notranslate", see breaking the language barrier.

    +
    + +
    +

    Future Plans

    + +

    Recent additions have included a table of contents, and a way to +hide and reveal content in the spirit of outline lists. The +script has been rewritten to make it easier to combine with other +scripts, e.g. for UI controls, and support swipes for navigation on +touch screen devices. Further work is anticipated on the +following:

    + +
      +
    • Collecting a gallery of good looking slide themes +
        +
      • Opportunities for graphics designers!
      • +
      +
    • +
    • Bob Ferris has worked on a +number of UI extensions which could be incorporated into the +W3C slidy script.
    • +
    • Getting SVG Tiny to work on IE without need for SVG plugin +
        +
      • Using scripts to dynamically convert SVG Tiny to VML
      • +
      • Note that IE9 introduces native SVG support, so it may +no longer be worth working on SVG to VML for rendering of SVG
      • +
      +
    • +
    • Pre-alpha version of wysiwyg slide editor (see screenshot) +
        +
      • Using contentEditable when available, otherwise +falling back to textarea and plain text conventions
      • +
      • Using XMLHttpRequest to dynamically reflect changes to server
      • +
      +
    • +
    • Mechanism for remotely driving Slidy as part of distributed meetings +
        +
      • Using XMLHttpRequest to listen for navigation commands
      • +
      • Using VoIP for accompanying audio and teleconferencing
      • +
      • Synchronizing recorded spoken presentation with currently viewed slide
      • +
      +
    • +
    • Filters from PowerPoint and Open Office + +
    • +
    + +

    If you have comments, suggestions for improvements, or would +like to volunteer your help with further work on Slidy, +please contact Dave Raggett <dsr@w3.org>

    +
    + +
    +

    Acknowledgements

    + +
      +
    • My thanks to everyone who sent in bug reports and feature +requests
    • +
    • Opera Software for implementing CSS @media projection and +promoting the idea of using the Web for presentations with +Opera +Show
    • +
    • Tantek Çelik for his +pioneering work on applying JavaScript for slide presentations on +other browsers
    • +
    • Eric Meyer for taking this further with the excellent S5
    • +
    • W3C's slidemaker +tool, which uses a perl script to split an html file up into +one file per slide with navigation buttons
    • +
    • Early versions of HTML +Tidy which supported a means to create presentations via splitting +html files on h2 elements
    • +
    • Many sites with advice on JavaScript work arounds for browser +variations
    • +
    • Microsoft for pioneering contentEditable and XMLHTTP which +both provide tremendous opportunities for Web applications
    • +
    • Microsoft Office which provided the impetus for creating +Slidy as a Web-based alternative to the ubiquitous use of PowerPoint
    • +
    + +

    Note that while Slidy and +S5 were developed independently, both support the use of the +class values "slide" and "handout" for div elements. Slidy doesn't +support the "layout" class featured in S5 and Opera Show, but +instead provides a more flexible alternative with the "background" +class, which enables different backgrounds on different slides.

    +
    + +
    +

    Acknowledgements

    + +

    The following people have contributed localizations:

    + +
      +
    • Emmanuelle Gutiérrez y Restrepo, Spanish
    • +
    • Joan V. Baz, Catalan
    • +
    • Jakub Vrána, Czech
    • +
    • Ruud Steltenpool, Dutch
    • +
    • Beat Vontobel, German
    • +
    • Krzysztof Kotowicz, Polish
    • +
    • Tamas Horvath, Hungarian
    • +
    • Creso Moraes, Brazilian Portuguese
    • +
    • Giuseppe Scollo, Italian
    • +
    • Konstantinos Koukopoulos, Greek
    • +
    • Yoshikazu Sawa (澤 義和), Japanese
    • +
    • Shelley Shyan, Chinese
    • +
    • Andrew Pantyukhin, Russian
    • +
    • Saasha Metsärantala, Swedish
    • +
    + +

    The following people have contributed bug reports:

    + +
      +
    • Steve Robertson
    • +
    • Ivan Herman
    • +
    • Steve Bratt
    • +
    • Peter Patel-Schneider
    • +
    • Matthew Coller
    • +
    • Rune Heggtveit
    • +
    • Gopal Venkatesan
    • +
    • Cay Horstmann
    • +
    • Schuyler Duveen
    • +
    • Matteo Nannini
    • +
    • Ralph Swick
    • +
    • Jakub Vrána
    • +
    • Philip Bolt
    • +
    • Jon Frost
    • +
    • Jonathan Chetwynd
    • +
    • Nicolas Frisby
    • +
    + +

    Douglas Crockford for jsmin +which was used to minify the script before compressing it with gzip.

    +
    + + diff --git a/slidy2/blank.html b/slidy2/blank.html new file mode 100644 index 0000000..c9081eb --- /dev/null +++ b/slidy2/blank.html @@ -0,0 +1,30 @@ + + + + + +HTML Slidy - template for basic presentations + + + + + + + +
    +

    Sample heading

    + +

    This is a template file you can copy and edit on your own server.

    + +
      +
    • point 1
    • +
    • point 2
    • +
    • . . .
    • +
    +
    + + diff --git a/slidy2/graphics/bullet-fold-dim.gif b/slidy2/graphics/bullet-fold-dim.gif new file mode 100644 index 0000000..bce1a2a Binary files /dev/null and b/slidy2/graphics/bullet-fold-dim.gif differ diff --git a/slidy2/graphics/bullet-fold-dim.png b/slidy2/graphics/bullet-fold-dim.png new file mode 100644 index 0000000..4e28cfa Binary files /dev/null and b/slidy2/graphics/bullet-fold-dim.png differ diff --git a/slidy2/graphics/bullet-fold.gif b/slidy2/graphics/bullet-fold.gif new file mode 100644 index 0000000..d4b063c Binary files /dev/null and b/slidy2/graphics/bullet-fold.gif differ diff --git a/slidy2/graphics/bullet-fold.png b/slidy2/graphics/bullet-fold.png new file mode 100644 index 0000000..b5334f3 Binary files /dev/null and b/slidy2/graphics/bullet-fold.png differ diff --git a/slidy2/graphics/bullet-nofold-dim.gif b/slidy2/graphics/bullet-nofold-dim.gif new file mode 100644 index 0000000..98a4c39 Binary files /dev/null and b/slidy2/graphics/bullet-nofold-dim.gif differ diff --git a/slidy2/graphics/bullet-nofold-dim.png b/slidy2/graphics/bullet-nofold-dim.png new file mode 100644 index 0000000..27bccb2 Binary files /dev/null and b/slidy2/graphics/bullet-nofold-dim.png differ diff --git a/slidy2/graphics/bullet-nofold.gif b/slidy2/graphics/bullet-nofold.gif new file mode 100644 index 0000000..76102a3 Binary files /dev/null and b/slidy2/graphics/bullet-nofold.gif differ diff --git a/slidy2/graphics/bullet-nofold.png b/slidy2/graphics/bullet-nofold.png new file mode 100644 index 0000000..28215ec Binary files /dev/null and b/slidy2/graphics/bullet-nofold.png differ diff --git a/slidy2/graphics/bullet-unfold-dim.gif b/slidy2/graphics/bullet-unfold-dim.gif new file mode 100644 index 0000000..b758cbe Binary files /dev/null and b/slidy2/graphics/bullet-unfold-dim.gif differ diff --git a/slidy2/graphics/bullet-unfold-dim.png b/slidy2/graphics/bullet-unfold-dim.png new file mode 100644 index 0000000..1dec59d Binary files /dev/null and b/slidy2/graphics/bullet-unfold-dim.png differ diff --git a/slidy2/graphics/bullet-unfold.gif b/slidy2/graphics/bullet-unfold.gif new file mode 100644 index 0000000..e5ecd5b Binary files /dev/null and b/slidy2/graphics/bullet-unfold.gif differ diff --git a/slidy2/graphics/bullet-unfold.png b/slidy2/graphics/bullet-unfold.png new file mode 100644 index 0000000..ce9de96 Binary files /dev/null and b/slidy2/graphics/bullet-unfold.png differ diff --git a/slidy2/graphics/bullet.gif b/slidy2/graphics/bullet.gif new file mode 100644 index 0000000..8a5bec9 Binary files /dev/null and b/slidy2/graphics/bullet.gif differ diff --git a/slidy2/graphics/bullet.png b/slidy2/graphics/bullet.png new file mode 100644 index 0000000..14ebd95 Binary files /dev/null and b/slidy2/graphics/bullet.png differ diff --git a/slidy2/graphics/example.png b/slidy2/graphics/example.png new file mode 100644 index 0000000..7ce9b3f Binary files /dev/null and b/slidy2/graphics/example.png differ diff --git a/slidy2/graphics/example.svg b/slidy2/graphics/example.svg new file mode 100644 index 0000000..581358e --- /dev/null +++ b/slidy2/graphics/example.svg @@ -0,0 +1,223 @@ + + + + W3C Indian Office logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/slidy2/graphics/face1.gif b/slidy2/graphics/face1.gif new file mode 100644 index 0000000..04e50cd Binary files /dev/null and b/slidy2/graphics/face1.gif differ diff --git a/slidy2/graphics/face2.gif b/slidy2/graphics/face2.gif new file mode 100644 index 0000000..12d8240 Binary files /dev/null and b/slidy2/graphics/face2.gif differ diff --git a/slidy2/graphics/face3.gif b/slidy2/graphics/face3.gif new file mode 100644 index 0000000..ac6e5e4 Binary files /dev/null and b/slidy2/graphics/face3.gif differ diff --git a/slidy2/graphics/face4.gif b/slidy2/graphics/face4.gif new file mode 100644 index 0000000..3f68740 Binary files /dev/null and b/slidy2/graphics/face4.gif differ diff --git a/slidy2/graphics/fold-bright.gif b/slidy2/graphics/fold-bright.gif new file mode 100644 index 0000000..7e38faa Binary files /dev/null and b/slidy2/graphics/fold-bright.gif differ diff --git a/slidy2/graphics/fold-dim.bmp b/slidy2/graphics/fold-dim.bmp new file mode 100644 index 0000000..117f91a Binary files /dev/null and b/slidy2/graphics/fold-dim.bmp differ diff --git a/slidy2/graphics/fold-dim.gif b/slidy2/graphics/fold-dim.gif new file mode 100644 index 0000000..346fcbf Binary files /dev/null and b/slidy2/graphics/fold-dim.gif differ diff --git a/slidy2/graphics/fold.bmp b/slidy2/graphics/fold.bmp new file mode 100644 index 0000000..6ba9e56 Binary files /dev/null and b/slidy2/graphics/fold.bmp differ diff --git a/slidy2/graphics/fold.gif b/slidy2/graphics/fold.gif new file mode 100644 index 0000000..133e594 Binary files /dev/null and b/slidy2/graphics/fold.gif differ diff --git a/slidy2/graphics/icon-blue.png b/slidy2/graphics/icon-blue.png new file mode 100644 index 0000000..58bf969 Binary files /dev/null and b/slidy2/graphics/icon-blue.png differ diff --git a/slidy2/graphics/keys2.jpg b/slidy2/graphics/keys2.jpg new file mode 100644 index 0000000..4739be0 Binary files /dev/null and b/slidy2/graphics/keys2.jpg differ diff --git a/slidy2/graphics/nofold-dim.bmp b/slidy2/graphics/nofold-dim.bmp new file mode 100644 index 0000000..8a12826 Binary files /dev/null and b/slidy2/graphics/nofold-dim.bmp differ diff --git a/slidy2/graphics/nofold-dim.gif b/slidy2/graphics/nofold-dim.gif new file mode 100644 index 0000000..996fb5e Binary files /dev/null and b/slidy2/graphics/nofold-dim.gif differ diff --git a/slidy2/graphics/nofold.bmp b/slidy2/graphics/nofold.bmp new file mode 100644 index 0000000..0937d32 Binary files /dev/null and b/slidy2/graphics/nofold.bmp differ diff --git a/slidy2/graphics/unfold-bright.gif b/slidy2/graphics/unfold-bright.gif new file mode 100644 index 0000000..2748131 Binary files /dev/null and b/slidy2/graphics/unfold-bright.gif differ diff --git a/slidy2/graphics/unfold-dim.bmp b/slidy2/graphics/unfold-dim.bmp new file mode 100644 index 0000000..c2a6baf Binary files /dev/null and b/slidy2/graphics/unfold-dim.bmp differ diff --git a/slidy2/graphics/unfold-dim.gif b/slidy2/graphics/unfold-dim.gif new file mode 100644 index 0000000..bee5671 Binary files /dev/null and b/slidy2/graphics/unfold-dim.gif differ diff --git a/slidy2/graphics/unfold.bmp b/slidy2/graphics/unfold.bmp new file mode 100644 index 0000000..30af625 Binary files /dev/null and b/slidy2/graphics/unfold.bmp differ diff --git a/slidy2/graphics/unfold.gif b/slidy2/graphics/unfold.gif new file mode 100644 index 0000000..0753ae4 Binary files /dev/null and b/slidy2/graphics/unfold.gif differ diff --git a/slidy2/graphics/w3c-logo-blue.gif b/slidy2/graphics/w3c-logo-blue.gif new file mode 100644 index 0000000..890bc97 Binary files /dev/null and b/slidy2/graphics/w3c-logo-blue.gif differ diff --git a/slidy2/graphics/w3c-logo-blue.svg b/slidy2/graphics/w3c-logo-blue.svg new file mode 100644 index 0000000..6595d01 --- /dev/null +++ b/slidy2/graphics/w3c-logo-blue.svg @@ -0,0 +1,14 @@ + + + W3C logo + + + + + + + ® + + + + diff --git a/slidy2/graphics/w3c-logo-slanted.jpg b/slidy2/graphics/w3c-logo-slanted.jpg new file mode 100644 index 0000000..54e0ac3 Binary files /dev/null and b/slidy2/graphics/w3c-logo-slanted.jpg differ diff --git a/slidy2/graphics/w3c-logo-white.gif b/slidy2/graphics/w3c-logo-white.gif new file mode 100644 index 0000000..3b3c6fd Binary files /dev/null and b/slidy2/graphics/w3c-logo-white.gif differ diff --git a/slidy2/graphics/w3c-logo-white.svg b/slidy2/graphics/w3c-logo-white.svg new file mode 100644 index 0000000..d63907f --- /dev/null +++ b/slidy2/graphics/w3c-logo-white.svg @@ -0,0 +1,14 @@ + + + W3C logo + + + + + + + ® + + + + diff --git a/slidy2/help/.htaccess b/slidy2/help/.htaccess new file mode 100644 index 0000000..d395348 --- /dev/null +++ b/slidy2/help/.htaccess @@ -0,0 +1,28 @@ +Options +MultiViews +LanguagePriority en +AddLanguage pt-br .pt-br + + + +ForceType 'text/html; charset=utf-8' + + + + + +ForceType 'application/xhtml+xml; charset=utf-8' + + + + + +ForceType 'text/css; charset=utf-8' + + + + + +ForceType 'text/javascript; charset=utf-8' + + +mkdir diff --git a/slidy2/help/help.html b/slidy2/help/help.html new file mode 100644 index 0000000..c2f8614 --- /dev/null +++ b/slidy2/help/help.html @@ -0,0 +1,80 @@ + + + + Slide Show Help + + + +

    Slide Show Help

    + +

    This slide show can be driven in the same way as Power Point. +To advance to the next slide click pretty much anywhere on the +page with the mouse, or press the space bar. You can move forwards +or backwards through the slides with the Cursor left, Cursor +right, Pg Up and Pg Dn keys. The font size is automatically +adjusted to match the browser's window width, but you can also +adjust it manually using the "S" key for smaller and the "B" key +for bigger. You can also use the "<" and ">" keys. Use the +"F" key to switch off/on the bottom status line. The "K" key +toggles the use of mouse click to advance to the next slide. You +can use "C" to show the table of contents and any other key to +hide it. Use the "F11" key to toggle the browser's full screen +mode. Note that not all keys are supported in all browsers, as +browsers may reserve some keys for browser control and this varies +from one browser to the next.

    + +

    Firefox users may want the autohide +extension to hide the toolbars when entering full screen with F11. +Newer versions of Firefox have built-in support for SVG, but on older +versions for Microsoft Windows, you should consider installing the Adobe SVG Viewer +6.0.

    + +

    If you would like to see how Slidy works, use View Source to view +the XHTML markup, or see this longer explanation, +which also explains additional features. Each slide is marked up as +a div element with class="slide". CSS positioning and percentage +widths on images can be used to ensure your image rich slides scale +to match the window size. Content to be revealed incrementally can +be marked up with class="incremental". The linked style sheet and +scripts were developed as a Web-based alternative to proprietary +presentation tools and have been tested on a variety of recent +browsers. Integrated editing support is under development. Please +send your comments to Dave +Raggett <dsr@w3.org>. +If you find Slidy useful, you may want to consider becoming a +W3C Supporter.

    + +

    You are welcome to make use of the slide show style sheets, +scripts and help file under W3C's document use +and software +licensing rules.

    + + + +
    + + + diff --git a/slidy2/help/help.html.ca b/slidy2/help/help.html.ca new file mode 100644 index 0000000..fef10cf --- /dev/null +++ b/slidy2/help/help.html.ca @@ -0,0 +1,52 @@ + + + + + Ajuda del presentador de diapositives + + + +

    Ajuda del presentador de diapositives

    + +

    Per avançar a la pròxima diapositiva només cal fer clic amb el ratolí en qualsevol lloc de la pàgina o bé prémer la barra d’espaidora. +Es pot anar endavant i endarrere per les diapositives amb les tecles "cursor esquerra" i "cursor dreta", "RePàg" i "AvPàg". El tamany de font de les lletres s’ajusta automàticament a l’amplada de la pantalla, però també es pot ajustar manualment fent servir la “S” per fer-la mes petita (Smaller) i la “B” per fer-la mes gran (“Bigger”),també es poden fer servir les tecles "<" i ">". +La tecla “F” fa aparèixer/desaparèixer el menú de la línia de estat a la part de sota. +Amb la tecla “K” s’habilita/deshabilita l’ús del ratolí per avançar a la pròxima diapositiva. La tecla “C” mostra la taula de continguts, amb qualsevol altra tecla la podem amagar. +La tecla “F11” serveix per entrar/sortir en el mode pantalla completa del navegador, la tecla “H” dona accés a aquesta pàgina. +Cal notar que no totes les tecles estan suportades en tots els navegadors donat que els navegadors poden reservar algunes tecles per el control de navegació i aquestes varien d’un navegador a un altre.

    +

    Es recomana als usuaris de Firefox que instal•lin la extensió d’autoamagar per amagar les barres d’eines en entrar al mode pantalla completa.

    +

    Si vol saber com funciona Slidy, feu servir “Veure el codi font” per veure el codi XHTML o vegi aquesta explicació més llarga., que també explica característiques addicionals. Cada diapositiva està marcada com element div amb classe “slide”. Es fa servir posicionament CSS i amplades per percentatge a les imatges per assegurar-se de que les vostres diapositives riques en imatges s’ajustin perfectament a la grandària de la finestra. El contingut que s’ha de revelar incrementalment es pot marcar amb la classe “incremental”. La fulla d’estils adjunta i els scripts es van desenvolupar com una alternativa basada en Web a les eines de presentació propietàries i s’han provat en una gran varietat de navegadors actuals. S’està desenvolupant un sistema d’edició integrada. Si us plau envieu els vostres comentaris a : Dave +Raggett <dsr@w3.org>. +Si trobeu Slidy útil podeu considerar ajudar al W3C.

    +

    Sou benvingut a fer servir el presentador de diapositives, les fulles d’estil , scripts i el fitxer d’ajuda sota les condicions d’ ùs de document del W3C I les normes +llicència de software.

    + + + +
    + + + + diff --git a/slidy2/help/help.html.de b/slidy2/help/help.html.de new file mode 100644 index 0000000..55a8e48 --- /dev/null +++ b/slidy2/help/help.html.de @@ -0,0 +1,96 @@ + + + + + + + Slide Show Help + + + + +

    Hilfe für die HTML-Slidy-Präsentation

    + +

    Diese Präsentation wird wie Power Point kontrolliert: Klicken +Sie mit der Maus irgendwo ins Bild, um zur nächsten Seite zu +schalten, oder drücken Sie die Leertaste. Sie können ebenfalls +mit den Cursor-Tasten (links/rechts) oder den Tasten für Seite +auf und ab vorwärts und rückwärts durch die Präsentation +navigieren. Die Schriftgrösse wird automatisch so angepasst, dass +Sie zur Fensterbreite des Browsers passt, sie kann aber auch +manuell mit den Tasten "s" (kleiner) und "b" (grösser) +kontrolliert werden (oder mit der Taste "<" bzw. ">"). Die +Statuszeile am unteren Rand des Fensters wird mit "f" ein- und +ausgeschaltet. Die Taste "k" schaltet die Funktion des Mausklicks +zum Kontrollieren der Präsentation ein und aus. Sie können mit +"c" ein Inhaltsverzeichnis ein- und mit einer beliebigen anderen +Taste wieder ausblenden. Mit "F11" können Sie (je nach Browser) +den Vollbildmodus aktivieren. Die Taste "h" zeigt diesen Hilfetext +an. Es ist zu bemerken, dass nicht alle diese Tasten in jedem +Browser funktionieren, da sie zum Teil mit anderen Funktionen +belegt sind.

    + +

    Firefox-Benutzer können die autohide-Erweiterung +installieren, um die Werkzeugleiste im Vollbildmodus auszublenden.

    + +

    Wenn Sie wissen möchten, wie Slidy funktioniert, schauen Sie sich +den XHTML-Quellcode der Seite an oder lesen diese etwas längere Erklärung +(in Englisch), die auch weitere Funktionen erläutert. Jede einzelne +Folie ist als ein div-Element mit class="slide" +markiert. CSS-Positionierung und prozentuale Breitenangaben für Bilder +können benutzt werden, um sicherzustellen, dass die Folien bei +verschiedenen Fenstergrössen optimal dargestellt werden. Der Inhalt +auf Folien kann schrittweise angezeigt werden, indem den Elementen +class="incremental" zugewiesen wird. Das eingebundene +Style Sheet und die Skripten wurden als web-basierte Alternative zu +proprietären Programmen entwickelt. Sie wurden auf verschiedensten +aktuellen Browsern getestet. Ein eingebauter Editor für die Folien +ist in Entwicklung. Bitte senden Sie Kommentare an Dave Raggett <dsr@w3.org>. Wenn Sie Slidy +nützlich finden, möchten Sie vielleicht ein W3C Supporter werden.

    + +

    Die Style Sheets, die Skripten der Präsentation und die +zugehörigen Texte sind frei zur Benutzung unter den Bedingungen +der W3C-Lizenzen document +use und software +licensing.

    + + + +
    + + + + + diff --git a/slidy2/help/help.html.en b/slidy2/help/help.html.en new file mode 100644 index 0000000..f7e9e5c --- /dev/null +++ b/slidy2/help/help.html.en @@ -0,0 +1,81 @@ + + + + + + Slide Show Help + + + + +

    Slide Show Help

    + +

    This slide show can be driven in the same way as Power Point. +To advance to the next slide click pretty much anywhere on the +page with the mouse, or press the space bar. You can move forwards +or backwards through the slides with the Cursor left, Cursor +right, Pg Up and Pg Dn keys. The font size is automatically +adjusted to match the browser's window width, but you can also +adjust it manually using the "S" key for smaller and the "B" key +for bigger. You can also use the "<" and ">" keys. Use the +"F" key to switch off/on the bottom status line. The "K" key +toggles the use of mouse click to advance to the next slide. You +can use "C" to show the table of contents and any other key to +hide it. Press the "H" key to view this page. Use the "F11" key to +toggle the browser's full screen mode. Note that not all keys are +supported in all browsers, as browsers may reserve some keys for +browser control and this varies from one browser to the next.

    + +

    Firefox users may want the autohide +extension to hide the toolbars when entering full screen with F11.

    + +

    If you would like to see how Slidy works, use View Source to view +the XHTML markup, or see this longer explanation, +which also explains additional features. Each slide is marked up as +a div element with class="slide". CSS positioning and percentage +widths on images can be used to ensure your image rich slides scale +to match the window size. Content to be revealed incrementally can +be marked up with class="incremental". The linked style sheet and +scripts were developed as a Web-based alternative to proprietary +presentation tools and have been tested on a variety of recent +browsers. Integrated editing support is under development. Please +send your comments to Dave +Raggett <dsr@w3.org>. +If you find Slidy useful, you may want to consider becoming a +W3C Supporter.

    + +

    You are welcome to make use of the slide show style sheets, +scripts and help file under W3C's document use +and software +licensing rules.

    + + + +
    + + + + diff --git a/slidy2/help/help.html.es b/slidy2/help/help.html.es new file mode 100644 index 0000000..a3059aa --- /dev/null +++ b/slidy2/help/help.html.es @@ -0,0 +1,52 @@ + + + + + + + Ayuda de Slidy + + + + +

    Ayuda de "Slidy"

    + +

    Esta presentación puede manejarse igual que una presentación hecha con Power Point. +Para avanzar a la siguiente página o diapositiva haga clic con el ratón en cualquier parte de la página, o pulse la barra espaciadora. Puede moverse adelante y atrás entre las diapositivas con las teclas de flecha izquierda, derecha, retroceso de página (Re Pag) o avance de página (Av Pag). El tamaño de fuente se ajusta automáticamente para encajar en el ancho de la ventana del navegador, pero puede ajustarlo manualmente utilizando la tecla "S" para reducirlo y la tecla "B" para aumentarlo. También puede usar las teclas "<" y ">". Use la tecla "F" para presentar u ocultar la línea de estado en la parte inferior. La tecla "K" habilita o deshabilita el uso del ratón para avanzar a la siguiente diapositiva. Puede usar la tecla "C" para mostrar la tabla de contenidos o índice, y cualquier otra tecla para esconderla. Use la tecla de función "F11" para conmutar la vista a toda pantalla del navegador. Tenga en cuenta que no todas las teclas están igualmente soportadas en todos los navegadores, ya que los navegadores pueden tener reservado el uso de algunas teclas para controles del navegador, y esto puede variar de un navegador a otro.

    + +

    Los usuarios de Firefox pueden desear instalar la extensión "autohide" +para ocultar las barras de herramientas cuando utilizan la función F11 para el modo a toda pantalla.

    + +

    Si desea saber cómo funciona Slidy, utilice la Vista de Código para ver el marcado XHML, o vea esta explicación extensa, +que expone otras características adicionales. Cada diapositiva está marcada con un elemento div con la clase class="slide". Puede usarse posicionamiento y anchos en porcentajes para las imágenes, mediante CSS, para garantizar que la imagen alcance el tamaño de la diapositiva de acuerdo con el tamaño de la ventana. El contenido que se desee presentar paulatinamente puede marcarse con la clase class="incremental". La hoja de estilos y el script enlazado fueron desarrollados como una alternativa, basada en la Web, a las herramientas propietarias de presentación, y han sido probados en una variedad de navegadores recientes. Se está desarrollando un editor integrado. Envie sus comentarios, por favor, a Dave Raggett <dsr@w3.org>.

    + +

    Usted puede utilizar las hojas de estilo, scripts, y el fichero de ayuda; siempre que siga las normas de uso de documentos y licencia de software del W3C.

    + + + +
    + + + + diff --git a/slidy2/help/help.html.fr b/slidy2/help/help.html.fr new file mode 100644 index 0000000..daa7605 --- /dev/null +++ b/slidy2/help/help.html.fr @@ -0,0 +1,118 @@ + + + + + + Aide de Slide Show + + + + + +

    Aide de Slide Show

    + + + +

    Cet exposé Slide Show peut être utilisé de la même manière que Powerpoint. + +Pour avancer au prochain transparent, cliquez n'importe où sur la page avec la +souris ou appuyez sur la barre d'espace. Vous pouvez naviguer entre +les transparents avec les flèches gauche/droite ainsi que les touches Pg Up et +Pg Dn. + +La taille de la police s'adapte automatiquement à la largeur de la fenêtre +du navigateur, mais vous pouvez aussi l'ajuster manuellement en utilisant les +touches "S" (small) pour la diminuer et "B" (big) pour l'augmenter. Vous +pouvez aussi utiliser les touches "<" et ">". + +Utilisez la touche "F" pour afficher ou non le statut en pied-de-page. + +La touche "K" active l'utilisation du clic de souris pour avancer au prochain transparent. +Vous pouvez utiliser "T" pour afficher la table des matières et n'importe quelle autre touche +pour la cacher. + +Les utilisateurs de Windows peuvent utiliser la touche "F11" pour activer le mode plein écran +du navigateur. Appuyez sur la touche "H" pour obtenir cette page. À noter que certaines touches +peuvent ne pas fonctionner avec certains navigateurs car elles sont réservées pour son contrôle. +De plus, cela peut varier d'un navigateur à l'autre.

    + +

    Les utilisateurs de Firefox peuvent installer l'extension autohide +pour cacher les barres d'outils lorsque le mode plein écran est activé +avec la touche F11.

    + +

    Si vous voulez voir comment Slidy fonctionne, affichez le code source de la page +pour voir le balisage XHTML, ou lisez cette explication plus complète (en anglais), +qui explique aussi des fonctionnalités additionnelles. + +Chaque transparent est balisé par un élément div avec l'attribut class="slide". +Il est aussi possible d'utiliser le positionnement CSS ainsi que la largeur en pourcentage +pour s'assurer que vos images soient à l'échelle du transparent et correspondent ainsi à la taille +de la fenêtre. Le contenu devant s'afficher progressivement doit être marqué par l'attribut + class="incremental". + +La feuille de style reliée ainsi que les scripts ont été développés comme alternative Web +aux outils de présentation propriétaires et ont été testés sur un large panel de navigateurs récents. +Le support intégré pour l'édition est en cours de développement. Envoyez vos commentaires +(en anglais) à Dave +Raggett <dsr@w3.org>. +Si vous trouvez Slidy utile, vous pouvez également devenir +Supporter du W3C.

    + + + +

    Veuillez utilisez les feuilles de style, scripts et fichiers d'aide + +en suivant le copyright + +et la licence du W3C.

    + + + + + + + +
    + + + + + + + diff --git a/slidy2/help/help.html.hu b/slidy2/help/help.html.hu new file mode 100644 index 0000000..64eb205 --- /dev/null +++ b/slidy2/help/help.html.hu @@ -0,0 +1,98 @@ + + + + + + Segítség a bemutatóhoz + + + + + + + +

    Segítség a bemutatóhoz

    + +

    Ezt a bemutatót a Power Point-hoz hasonlóan lehet vezérelni. + A következő oldalra való lépéshez kattintson bárhova az aktuális + oldalon belül, vagy nyomja le a szóköz billentyűt. Az oldalak között + a bal és jobb nyíl, illetve a Page Up és Page Down billentyűkkel mozoghat. + A szöveg mérete automatikusan kerül beállításra úgy, hogy igazodjon + a böngésző ablakának szélességéhez, viszont az "S" billentyűvel + csökkentheti, a "B"-vel növelheti azt. Ugyanerre használhatja a "<" + és a ">" billentyűket is. + Az "F" billentyűvel be- és + kikapcsolhatja az alsó állapotsor megjelenítését. A "K" billentyűvel + letilthatja, illetve engedélyezheti, hogy egérkattintással a következő + oldalra lehessen lépni. A "C" billentyűvel megjelenítheti, bármely másikkal + pedig eltűntetheti a tartalomjegyzéket. Az "F11" billenytűvel válthat át + a böngésző teljes képernyős üzemmódjára, vagy jöhet onnan vissza. + Megjegyezzük, hogy nem minden billentyű támogatott minden böngészőben, + mivel a böngészők lefoglalhatnak néhány (böngészőnként eltérő) billentyűt + a saját vezérlésükre. +

    + +

    A Firefox felhasználóknak hasznos lehet az + autohide + bővítmény, amivel elrejthetők az eszköztárak teljes képernyős üzemmódban. +

    + +

    Ha szeretné látni, hogyan működik a Slidy, nézze meg az oldal + forrásában az XHTML jelölésmódot, vagy nézze meg ezt a + hosszabb magyarázatot, + ami további funkciókat is bemutat. Minden oldalt egy olyan div elem jelöl, + amiben be van állítva, hogy class="slide". A képek CSS-sel történő + pozicionálása és szélességüknek százalékban való megadása biztosítja, + hogy a sok képet tartalmazó oldalak az ablak méretének megfelelően + skálázódjanak. Az oldalon belül egymás után megjelenítendő tartalom a + class="incremental" megadásával jelölhető. A becsatolt stíluslapok és + scriptek a védjegyzett/szabadalmaztatott/más módon védett + bemutató-megjelenítő eszközök web-alapú alternatívájaként lettek + fejlesztve, és sok, manapság használatos böngészővel tesztelve. + Az integrált szerkesztési lehetőség jelenleg fejlesztés alatt áll. + Észrevételeit a következő helyre küldje: + Dave Raggett + <dsr@w3.org>. +

    + +

    + Ön jogosult az e bemutatóhoz tartozó stíluslapok, scriptek és + segítség fájl használatára, amennyiben betartja a W3C + + dokumentum használati és + + szoftver licencelési szabályait. + +

    + + + +
    + + + + diff --git a/slidy2/help/help.html.nl b/slidy2/help/help.html.nl new file mode 100644 index 0000000..b2e9043 --- /dev/null +++ b/slidy2/help/help.html.nl @@ -0,0 +1,82 @@ + + + + + + + Slidy Help + + + + +

    Slidy Help

    + + + +

    Deze sheetpresentatie kan op dezelfde manier worden aangestuurd als +Powerpoint. Klik op een willekeurige plaats op de pagina met de muis, of +druk op de spatiebalk om naar de volgende sheet te gaan. Je kan voor- of +achterwaarts door de sheets bewegen mbv de links/rechts cursor- en de Page +Up en Page Down toetsen. De lettergrootte wordt automatisch aangepast aan +de breedte van het venster, maar je kunt 'm ook handmatig aanpassen met +"S" en "<" voor kleiner en "B" en ">" voor groter. Gebruik de +"F" om de status aan de onderkant aan/uit te schakelen. De "K" zorgt +ervoor dat een muisklik je niet meer, of wel weer naar de volgende sheet +brengt. Je kan de "C" gebruiken om het inhoudsoverzicht op te roepen, en +een willekeurige andere toets om 'm weer te verbergen. Gebruik "F11" om de +"volledig scherm" modus aan /uit te schakelen. Merk op dat niet alle +toetsen in iedere browser worden ondersteund, omdat sommige browsers +toetsen gebruiken voor besturing van de browser zelf. Dit varieert zelfs +tussen versies van dezelfde browser.

    + +

    Firefox gebruikers willen wellicht de "autohide" extension gebruiken om +werkbalken te verbergen wanneer "volledig scherm" wordt aangeroepen met +"F11".

    + +

    Als u wilt zien hoe Slidy werkt, gebruik Bron Bekijken om de XHTML opmaak +te bekijken, of bekijk deze langere uitleg, die ook extra functionaliteit +uitlegt. Elke sheet is in de opmaak genoteerd als een div element met +class="slide". CSS positionering and procentuele breedtes op afbeeldingen +kunnen worden gebruikt om te verzekeren dat uw afbeeldingrijke sheets +schalen naar de vensterbreedte. Inhoud kan stapsgewijs zichtbaar worden +gemaakt met behulp van class="incremental". Het gelinkte stijlblad en de +gelinkte scripts zijn ontwikkeld als een Web-gebaseerd alternatief voor +gesloten presentatie programma's en zijn getest op een variëteit van +recente browsers. Geintegreerde ondersteuning voor (inhoud)aanpassing +wordt ontwikkeld. Zend uw opmerkingen aub naar Dave Raggett <dsr@w3.org> +Als u Slidy bruikbaar vindt, wilt u wellicht overwegen W3C donateur te +worden.

    + +

    U bent welkom om gebruik te maken van de stijlbladen, scripts en dit +helpbestand onder de regels van W3C's document use (document gebruik) en +software licensing (software licenties)

    + + + + +
    + + + + diff --git a/slidy2/help/help.html.pl b/slidy2/help/help.html.pl new file mode 100644 index 0000000..2eb6ca4 --- /dev/null +++ b/slidy2/help/help.html.pl @@ -0,0 +1,76 @@ + + + + + + + Slidy - pomoc + + + + +

    Slidy - pomoc

    + +

    Prezentacją steruje się tak samo, jak w Powerpoincie. +Aby przejść do następnego slajdu, kliknij w dowolnym miejscu prezentacji myszą +lub naciśnij spację. Możesz też poruszać się w przód / tył używając klawiszy +kursora (lewo / prawo) lub klawiszy Pg Up / Pg Dn. Rozmiar czcionki jest +dobierany automatycznie tak, żeby mieścił się w obszarze przeglądarki, +ale możesz także dostosować go ręcznie naciskając klawisze "S", aby pomniejszyć +tekst i "B", aby go powiększyć. Możesz do tego celu także użyć klawiszy "<" + i ">". Użyj klawisza "F" aby + ukryć / pokazać dolny pasek statusu. Klawisz "K" włącza / wyłącza tryb przechodzenia + do następnego slajdu po kliknięciu myszką. Możesz użyć klawisza "C", żeby pokazać + spis treści i dowolnego innego, żeby go ukryć. Klawisz +"F11" włącza tryb pełnoekranowy przeglądarki. Pamiętaj, że nie wszystkie klawisze +są obsługiwane we wszystkich przeglądarkach, gdyż niektóre z nich rezerwują +konkretne klawisze do własnych celów, wszystko to zależy od używanej przeglądarki.

    + +

    Jeśli używasz Firefoxa, zwróć uwagę na rozszerzenie autohide, dzięki któremu +możesz ukryć paski narzędziowe w trybie pełnoekranowym (F11).

    + +

    Jeśli chcesz dowiedzieć się, w jaki sposób działa Slidy, obejrzyj źródło strony prezentacji, żeby +zobaczyć użyty XHTML lub zapoznaj się z prezentacją działania, która omawia +wszystkie dodatkowe funkcje. Każdy slajd jest reprezentowany przez element div o klasie "slide". +Pozycjonowanie CSS i użycie procentowych szerokości obrazków zapewni, że +Twoje slajdy będą poprawnie wyświetlane w każdej skali. +Zawartości slajdu, które mają być stopniowo odsłaniane oznacz klasą "incremental". +Powiązany arkusz stylów CSS i skrypt zostały stworzone jako sieciowa +alternatywa dla komercyjnych narzędzi prezentacyjnych. Całość została +przetestowana na różnorodnych współczesnych przeglądarkach. +Na etapie tworzenia jest aplikacja do zintegrowanego tworzenia i edycji prezentacji. +Wszystkie komentarze prosimy kierować do Dave'a +Raggetta <dsr@w3.org>.

    + +

    Zachęcamy do używania arkuszy stylów, skryptów i pliku pomocy na warunkach licencyjnych dotyczących dokumentów +i oprogramowania W3C

    + + + +
    + + + diff --git a/slidy2/help/help.html.pt-br b/slidy2/help/help.html.pt-br new file mode 100644 index 0000000..c2aee81 --- /dev/null +++ b/slidy2/help/help.html.pt-br @@ -0,0 +1,95 @@ + + + + + Slide Show Help + + + +

    Ajuda do Slide Show

    + +

    Este slide show pode ser tocado do jeito do Power Point. +Para avançar ao próximo eslaide, clique em qualquer ponto +da página com o botão direito do mouse. Ou então use a +barra de espaços. Também se pode movimentar para frente ou +para trás com as teclas do cursor -- setinhas para a +direita, para a esquerda, para cima e para baixo. E ainda +com as teclas Page Up e Page Down. O tamanho da fonte é +automaticamente ajustado à largura da janela do navegador, +mas esse ajuste pode ser manual, usando as teclas "S" +(de "smaller") para diminuir o tamanho, e "B" (de "bigger") +para aumentar. Igualmente se pode usar as teclas "<" e +">". Use +a tecla "F" para alternar entre desativada e ativada a +linha de status no rodapé. A tecla "K" alterna o uso do +clique do mouse para avançar ao próximo eslaide. A tecla +"C" mostra a tabela de conteúdos, que será novamente +ocultada apertando-se qualquer tecla. Use a tecla "F11" +para alternar o modo de tela cheia do navegador. Aperte +"H" (de "Help") para abrir esta página de Ajuda. Note que +alguns navegadores reservam algumas dessas teclas para +outras funções. Assim, experimente no seu navegador para +ver se esse é o seu caso.

    + +

    Usuários do Firefox podem querer a extensão autoocultar +para esconder as barras de ferramentas quando entrarem em tela cheia +com a tecla F11.

    + +

    Se quiser ver como funciona o Slidy, use o View Source para +visualizar a marcação XHTML, ou leia esta explanação mais longa, +que também contém funcionalidades adicionais. Cada eslaide é +marcado como um div element com +classe="slide". Posicionamentos e larguras em porcentual de CSS +podem ser usados para assegurar que os eslaides com rica +ilustração tenham escalabilidade de acordo com o tamanho da janela. +Já o conteúdo a ser revelado incrementalmente pode receber a +marcação com a classe="incremental". +A folha de estilos vinculados e os scripts foram desenvolvidos +como uma alternativa baseada em web às ferramentas proprietárias +de apresentação, e testados em diversos navegadores recentes. +Suporte à edição integrada ainda está em desenvolvimento. Mande +seus comentários para Dave +Raggett <dsr@w3.org>. +Achando que o Slidy é útil, V. talvez possa considerar a +possibilidade de se tornar um +Apoiador do W3C.

    + +

    Fique à vontade para usar as folhas de estilo, os scripts +e o arquivo de ajuda do show de eslaides que se encontram sob as +regras de + +uso de documentação +e +licenciamento de softwaredo W3C -- Consórcio da World Wide +Web.

    + + + +
    + + + + diff --git a/slidy2/help/help.html.pt_br b/slidy2/help/help.html.pt_br new file mode 100644 index 0000000..c2aee81 --- /dev/null +++ b/slidy2/help/help.html.pt_br @@ -0,0 +1,95 @@ + + + + + Slide Show Help + + + +

    Ajuda do Slide Show

    + +

    Este slide show pode ser tocado do jeito do Power Point. +Para avançar ao próximo eslaide, clique em qualquer ponto +da página com o botão direito do mouse. Ou então use a +barra de espaços. Também se pode movimentar para frente ou +para trás com as teclas do cursor -- setinhas para a +direita, para a esquerda, para cima e para baixo. E ainda +com as teclas Page Up e Page Down. O tamanho da fonte é +automaticamente ajustado à largura da janela do navegador, +mas esse ajuste pode ser manual, usando as teclas "S" +(de "smaller") para diminuir o tamanho, e "B" (de "bigger") +para aumentar. Igualmente se pode usar as teclas "<" e +">". Use +a tecla "F" para alternar entre desativada e ativada a +linha de status no rodapé. A tecla "K" alterna o uso do +clique do mouse para avançar ao próximo eslaide. A tecla +"C" mostra a tabela de conteúdos, que será novamente +ocultada apertando-se qualquer tecla. Use a tecla "F11" +para alternar o modo de tela cheia do navegador. Aperte +"H" (de "Help") para abrir esta página de Ajuda. Note que +alguns navegadores reservam algumas dessas teclas para +outras funções. Assim, experimente no seu navegador para +ver se esse é o seu caso.

    + +

    Usuários do Firefox podem querer a extensão autoocultar +para esconder as barras de ferramentas quando entrarem em tela cheia +com a tecla F11.

    + +

    Se quiser ver como funciona o Slidy, use o View Source para +visualizar a marcação XHTML, ou leia esta explanação mais longa, +que também contém funcionalidades adicionais. Cada eslaide é +marcado como um div element com +classe="slide". Posicionamentos e larguras em porcentual de CSS +podem ser usados para assegurar que os eslaides com rica +ilustração tenham escalabilidade de acordo com o tamanho da janela. +Já o conteúdo a ser revelado incrementalmente pode receber a +marcação com a classe="incremental". +A folha de estilos vinculados e os scripts foram desenvolvidos +como uma alternativa baseada em web às ferramentas proprietárias +de apresentação, e testados em diversos navegadores recentes. +Suporte à edição integrada ainda está em desenvolvimento. Mande +seus comentários para Dave +Raggett <dsr@w3.org>. +Achando que o Slidy é útil, V. talvez possa considerar a +possibilidade de se tornar um +Apoiador do W3C.

    + +

    Fique à vontade para usar as folhas de estilo, os scripts +e o arquivo de ajuda do show de eslaides que se encontram sob as +regras de + +uso de documentação +e +licenciamento de softwaredo W3C -- Consórcio da World Wide +Web.

    + + + +
    + + + + diff --git a/slidy2/help/help.html.sv b/slidy2/help/help.html.sv new file mode 100644 index 0000000..3d019a7 --- /dev/null +++ b/slidy2/help/help.html.sv @@ -0,0 +1,75 @@ + + + + + + + + Hjälpsida för presentationer + + +

    Hjälpsida för presentationer

    + +

    Denna presentation kan användas på liknande sätt som Power Point. +För att bläddra till nästa sida går det att trycka på mellanslagstangenten eller klicka med musens +västra knapp så gott som var som helst på sidan. Bläddra framåt och +bakåt med höger- respektive vänsterpiltangenterna eller tangenterna »Pg Dn» respektive +»Pg Up». Textens storlek anpassas automatiskt efter webbläsarens +fönsterbredd, men den går även att justera manuellt med +tangenterna »S» och »B» för att förminska respektive förstora texten. Alternativt kan +tangenterna »<» respektive »>» användas. Tangenten +»F» används för att visa / dölja statusraden längst ner i fönstret. Tangenten »K» +kopplar på / av möjligheten att klicka med musen för att bläddra till nästa sida. Tangenten +»C» används för att visa innehållsförteckningen och en tryckning på vilken annan tangent som +helst döljer den. En tryckning på tangenten »H» visar denna hjälpsida. Tangenten »F11» +växlar mellan fullskärmsvisning och visning i webbläsarens fönster. Observera att vissa webbläsare kan +ha reserverat några av dessa tangenttryckningar för andra funktioner; detta varierar mellan olika webbläsare.

    + +

    Firefoxanvändare kan vid behov installera autohide +för att verktygsfälten skall döljas vid övergång till fullskärmsvisning med F11.

    + +

    För att se hur Slidy fungerar, titta på XHTML-koden genom att välja »Visa +källa» (eller liknande) i webbläsarens meny eller läs följande längre +beskrivning, där även ytterligare finesser beskrivs. Varje sida är markerad som +div-element med attributet class="slide". CSS-positionering och procentuell bredd +kan användas för att placera bilderna i rätt skala i förhållande till +webbläsarens fönsterstorlek. Det som skall visas inkrementiellt +markeras med class="incremental". Länkar hänvisar till några skript och stilmallar +som har testats med en mängd nutida webbläsare och bildar ett webbaserat alternativ till proprietära +presentationsprogram. Stöd för integrerad editering håller på att utvecklas. Skicka gärna +kommentarer till Dave +Raggett <dsr@w3.org>. +Om du finner Slidy användbar kan du överväga att bli +W3C Supporter.

    + +

    Välkommen att använda presentationens stilmallar, skript och hjälpfiler enligt reglerna +för W3C:s document use +och software +licensing!

    + + + +
    + + + diff --git a/slidy2/help/help.pt-br.html b/slidy2/help/help.pt-br.html new file mode 100644 index 0000000..72d9891 --- /dev/null +++ b/slidy2/help/help.pt-br.html @@ -0,0 +1,95 @@ + + + + + Slide Show Help + + + +

    Ajuda do Slide Show

    + +

    Este slide show pode ser tocado do jeito do Power Point. +Para avançar ao próximo eslaide, clique em qualquer ponto +da página com o botão direito do mouse. Ou então use a +barra de espaços. Também se pode movimentar para frente ou +para trás com as teclas do cursor -- setinhas para a +direita, para a esquerda, para cima e para baixo. E ainda +com as teclas Page Up e Page Down. O tamanho da fonte é +automaticamente ajustado à largura da janela do navegador, +mas esse ajuste pode ser manual, usando as teclas "S" +(de "smaller") para diminuir o tamanho, e "B" (de "bigger") +para aumentar. Igualmente se pode usar as teclas "<" e +">". Use +a tecla "F" para alternar entre desativada e ativada a +linha de status no rodapé. A tecla "K" alterna o uso do +clique do mouse para avançar ao próximo eslaide. A tecla +"C" mostra a tabela de conteúdos, que será novamente +ocultada apertando-se qualquer tecla. Use a tecla "F11" +para alternar o modo de tela cheia do navegador. Aperte +"H" (de "Help") para abrir esta página de Ajuda. Note que +alguns navegadores reservam algumas dessas teclas para +outras funções. Assim, experimente no seu navegador para +ver se esse é o seu caso.

    + +

    Usuários do Firefox podem querer a extensão autoocultar +para esconder as barras de ferramentas quando entrarem em tela cheia +com a tecla F11.

    + +

    Se quiser ver como funciona o Slidy, use o View Source para +visualizar a marcação XHTML, ou leia esta explanação mais longa, +que também contém funcionalidades adicionais. Cada eslaide é +marcado como um div element com +classe="slide". Posicionamentos e larguras em porcentual de CSS +podem ser usados para assegurar que os eslaides com rica +ilustração tenham escalabilidade de acordo com o tamanho da janela. +Já o conteúdo a ser revelado incrementalmente pode receber a +marcação com a classe="incremental". +A folha de estilos vinculados e os scripts foram desenvolvidos +como uma alternativa baseada em web às ferramentas proprietárias +de apresentação, e testados em diversos navegadores recentes. +Suporte à edição integrada ainda está em desenvolvimento. Mande +seus comentários para Dave +Raggett <dsr@w3.org>. +Achando que o Slidy é útil, V. talvez possa considerar a +possibilidade de se tornar um +Apoiador do W3C.

    + +

    Fique à vontade para usar as folhas de estilo, os scripts +e o arquivo de ajuda do show de eslaides que se encontram sob as +regras de + +uso de documentação +e +licenciamento de softwaredo W3C -- Consórcio da World Wide +Web.

    + + + +
    + + + + diff --git a/slidy2/scripts/.htaccess b/slidy2/scripts/.htaccess new file mode 100644 index 0000000..d395348 --- /dev/null +++ b/slidy2/scripts/.htaccess @@ -0,0 +1,28 @@ +Options +MultiViews +LanguagePriority en +AddLanguage pt-br .pt-br + + + +ForceType 'text/html; charset=utf-8' + + + + + +ForceType 'application/xhtml+xml; charset=utf-8' + + + + + +ForceType 'text/css; charset=utf-8' + + + + + +ForceType 'text/javascript; charset=utf-8' + + +mkdir diff --git a/slidy2/scripts/img.srcset.js b/slidy2/scripts/img.srcset.js new file mode 100644 index 0000000..b83e5ac --- /dev/null +++ b/slidy2/scripts/img.srcset.js @@ -0,0 +1,153 @@ +/* imgsrcset - Img srcset polyfill for resolution responsive images. Authors & copyright (c) 2012: WebLinc, David Knight. */ + +// Imgsrcset +(function(win) { + 'use strict'; + + var _viewport = win.document.documentElement, + _srcsetID = 0, + _srcsets = [], + _eventPrefix = '', + _addEvent = win.addEventListener || (_eventPrefix = 'on') && win.attachEvent, + _removeEvent = win.removeEventListener || win.detachEvent, + _srcExpr = /[^\s]+/g, + _digitExpr = /[0-9\.]+/g, + _timer = 0, + + /* + _matches + */ + _matches = function(srcset) { + var srcList = (srcset.indexOf(',') !== -1 && srcset.split(',')) || [srcset], + srcIndex = srcList.length - 1, + srcLength = srcIndex, + + list = null, + listIndex = 0, + + src = '', + media = ''; + + if (srcIndex < 0) { + return; + } + + do { + var list = srcList[srcLength - srcIndex].match(_srcExpr) || [], + listIndex = list.length; + + while (listIndex--) { + var item = list[listIndex], + feature = 0, + digits = 0; + + if (listIndex > 0) { + feature = (item.indexOf('w') !== -1 && (win.innerWidth || _viewport.clientWidth)) || + (item.indexOf('h') !== -1 && (win.innerHeight || _viewport.clientHeight)) || + (item.indexOf('x') !== -1 && (win.devicePixelRatio || 1)); + + digits = Number(item.match(_digitExpr)); + + if (feature && digits && digits > feature) { + break; + } + } else { + src = item; + media = srcList[srcIndex]; + } + } + } while (srcIndex--); + + return (src && media && {src: src, media: media}) || false; + }, + + /* + watch + */ + _watch = function(evt) { + clearTimeout(_timer); + + _timer = setTimeout(function() { + var srcset = null, + srcsetIndex = _srcsetID - 1, + srcsetLength = srcsetIndex, + match = false; + + do { + srcset = _srcsets[srcsetLength - srcsetIndex]; + + // If img element does not have a parent, remove array index to prevent caching + if (!srcset.element.parentNode) { + _srcsetID--; + srcset.splice(srcsetIndex, 1); + continue; + } + + match = _matches(srcset.media); + + if (match && (srcset.matches !== match.media)) { + srcset.matches = match.media; + + srcset.element.src = match.src; + } else if (!match) { + srcset.matches = false; + srcset.src && (srcset.element.src = srcset.src); + } + } while(srcsetIndex--); + }, 10); + }, + + /* + init + */ + _init = function() { + _removeEvent(_eventPrefix + 'load', _init); + + win.Imgsrcset.parse(); + _watch(); + + // Processes '_srcsets' array and determines which source to use + // '_watch' will clear out any images from the array that do not have parents, which should eliminate element caching + _addEvent(_eventPrefix + 'resize', _watch); + _addEvent(_eventPrefix + 'orientationchange', _watch); + }; + + /* + imgsrcset + */ + win.Imgsrcset = { + /* + parse + + Called on '_init' and can also be called if new images are added/removed + */ + parse: function() { + _srcsets = []; + + var imgs = win.document.getElementsByTagName('img') || [], + imgIndex = imgs.length - 1, + imgLength = imgIndex, + img = null, + srcset = ''; + + do { + img = imgs[imgLength - imgIndex]; + srcset = img.getAttribute('srcset') || ''; + + if (!srcset) { + continue; + } + + _srcsetID = _srcsets.push({ + element : img, + media : srcset, + matches : false, + src : img.getAttribute('src') || '' + }); + } while(imgIndex--); + } + }; + + // Set up listeners + _addEvent(_eventPrefix + 'load', _init); +})(window); diff --git a/slidy2/scripts/slidy.js b/slidy2/scripts/slidy.js new file mode 100644 index 0000000..d6bc96c --- /dev/null +++ b/slidy2/scripts/slidy.js @@ -0,0 +1,2944 @@ +/* slidy.js + + Copyright (c) 2005-2011 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software + + Defines single name "w3c_slidy" in global namespace + Adds event handlers without trampling on any others +*/ + +function copyToClipboard(element) { + var doc = document + , text = doc.getElementById(element) + , range, selection; + if (doc.body.createTextRange) { + range = document.body.createTextRange(); + range.moveToElementText(text); + range.select(); + } else if (window.getSelection) { + selection = window.getSelection(); + range = document.createRange(); + range.selectNodeContents(text); + selection.removeAllRanges(); + selection.addRange(range); + } +} + +/* +function copyToClipboard(elementId) { + // create a "hidden" input + var aux = document.createElement("input"); + + // this part is not really needed anymore and could be removed + aux.setAttribute("type", "text"); + aux.setAttribute("id", "temp"); + aux.setAttribute("style", "position:absolute;opacity:0;"); + + // assign it the value of the specified element + var c = document.getElementById(elementId).innerHTML. + replace(">", ">"). + replace("<", "<"). + replace("&", "&"). + replace(/<\/span>(\s\s+)/gi, "\n$1"). + replace(/<\/?span.*?>/gi, ""); + // replace(/\<br\>/gi,"\n").replace(/(<([^>]+)>)/gi, ""); + + document.getElementById(elementId).select(); + aux.setAttribute("value", c); + + // append it to the body + document.body.appendChild(aux); + + // highlight its content + aux.select(); + + // copy the highlighted text + document.execCommand("copy"); + + // remove it from the body + document.body.removeChild(aux); +} */ + +// the slidy object implementation +var w3c_slidy = { + // classify which kind of browser we're running under + ns_pos: (typeof window.pageYOffset!='undefined'), + khtml: ((navigator.userAgent).indexOf("KHTML") >= 0 ? true : false), + opera: ((navigator.userAgent).indexOf("Opera") >= 0 ? true : false), + ipad: ((navigator.userAgent).indexOf("iPad") >= 0 ? true : false), + iphone: ((navigator.userAgent).indexOf("iPhone") >= 0 ? true : false), + android: ((navigator.userAgent).indexOf("Android") >= 0 ? true : false), + ie: (typeof document.all != "undefined" && !this.opera), + ie6: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 6") != -1), + ie7: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 7") != -1), + ie8: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 8") != -1), + ie9: (!this.ns_pos && navigator.userAgent.indexOf("MSIE 9") != -1), + + // data for swipe and double tap detection on touch screens + last_tap: 0, + prev_tap: 0, + start_x: 0, + start_y: 0, + delta_x: 0, + delta_y: 0, + + // are we running as XHTML? (doesn't work on Opera) + is_xhtml: /xml/.test(document.contentType), + + slide_number: 0, // integer slide count: 0, 1, 2, ... + slide_number_element: null, // element containing slide number + slides: [], // set to array of slide div's + notes: [], // set to array of handout div's + backgrounds: [], // set to array of background div's + toolbar: null, // element containing toolbar + title: null, // document title + last_shown: null, // last incrementally shown item + eos: null, // span element for end of slide indicator + toc: null, // table of contents + outline: null, // outline element with the focus + selected_text_len: 0, // length of drag selection on document + view_all: 0, // 1 to view all slides + handouts + want_toolbar: true, // user preference to show/hide toolbar + mouse_click_enabled: false, // enables left click for next slide + scroll_hack: 0, // IE work around for position: fixed + disable_slide_click: false, // used by clicked anchors + + lang: "en", // updated to language specified by html file + + help_anchor: null, // used for keyboard focus hack in showToolbar() + help_page: "http://www.w3.org/Talks/Tools/Slidy2/help/help.html", + help_text: "Navigate with mouse click, space bar, Cursor Left/Right, " + + "or Pg Up and Pg Dn. Use S and B to change font size.", + + size_index: 0, + size_adjustment: 0, + sizes: new Array("10pt", "12pt", "14pt", "16pt", "18pt", "20pt", + "22pt", "24pt", "26pt", "28pt", "30pt", "32pt"), + + // needed for efficient resizing + last_width: 0, + last_height: 0, + + + // Needed for cross browser support for relative width/height on + // object elements. The work around is to save width/height attributes + // and then to recompute absolute width/height dimensions on resizing + objects: [], + + // attach initialiation event handlers + set_up: function () { + var init = function() { w3c_slidy.init(); }; + if (typeof window.addEventListener != "undefined") + window.addEventListener("load", init, false); + else + window.attachEvent("onload", init); + }, + + hide_slides: function () { + if (document.body && !w3c_slidy.initialized) + document.body.style.visibility = "hidden"; + else + setTimeout(w3c_slidy.hide_slides, 50); + }, + + // hack to persuade IE to compute correct document height + // as needed for simulating fixed positioning of toolbar + ie_hack: function () { + window.resizeBy(0,-1); + window.resizeBy(0, 1); + }, + + init: function () { + //alert("slidy starting test 10"); + document.body.style.visibility = "visible"; + this.init_localization(); + this.add_toolbar(); + this.wrap_implicit_slides(); + this.collect_slides(); + this.collect_notes(); + this.collect_backgrounds(); + this.objects = document.body.getElementsByTagName("object"); + this.patch_anchors(); + this.slide_number = this.find_slide_number(location.href); + window.offscreenbuffering = true; + this.size_adjustment = this.find_size_adjust(); + this.time_left = this.find_duration(); + this.hide_image_toolbar(); // suppress IE image toolbar popup + this.init_outliner(); // activate fold/unfold support + this.title = document.title; + this.keyboardless = (this.ipad||this.iphone||this.android); + + if (this.keyboardless) + { + w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden") + this.want_toolbar = 0; + } + + // work around for opera bug + this.is_xhtml = (document.body.tagName == "BODY" ? false : true); + + if (this.slides.length > 0) + { + var slide = this.slides[this.slide_number]; + + if (this.slide_number > 0) + { + this.set_visibility_all_incremental("visible"); + this.last_shown = this.previous_incremental_item(null); + this.set_eos_status(true); + } + else + { + this.last_shown = null; + this.set_visibility_all_incremental("hidden"); + this.set_eos_status(!this.next_incremental_item(this.last_shown)); + } + + this.set_location(); + this.add_class(this.slides[0], "first-slide"); + w3c_slidy.show_slide(slide); + } + + this.toc = this.table_of_contents(); + + this.add_initial_prompt(); + + // bind event handlers without interfering with custom page scripts + // Tap events behave too weirdly to support clicks reliably on + // iPhone and iPad, so exclude these from click handler + + if (!this.keyboardless) + { + //this.add_listener(document.body, "click", this.mouse_button_click); + this.add_listener(document.body, "mousedown", this.mouse_button_down); + } + + this.add_listener(document, "keydown", this.key_down); + this.add_listener(document, "keypress", this.key_press); + this.add_listener(window, "resize", this.resized); + this.add_listener(window, "scroll", this.scrolled); + this.add_listener(window, "unload", this.unloaded); + + this.add_listener(document, "touchstart", this.touchstart); + this.add_listener(document, "touchmove", this.touchmove); + this.add_listener(document, "touchend", this.touchend); + + // this seems to be a debugging hack + //if (!document.body.onclick) + // document.body.onclick = function () { }; + + this.single_slide_view(); + + //this.set_location(); + + this.resized(); + + if (this.ie7) + setTimeout(w3c_slidy.ie_hack, 100); + + this.show_toolbar(); + + // for back button detection + setInterval(function () { w3c_slidy.check_location(); }, 200); + w3c_slidy.initialized = true; + }, + + // create div element with links to each slide + table_of_contents: function () { + var toc = this.create_element("div"); + this.add_class(toc, "slidy_toc hidden"); + //toc.setAttribute("tabindex", "0"); + + var heading = this.create_element("div"); + this.add_class(heading, "toc-heading"); + heading.innerHTML = this.localize("Table of Contents"); + + toc.appendChild(heading); + var previous = null; + + for (var i = 0; i < this.slides.length; ++i) + { + var title = this.has_class(this.slides[i], "title"); + var num = document.createTextNode((i + 1) + ". "); + + toc.appendChild(num); + + var a = this.create_element("a"); + a.setAttribute("href", "#(" + (i+1) + ")"); + + if (title) + this.add_class(a, "titleslide"); + + var name = document.createTextNode(this.slide_name(i)); + a.appendChild(name); + a.onclick = w3c_slidy.toc_click; + a.onkeydown = w3c_slidy.toc_key_down; + a.previous = previous; + + if (previous) + previous.next = a; + + toc.appendChild(a); + + if (i == 0) + toc.first = a; + + if (i < this.slides.length - 1) + { + var br = this.create_element("br"); + toc.appendChild(br); + } + + previous = a; + } + + toc.focus = function () { + if (this.first) + this.first.focus(); + } + + toc.onmouseup = w3c_slidy.mouse_button_up; + + toc.onclick = function (e) { + e||(e=window.event); + + if (w3c_slidy.selected_text_len <= 0) + w3c_slidy.hide_table_of_contents(true); + + w3c_slidy.stop_propagation(e); + + if (e.cancel != undefined) + e.cancel = true; + + if (e.returnValue != undefined) + e.returnValue = false; + + return false; + }; + + document.body.insertBefore(toc, document.body.firstChild); + return toc; + }, + + is_shown_toc: function () { + return !w3c_slidy.has_class(w3c_slidy.toc, "hidden"); + }, + + show_table_of_contents: function () { + w3c_slidy.remove_class(w3c_slidy.toc, "hidden"); + var toc = w3c_slidy.toc; + toc.focus(); + + if (w3c_slidy.ie7 && w3c_slidy.slide_number == 0) + setTimeout(w3c_slidy.ie_hack, 100); + }, + + hide_table_of_contents: function (focus) { + w3c_slidy.add_class(w3c_slidy.toc, "hidden"); + + if (focus && !w3c_slidy.opera && + !w3c_slidy.has_class(w3c_slidy.toc, "hidden")) + w3c_slidy.help_anchor.focus(); + }, + + toggle_table_of_contents: function () { + if (w3c_slidy.is_shown_toc()) + w3c_slidy.hide_table_of_contents(true); + else + w3c_slidy.show_table_of_contents(); + }, + + // called on clicking toc entry + toc_click: function (e) { + if (!e) + e = window.event; + + var target = w3c_slidy.get_target(e); + + if (target && target.nodeType == 1) + { + var uri = target.getAttribute("href"); + + if (uri) + { + //alert("going to " + uri); + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri); + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.last_shown = null; + w3c_slidy.set_location(); + w3c_slidy.set_visibility_all_incremental("hidden"); + w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown)); + w3c_slidy.show_slide(slide); + //target.focus(); + + try + { + if (!w3c_slidy.opera) + w3c_slidy.help_anchor.focus(); + } + catch (e) + { + } + } + } + + w3c_slidy.hide_table_of_contents(true); + if (w3c_slidy.ie7) w3c_slidy.ie_hack(); + w3c_slidy.stop_propagation(e); + return w3c_slidy.cancel(e); + }, + + // called onkeydown for toc entry + toc_key_down: function (event) { + var key; + + if (!event) + var event = window.event; + + // kludge around NS/IE differences + if (window.event) + key = window.event.keyCode; + else if (event.which) + key = event.which; + else + return true; // Yikes! unknown browser + + // ignore event if key value is zero + // as for alt on Opera and Konqueror + if (!key) + return true; + + // check for concurrent control/command/alt key + // but are these only present on mouse events? + + if (event.ctrlKey || event.altKey) + return true; + + if (key == 13) + { + var uri = this.getAttribute("href"); + + if (uri) + { + //alert("going to " + uri); + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.slide_number = w3c_slidy.find_slide_number(uri); + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.last_shown = null; + w3c_slidy.set_location(); + w3c_slidy.set_visibility_all_incremental("hidden"); + w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown)); + w3c_slidy.show_slide(slide); + //target.focus(); + + try + { + if (!w3c_slidy.opera) + w3c_slidy.help_anchor.focus(); + } + catch (e) + { + } + } + + w3c_slidy.hide_table_of_contents(true); + + if (self.ie7) + w3c_slidy.ie_hack(); + + return w3c_slidy.cancel(event); + } + + if (key == 40 && this.next) + { + this.next.focus(); + return w3c_slidy.cancel(event); + } + + if (key == 38 && this.previous) + { + this.previous.focus(); + return w3c_slidy.cancel(event); + } + + return true; + }, + + touchstart: function (e) + { + //e.preventDefault(); + this.prev_tap = this.last_tap; + this.last_tap = (new Date).getTime(); + + var tap_delay = this.last_tap - this.prev_tap; + + if (tap_delay <= 200) + { + // double tap + } + + var touch = e.touches[0]; + + this.start_x = touch.pageX; + this.start_y = touch.pageY; + this.delta_x = this.delta_y = 0; + }, + + touchmove: function (e) + { + //e.preventDefault(); + var touch = e.touches[0]; + this.delta_x = touch.pageX - this.start_x; + this.delta_y = touch.pageY - this.start_y; + }, + + touchend: function (e) + { + //e.preventDefault(); + var delay = (new Date).getTime() - this.last_tap; + var dx = this.delta_x; + var dy = this.delta_y; + var abs_dx = Math.abs(dx); + var abs_dy = Math.abs(dy); + + if (delay < 500 && (abs_dx > 100 || abs_dy > 100)) + { + if (abs_dx > 0.5 * abs_dy) + { + if (dx < 0) + w3c_slidy.next_slide(true); + else + w3c_slidy.previous_slide(true); + } + else if (abs_dy > 2 * abs_dx) + { + w3c_slidy.toggle_table_of_contents(); + } + } + }, + + // ### OBSOLETE ### + before_print: function () { + this.show_all_slides(); + this.hide_toolbar(); + alert("before print"); + }, + + // ### OBSOLETE ### + after_print: function () { + if (!this.view_all) + { + this.single_slide_view(); + this.show_toolbar(); + } + alert("after print"); + }, + + // ### OBSOLETE ### + print_slides: function () { + this.before_print(); + window.print(); + this.after_print(); + }, + + // ### OBSOLETE ?? ### + toggle_view: function () { + if (this.view_all) + { + this.single_slide_view(); + this.show_toolbar(); + this.view_all = 0; + } + else + { + this.show_all_slides(); + this.hide_toolbar(); + this.view_all = 1; + } + }, + + // prepare for printing ### OBSOLETE ### + show_all_slides: function () { + this.remove_class(document.body, "single_slide"); + this.set_visibility_all_incremental("visible"); + }, + + // restore after printing ### OBSOLETE ### + single_slide_view: function () { + this.add_class(document.body, "single_slide"); + this.set_visibility_all_incremental("visible"); + this.last_shown = this.previous_incremental_item(null); + }, + + // suppress IE's image toolbar pop up + hide_image_toolbar: function () { + if (!this.ns_pos) + { + var images = document.getElementsByTagName("IMG"); + + for (var i = 0; i < images.length; ++i) + images[i].setAttribute("galleryimg", "no"); + } + }, + + unloaded: function (e) { + //alert("unloaded"); + }, + + // Safari and Konqueror don't yet support getComputedStyle() + // and they always reload page when location.href is updated + is_KHTML: function () { + var agent = navigator.userAgent; + return (agent.indexOf("KHTML") >= 0 ? true : false); + }, + + // find slide name from first h1 element + // default to document title + slide number + slide_name: function (index) { + var name = null; + var slide = this.slides[index]; + + var heading = this.find_heading(slide); + + if (heading) + name = this.extract_text(heading); + + if (!name) + name = this.title + "(" + (index + 1) + ")"; + + name.replace(/\&/g, "&"); + name.replace(/\/g, ">"); + + return name; + }, + + // find first h1 element in DOM tree + find_heading: function (node) { + if (!node || node.nodeType != 1) + return null; + + if (node.nodeName == "H1" || node.nodeName == "h1") + return node; + + var child = node.firstChild; + + while (child) + { + node = this.find_heading(child); + + if (node) + return node; + + child = child.nextSibling; + } + + return null; + }, + + // recursively extract text from DOM tree + extract_text: function (node) { + if (!node) + return ""; + + // text nodes + if (node.nodeType == 3) + return node.nodeValue; + + // elements + if (node.nodeType == 1) + { + node = node.firstChild; + var text = ""; + + while (node) + { + text = text + this.extract_text(node); + node = node.nextSibling; + } + + return text; + } + + return ""; + }, + + // find copyright text from meta element + find_copyright: function () { + var name, content; + var meta = document.getElementsByTagName("meta"); + + for (var i = 0; i < meta.length; ++i) + { + name = meta[i].getAttribute("name"); + content = meta[i].getAttribute("content"); + + if (name == "copyright") + return content; + } + + return null; + }, + + find_size_adjust: function () { + var name, content, offset; + var meta = document.getElementsByTagName("meta"); + + for (var i = 0; i < meta.length; ++i) + { + name = meta[i].getAttribute("name"); + content = meta[i].getAttribute("content"); + + if (name == "font-size-adjustment") + return 1 * content; + } + + return 1; + }, + + // for 20 minutes + find_duration: function () { + var name, content, offset; + var meta = document.getElementsByTagName("meta"); + + for (var i = 0; i < meta.length; ++i) + { + name = meta[i].getAttribute("name"); + content = meta[i].getAttribute("content"); + + if (name == "duration") + return 60000 * content; + } + + return null; + }, + + replace_by_non_breaking_space: function (str) { + for (var i = 0; i < str.length; ++i) + str[i] = 160; + }, + + // ### CHECK ME ### is use of "li" okay for text/html? + // for XHTML do we also need to specify namespace? + init_outliner: function () { + var items = document.getElementsByTagName("li"); + + for (var i = 0; i < items.length; ++i) + { + var target = items[i]; + + if (!this.has_class(target.parentNode, "outline")) + continue; + + // target.onclick = this.outline_click; +/* ### more work needed for IE6 + if (!this.ns_pos) + { + target.onmouseover = this.hover_outline; + target.onmouseout = this.unhover_outline; + } +*/ + if (this.foldable(target)) + { + target.foldable = true; + target.onfocus = function () {w3c_slidy.outline = this;}; + target.onblur = function () {w3c_slidy.outline = null;}; + + if (!target.getAttribute("tabindex")) + target.setAttribute("tabindex", "0"); + + if (this.has_class(target, "expand")) + this.unfold(target); + else + this.fold(target); + } + else + { + this.add_class(target, "nofold"); + target.visible = true; + target.foldable = false; + } + } + }, + + foldable: function (item) { + if (!item || item.nodeType != 1) + return false; + + var node = item.firstChild; + + while (node) + { + if (node.nodeType == 1 && this.is_block(node)) + return true; + + node = node.nextSibling; + } + + return false; + }, + + // ### CHECK ME ### switch to add/remove "hidden" class + fold: function (item) { + if (item) + { + this.remove_class(item, "unfolded"); + this.add_class(item, "folded"); + } + + var node = item ? item.firstChild : null; + + while (node) + { + if (node.nodeType == 1 && this.is_block(node)) // element + { + w3c_slidy.add_class(node, "hidden"); + } + + node = node.nextSibling; + } + + item.visible = false; + }, + + // ### CHECK ME ### switch to add/remove "hidden" class + unfold: function (item) { + if (item) + { + this.add_class(item, "unfolded"); + this.remove_class(item, "folded"); + } + + var node = item ? item.firstChild : null; + + while (node) + { + if (node.nodeType == 1 && this.is_block(node)) // element + { + w3c_slidy.remove_class(node, "hidden"); + } + + node = node.nextSibling; + } + + item.visible = true; + }, + + outline_click: function (e) { + if (!e) + e = window.event; + + var rightclick = false; + var target = w3c_slidy.get_target(e); + + while (target && target.visible == undefined) + target = target.parentNode; + + if (!target) + return true; + + if (e.which) + rightclick = (e.which == 3); + else if (e.button) + rightclick = (e.button == 2); + + if (!rightclick && target.visible != undefined) + { + if (target.foldable) + { + if (target.visible) + w3c_slidy.fold(target); + else + w3c_slidy.unfold(target); + } + + w3c_slidy.stop_propagation(e); + e.cancel = true; + e.returnValue = false; + } + + return false; + }, + + add_initial_prompt: function () { + var prompt = this.create_element("div"); + prompt.setAttribute("class", "initial_prompt"); + + var p1 = this.create_element("p"); + prompt.appendChild(p1); + p1.setAttribute("class", "help"); + + if (this.keyboardless) + p1.innerHTML = "swipe left to move to next slide"; + else + p1.innerHTML = "Space, Right Arrow or swipe left to move to " + + "next slide, click help below for more details"; + + this.add_listener(prompt, "click", function (e) { + document.body.removeChild(prompt); + w3c_slidy.stop_propagation(e); + + if (e.cancel != undefined) + e.cancel = true; + + if (e.returnValue != undefined) + e.returnValue = false; + + return false; + }); + + document.body.appendChild(prompt); + this.initial_prompt = prompt; + setTimeout(function() {document.body.removeChild(prompt);}, 5000); + }, + + add_toolbar: function () { + var counter, page; + + this.toolbar = this.create_element("div"); + this.toolbar.setAttribute("class", "toolbar"); + + // a reasonably behaved browser + if (this.ns_pos || !this.ie6) + { + var right = this.create_element("div"); + right.setAttribute("style", "float: right; text-align: right"); + + counter = this.create_element("span") + counter.innerHTML = this.localize("slide") + " n/m"; + right.appendChild(counter); + this.toolbar.appendChild(right); + + var left = this.create_element("div"); + left.setAttribute("style", "text-align: left"); + + // global end of slide indicator + this.eos = this.create_element("span"); + this.eos.innerHTML = "* "; + left.appendChild(this.eos); + + var gap1 = document.createTextNode(" "); + left.appendChild(gap1); + + var contents = this.create_element("a"); + contents.setAttribute("href", "javascript:w3c_slidy.toggle_table_of_contents()"); + contents.setAttribute("title", this.localize("table of contents")); + contents.innerHTML = this.localize("contents?"); + left.appendChild(contents); + + var gap2 = document.createTextNode(" "); + left.appendChild(gap2); + + var copyright = this.find_copyright(); + + if (copyright) + { + var span = this.create_element("span"); + span.className = "copyright"; + span.innerHTML = copyright; + left.appendChild(span); + } + + this.toolbar.setAttribute("tabindex", "0"); + this.toolbar.appendChild(left); + } + else // IE6 so need to work around its poor CSS support + { + this.toolbar.style.position = (this.ie7 ? "fixed" : "absolute"); + this.toolbar.style.zIndex = "200"; + this.toolbar.style.width = "99.9%"; + this.toolbar.style.height = "1.2em"; + this.toolbar.style.top = "auto"; + this.toolbar.style.bottom = "0"; + this.toolbar.style.left = "0"; + this.toolbar.style.right = "0"; + this.toolbar.style.textAlign = "left"; + this.toolbar.style.fontSize = "60%"; + this.toolbar.style.color = "red"; + this.toolbar.borderWidth = 0; + this.toolbar.className = "toolbar"; + this.toolbar.style.background = "rgb(240,240,240)"; + + // would like to have help text left aligned + // and page counter right aligned, floating + // div's don't work, so instead use nested + // absolutely positioned div's. + + var sp = this.create_element("span"); + sp.innerHTML = "  * "; + this.toolbar.appendChild(sp); + this.eos = sp; // end of slide indicator + + var gap1 = document.createTextNode(" "); + this.toolbar.appendChild(gap1); + + var contents = this.create_element("a"); + contents.setAttribute("href", "javascript:toggleTableOfContents()"); + contents.setAttribute("title", this.localize("table of contents".localize)); + contents.innerHTML = this.localize("contents?"); + this.toolbar.appendChild(contents); + + var gap2 = document.createTextNode(" "); + this.toolbar.appendChild(gap2); + + var copyright = this.find_copyright(); + + if (copyright) + { + var span = this.create_element("span"); + span.innerHTML = copyright; + span.style.color = "black"; + span.style.marginLeft = "0.5em"; + this.toolbar.appendChild(span); + } + + counter = this.create_element("div") + counter.style.position = "absolute"; + counter.style.width = "auto"; //"20%"; + counter.style.height = "1.2em"; + counter.style.top = "auto"; + counter.style.bottom = 0; + counter.style.right = "0"; + counter.style.textAlign = "right"; + counter.style.color = "red"; + counter.style.background = "rgb(240,240,240)"; + + counter.innerHTML = this.localize("slide") + " n/m"; + this.toolbar.appendChild(counter); + } + /* + // ensure that click isn't passed through to the page + this.toolbar.onclick = + function (e) { + if (!e) + e = window.event; + + var target = e.target; + + if (!target && e.srcElement) + target = e.srcElement; + + // work around Safari bug + if (target && target.nodeType == 3) + target = target.parentNode; + + w3c_slidy.stop_propagation(e); + + if (target && target.nodeName.toLowerCase() != "a") + w3c_slidy.mouse_button_click(e); + }; + */ + this.slide_number_element = counter; + this.set_eos_status(false); + document.body.appendChild(this.toolbar); + }, + + // wysiwyg editors make it hard to use div elements + // e.g. amaya loses the div when you copy and paste + // this function wraps div elements around implicit + // slides which start with an h1 element and continue + // up to the next heading or div element + wrap_implicit_slides: function () { + var i, heading, node, next, div; + var headings = document.getElementsByTagName("h1"); + + if (!headings) + return; + + for (i = 0; i < headings.length; ++i) + { + heading = headings[i]; + + if (heading.parentNode != document.body) + continue; + + node = heading.nextSibling; + + div = document.createElement("div"); + this.add_class(div, "slide"); + document.body.replaceChild(div, heading); + div.appendChild(heading); + + while (node) + { + if (node.nodeType == 1) // an element + { + if (node.nodeName == "H1" || node.nodeName == "h1") + break; + + if (node.nodeName == "DIV" || node.nodeName == "div") + { + if (this.has_class(node, "slide")) + break; + + if (this.has_class(node, "handout")) + break; + } + } + + next = node.nextSibling; + node = document.body.removeChild(node); + div.appendChild(node); + node = next; + } + } + }, + +// return new array of all slides + collect_slides: function () { + var slides = new Array(); + var divs = document.body.getElementsByTagName("div"); + + for (var i = 0; i < divs.length; ++i) + { + div = divs.item(i); + + if (this.has_class(div, "slide")) + { + // add slide to collection + slides[slides.length] = div; + + // hide each slide as it is found + this.add_class(div, "hidden"); + + // add dummy
    at end for scrolling hack + var node1 = document.createElement("br"); + div.appendChild(node1); + var node2 = document.createElement("br"); + div.appendChild(node2); + } + else if (this.has_class(div, "background")) + { // work around for Firefox SVG reload bug + // which otherwise replaces 1st SVG graphic with 2nd + div.style.display = "block"; + } + } + + this.slides = slides; + }, + + // return new array of all
    + collect_notes: function () { + var notes = new Array(); + var divs = document.body.getElementsByTagName("div"); + + for (var i = 0; i < divs.length; ++i) + { + div = divs.item(i); + + if (this.has_class(div, "handout")) + { + // add note to collection + notes[notes.length] = div; + + // and hide it + this.add_class(div, "hidden"); + } + } + + this.notes = notes; + }, + + // return new array of all
    + // including named backgrounds e.g. class="background titlepage" + collect_backgrounds: function () { + var backgrounds = new Array(); + var divs = document.body.getElementsByTagName("div"); + + for (var i = 0; i < divs.length; ++i) + { + div = divs.item(i); + + if (this.has_class(div, "background")) + { + // add background to collection + backgrounds[backgrounds.length] = div; + + // and hide it + this.add_class(div, "hidden"); + } + } + + this.backgrounds = backgrounds; + }, + + // set click handlers on all anchors + patch_anchors: function () { + var self = w3c_slidy; + var handler = function (event) { + // compare this.href with location.href + // for link to another slide in this doc + + if (self.page_address(this.href) == self.page_address(location.href)) + { + // yes, so find new slide number + var newslidenum = self.find_slide_number(this.href); + + if (newslidenum != self.slide_number) + { + var slide = self.slides[self.slide_number]; + self.hide_slide(slide); + self.slide_number = newslidenum; + slide = self.slides[self.slide_number]; + self.show_slide(slide); + self.set_location(); + } + } + else + w3c_slidy.stop_propagation(event); + +// else if (this.target == null) +// location.href = this.href; + + this.blur(); + self.disable_slide_click = true; + }; + }, + + // ### CHECK ME ### see which functions are invoked via setTimeout + // either directly or indirectly for use of w3c_slidy vs this + show_slide_number: function () { + var timer = w3c_slidy.get_timer(); + w3c_slidy.slide_number_element.innerHTML = timer + w3c_slidy.localize("slide") + " " + + (w3c_slidy.slide_number + 1) + "/" + w3c_slidy.slides.length; + }, + + // every 200mS check if the location has been changed as a + // result of the user activating the Back button/menu item + // doesn't work for Opera < 9.5 + check_location: function () { + var hash = location.hash; + + if (w3c_slidy.slide_number > 0 && (hash == "" || hash == "#")) + w3c_slidy.goto_slide(0); + else if (hash.length > 2 && hash != "#("+(w3c_slidy.slide_number+1)+")") + { + var num = parseInt(location.hash.substr(2)); + + if (!isNaN(num)) + w3c_slidy.goto_slide(num-1); + } + + if (w3c_slidy.time_left && w3c_slidy.slide_number > 0) + { + w3c_slidy.show_slide_number(); + + if (w3c_slidy.time_left > 0) + w3c_slidy.time_left -= 200; + } + }, + + get_timer: function () { + var timer = ""; + if (w3c_slidy.time_left) + { + var mins, secs; + secs = Math.floor(w3c_slidy.time_left/1000); + mins = Math.floor(secs / 60); + secs = secs % 60; + timer = (mins ? mins+"m" : "") + secs + "s "; + } + + return timer; + }, + + // this doesn't push location onto history stack for IE + // for which a hidden iframe hack is needed: load page into + // the iframe with script that set's parent's location.hash + // but that won't work for standalone use unless we can + // create the page dynamically via a javascript: URL + // ### use history.pushState if available + set_location: function () { + var uri = w3c_slidy.page_address(location.href); + var hash = "#(" + (w3c_slidy.slide_number+1) + ")"; + + if (w3c_slidy.slide_number >= 0) + uri = uri + hash; + + if (typeof(history.pushState) != "undefined") + { + document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")"; + history.pushState(0, document.title, hash); + w3c_slidy.show_slide_number(); + return; + } + + if (w3c_slidy.ie && (w3c_slidy.ie6 || w3c_slidy.ie7)) + w3c_slidy.push_hash(hash); + + if (uri != location.href) // && !khtml + location.href = uri; + + if (this.khtml) + hash = "(" + (w3c_slidy.slide_number+1) + ")"; + + if (!this.ie && location.hash != hash && location.hash != "") + location.hash = hash; + + document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")"; + w3c_slidy.show_slide_number(); + }, + + page_address: function (uri) { + var i = uri.indexOf("#"); + + if (i < 0) + i = uri.indexOf("%23"); + + // check if anchor is entire page + + if (i < 0) + return uri; // yes + + return uri.substr(0, i); + }, + + // only used for IE6 and IE7 + on_frame_loaded: function (hash) { + location.hash = hash; + var uri = w3c_slidy.page_address(location.href); + location.href = uri + hash; + }, + + // history hack with thanks to Bertrand Le Roy + push_hash: function (hash) { + if (hash == "") hash = "#(1)"; + window.location.hash = hash; + + var doc = document.getElementById("historyFrame").contentWindow.document; + doc.open("javascript:''"); + doc.write("hello mum"); + doc.close(); + }, + + // find current slide based upon location + // first find target anchor and then look + // for associated div element enclosing it + // finally map that to slide number + find_slide_number: function (uri) { + // first get anchor from page location + + var i = uri.indexOf("#"); + + // check if anchor is entire page + if (i < 0) + return 0; // yes + + var anchor = unescape(uri.substr(i+1)); + + // now use anchor as XML ID to find target + var target = document.getElementById(anchor); + + if (!target) + { + // does anchor look like "(2)" for slide 2 ?? + // where first slide is (1) + var re = /\((\d)+\)/; + + if (anchor.match(re)) + { + var num = parseInt(anchor.substring(1, anchor.length-1)); + + if (num > this.slides.length) + num = 1; + + if (--num < 0) + num = 0; + + return num; + } + + // accept [2] for backwards compatibility + re = /\[(\d)+\]/; + + if (anchor.match(re)) + { + var num = parseInt(anchor.substring(1, anchor.length-1)); + + if (num > this.slides.length) + num = 1; + + if (--num < 0) + num = 0; + + return num; + } + + // oh dear unknown anchor + return 0; + } + + // search for enclosing slide + + while (true) + { + // browser coerces html elements to uppercase! + if (target.nodeName.toLowerCase() == "div" && + this.has_class(target, "slide")) + { + // found the slide element + break; + } + + // otherwise try parent element if any + + target = target.parentNode; + + if (!target) + { + return 0; // no luck! + } + }; + + for (i = 0; i < slides.length; ++i) + { + if (slides[i] == target) + return i; // success + } + + // oh dear still no luck + return 0; + }, + + previous_slide: function (incremental) { + if (!w3c_slidy.view_all) + { + var slide; + + if ((incremental || w3c_slidy.slide_number == 0) && w3c_slidy.last_shown != null) + { + w3c_slidy.last_shown = w3c_slidy.hide_previous_item(w3c_slidy.last_shown); + w3c_slidy.set_eos_status(false); + } + else if (w3c_slidy.slide_number > 0) + { + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + + w3c_slidy.slide_number = w3c_slidy.slide_number - 1; + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.set_visibility_all_incremental("visible"); + w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null); + w3c_slidy.set_eos_status(true); + w3c_slidy.show_slide(slide); + } + + w3c_slidy.set_location(); + + if (!w3c_slidy.ns_pos) + w3c_slidy.refresh_toolbar(200); + } + }, + + next_slide: function (incremental) { + if (!w3c_slidy.view_all) + { + var slide, last = w3c_slidy.last_shown; + + if (incremental || w3c_slidy.slide_number == w3c_slidy.slides.length - 1) + w3c_slidy.last_shown = w3c_slidy.reveal_next_item(w3c_slidy.last_shown); + + if ((!incremental || w3c_slidy.last_shown == null) && + w3c_slidy.slide_number < w3c_slidy.slides.length - 1) + { + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + + w3c_slidy.slide_number = w3c_slidy.slide_number + 1; + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.last_shown = null; + w3c_slidy.set_visibility_all_incremental("hidden"); + w3c_slidy.show_slide(slide); + } + else if (!w3c_slidy.last_shown) + { + if (last && incremental) + w3c_slidy.last_shown = last; + } + + w3c_slidy.set_location(); + + w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown)); + + if (!w3c_slidy.ns_pos) + w3c_slidy.refresh_toolbar(200); + } + }, + + // to first slide with nothing revealed + // i.e. state at start of presentation + first_slide: function () { + if (!w3c_slidy.view_all) + { + var slide; + + if (w3c_slidy.slide_number != 0) + { + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + + w3c_slidy.slide_number = 0; + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.last_shown = null; + w3c_slidy.set_visibility_all_incremental("hidden"); + w3c_slidy.show_slide(slide); + } + + w3c_slidy.set_eos_status( + !w3c_slidy.next_incremental_item(w3c_slidy.last_shown)); + w3c_slidy.set_location(); + } + }, + + // goto last slide with everything revealed + // i.e. state at end of presentation + last_slide: function () { + if (!w3c_slidy.view_all) + { + var slide; + + w3c_slidy.last_shown = null; //revealNextItem(lastShown); + + if (w3c_slidy.last_shown == null && + w3c_slidy.slide_number < w3c_slidy.slides.length - 1) + { + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.slide_number = w3c_slidy.slides.length - 1; + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.set_visibility_all_incremental("visible"); + w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null); + + w3c_slidy.show_slide(slide); + } + else + { + w3c_slidy.set_visibility_all_incremental("visible"); + w3c_slidy.last_shown = w3c_slidy.previous_incremental_item(null); + } + + w3c_slidy.set_eos_status(true); + w3c_slidy.set_location(); + } + }, + + + // ### check this and consider add/remove class + set_eos_status: function (state) { + if (this.eos) + this.eos.style.color = (state ? "rgb(240,240,240)" : "red"); + }, + + // first slide is 0 + goto_slide: function (num) { + //alert("going to slide " + (num+1)); + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.slide_number = num; + slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.last_shown = null; + w3c_slidy.set_visibility_all_incremental("hidden"); + w3c_slidy.set_eos_status(!w3c_slidy.next_incremental_item(w3c_slidy.last_shown)); + document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")"; + w3c_slidy.show_slide(slide); + w3c_slidy.show_slide_number(); + }, + + + show_slide: function (slide) { + this.sync_background(slide); + window.scrollTo(0,0); + this.remove_class(slide, "hidden"); + }, + + hide_slide: function (slide) { + this.add_class(slide, "hidden"); + }, + + // show just the backgrounds pertinent to this slide + // when slide background-color is transparent + // this should now work with rgba color values + sync_background: function (slide) { + var background; + var bgColor; + + if (slide.currentStyle) + bgColor = slide.currentStyle["backgroundColor"]; + else if (document.defaultView) + { + var styles = document.defaultView.getComputedStyle(slide,null); + + if (styles) + bgColor = styles.getPropertyValue("background-color"); + else // broken implementation probably due Safari or Konqueror + { + //alert("defective implementation of getComputedStyle()"); + bgColor = "transparent"; + } + } + else + bgColor == "transparent"; + + if (bgColor == "transparent" || + bgColor.indexOf("rgba") >= 0 || + bgColor.indexOf("opacity") >= 0) + { + var slideClass = this.get_class_list(slide); + + for (var i = 0; i < this.backgrounds.length; i++) + { + background = this.backgrounds[i]; + + var bgClass = this.get_class_list(background); + + if (this.matching_background(slideClass, bgClass)) + this.remove_class(background, "hidden"); + else + this.add_class(background, "hidden"); + } + } + else // forcibly hide all backgrounds + this.hide_backgrounds(); + }, + + hide_backgrounds: function () { + for (var i = 0; i < this.backgrounds.length; i++) + { + background = this.backgrounds[i]; + this.add_class(background, "hidden"); + } + }, + + // compare classes for slide and background + matching_background: function (slideClass, bgClass) { + var i, count, pattern, result; + + // define pattern as regular expression + pattern = /\w+/g; + + // check background class names + result = bgClass.match(pattern); + + for (i = count = 0; i < result.length; i++) + { + if (result[i] == "hidden") + continue; + + if (result[i] == "background") + continue; + + ++count; + } + + if (count == 0) // default match + return true; + + // check for matches and place result in array + result = slideClass.match(pattern); + + // now check if desired name is present for background + for (i = count = 0; i < result.length; i++) + { + if (result[i] == "hidden") + continue; + + if (this.has_token(bgClass, result[i])) + return true; + } + + return false; + }, + + resized: function () { + var width = 0; + + if ( typeof( window.innerWidth ) == 'number' ) + width = window.innerWidth; // Non IE browser + else if (document.documentElement && document.documentElement.clientWidth) + width = document.documentElement.clientWidth; // IE6 + else if (document.body && document.body.clientWidth) + width = document.body.clientWidth; // IE4 + + var height = 0; + + if ( typeof( window.innerHeight ) == 'number' ) + height = window.innerHeight; // Non IE browser + else if (document.documentElement && document.documentElement.clientHeight) + height = document.documentElement.clientHeight; // IE6 + else if (document.body && document.body.clientHeight) + height = document.body.clientHeight; // IE4 + + if (height && (width/height > 1.05*1024/768)) + { + width = height * 1024.0/768; + } + + // IE fires onresize even when only font size is changed! + // so we do a check to avoid blocking < and > actions + if (width != w3c_slidy.last_width || height != w3c_slidy.last_height) + { + if (width >= 1100) + w3c_slidy.size_index = 5; // 4 + else if (width >= 1000) + w3c_slidy.size_index = 4; // 3 + else if (width >= 800) + w3c_slidy.size_index = 3; // 2 + else if (width >= 600) + w3c_slidy.size_index = 2; // 1 + else if (width) + w3c_slidy.size_index = 0; + + // add in font size adjustment from meta element e.g. + // + // useful when slides have too much content ;-) + + if (0 <= w3c_slidy.size_index + w3c_slidy.size_adjustment && + w3c_slidy.size_index + w3c_slidy.size_adjustment < w3c_slidy.sizes.length) + w3c_slidy.size_index = w3c_slidy.size_index + w3c_slidy.size_adjustment; + + // enables cross browser use of relative width/height + // on object elements for use with SVG and Flash media + w3c_slidy.adjust_object_dimensions(width, height); + + if (document.body.style.fontSize != w3c_slidy.sizes[w3c_slidy.size_index]) + { + document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index]; + } + + w3c_slidy.last_width = width; + w3c_slidy.last_height = height; + + // force reflow to work around Mozilla bug + if (w3c_slidy.ns_pos) + { + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.show_slide(slide); + } + + // force correct positioning of toolbar + w3c_slidy.refresh_toolbar(200); + } + }, + + scrolled: function () { + if (w3c_slidy.toolbar && !w3c_slidy.ns_pos && !w3c_slidy.ie7) + { + w3c_slidy.hack_offset = w3c_slidy.scroll_x_offset(); + // hide toolbar + w3c_slidy.toolbar.style.display = "none"; + + // make it reappear later + if (w3c_slidy.scrollhack == 0 && !w3c_slidy.view_all) + { + setTimeout(function () {w3c_slidy.show_toolbar(); }, 1000); + w3c_slidy.scrollhack = 1; + } + } + }, + + hide_toolbar: function () { + w3c_slidy.add_class(w3c_slidy.toolbar, "hidden"); + window.focus(); + }, + + // used to ensure IE refreshes toolbar in correct position + refresh_toolbar: function (interval) { + if (!w3c_slidy.ns_pos && !w3c_slidy.ie7) + { + w3c_slidy.hide_toolbar(); + setTimeout(function () {w3c_slidy.show_toolbar();}, interval); + } + }, + + // restores toolbar after short delay + show_toolbar: function () { + if (w3c_slidy.want_toolbar) + { + w3c_slidy.toolbar.style.display = "block"; + + if (!w3c_slidy.ns_pos) + { + // adjust position to allow for scrolling + var xoffset = w3c_slidy.scroll_x_offset(); + w3c_slidy.toolbar.style.left = xoffset; + w3c_slidy.toolbar.style.right = xoffset; + + // determine vertical scroll offset + //var yoffset = scrollYOffset(); + + // bottom is doc height - window height - scroll offset + //var bottom = documentHeight() - lastHeight - yoffset + + //if (yoffset > 0 || documentHeight() > lastHeight) + // bottom += 16; // allow for height of scrollbar + + w3c_slidy.toolbar.style.bottom = 0; //bottom; + } + + w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden"); + } + + w3c_slidy.scrollhack = 0; + + + // set the keyboard focus to the help link on the + // toolbar to ensure that document has the focus + // IE doesn't always work with window.focus() + // and this hack has benefit of Enter for help + + try + { + if (!w3c_slidy.opera) + w3c_slidy.help_anchor.focus(); + } + catch (e) + { + } + }, + +// invoked via F key + toggle_toolbar: function () { + if (!w3c_slidy.view_all) + { + if (w3c_slidy.has_class(w3c_slidy.toolbar, "hidden")) + { + w3c_slidy.remove_class(w3c_slidy.toolbar, "hidden") + w3c_slidy.want_toolbar = 1; + } + else + { + w3c_slidy.add_class(w3c_slidy.toolbar, "hidden") + w3c_slidy.want_toolbar = 0; + } + } + }, + + scroll_x_offset: function () { + if (window.pageXOffset) + return self.pageXOffset; + + if (document.documentElement && + document.documentElement.scrollLeft) + return document.documentElement.scrollLeft; + + if (document.body) + return document.body.scrollLeft; + + return 0; + }, + + scroll_y_offset: function () { + if (window.pageYOffset) + return self.pageYOffset; + + if (document.documentElement && + document.documentElement.scrollTop) + return document.documentElement.scrollTop; + + if (document.body) + return document.body.scrollTop; + + return 0; + }, + + // looking for a way to determine height of slide content + // the slide itself is set to the height of the window + optimize_font_size: function () { + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + + //var dh = documentHeight(); //getDocHeight(document); + var dh = slide.scrollHeight; + var wh = getWindowHeight(); + var u = 100 * dh / wh; + + alert("window utilization = " + u + "% (doc " + + dh + " win " + wh + ")"); + }, + + // from document object + get_doc_height: function (doc) { + if (!doc) + doc = document; + + if (doc && doc.body && doc.body.offsetHeight) + return doc.body.offsetHeight; // ns/gecko syntax + + if (doc && doc.body && doc.body.scrollHeight) + return doc.body.scrollHeight; + + alert("couldn't determine document height"); + }, + + get_window_height: function () { + if ( typeof( window.innerHeight ) == 'number' ) + return window.innerHeight; // Non IE browser + + if (document.documentElement && document.documentElement.clientHeight) + return document.documentElement.clientHeight; // IE6 + + if (document.body && document.body.clientHeight) + return document.body.clientHeight; // IE4 + }, + + document_height: function () { + var sh, oh; + + sh = document.body.scrollHeight; + oh = document.body.offsetHeight; + + if (sh && oh) + { + return (sh > oh ? sh : oh); + } + + // no idea! + return 0; + }, + + smaller: function () { + if (w3c_slidy.size_index > 0) + { + --w3c_slidy.size_index; + } + + w3c_slidy.toolbar.style.display = "none"; + document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index]; + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.show_slide(slide); + setTimeout(function () {w3c_slidy.show_toolbar(); }, 50); + }, + + bigger: function () { + if (w3c_slidy.size_index < w3c_slidy.sizes.length - 1) + { + ++w3c_slidy.size_index; + } + + w3c_slidy.toolbar.style.display = "none"; + document.body.style.fontSize = w3c_slidy.sizes[w3c_slidy.size_index]; + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + w3c_slidy.hide_slide(slide); + w3c_slidy.show_slide(slide); + setTimeout(function () {w3c_slidy.show_toolbar(); }, 50); + }, + + // enables cross browser use of relative width/height + // on object elements for use with SVG and Flash media + // with thanks to Ivan Herman for the suggestion + adjust_object_dimensions: function (width, height) { + for( var i = 0; i < w3c_slidy.objects.length; i++ ) + { + var obj = this.objects[i]; + var mimeType = obj.getAttribute("type"); + + if (mimeType == "image/svg+xml" || mimeType == "application/x-shockwave-flash") + { + if ( !obj.initialWidth ) + obj.initialWidth = obj.getAttribute("width"); + + if ( !obj.initialHeight ) + obj.initialHeight = obj.getAttribute("height"); + + if ( obj.initialWidth && obj.initialWidth.charAt(obj.initialWidth.length-1) == "%" ) + { + var w = parseInt(obj.initialWidth.slice(0, obj.initialWidth.length-1)); + var newW = width * (w/100.0); + obj.setAttribute("width",newW); + } + + if ( obj.initialHeight && + obj.initialHeight.charAt(obj.initialHeight.length-1) == "%" ) + { + var h = parseInt(obj.initialHeight.slice(0, obj.initialHeight.length-1)); + var newH = height * (h/100.0); + obj.setAttribute("height", newH); + } + } + } + }, + + // needed for Opera to inhibit default behavior + // since Opera delivers keyPress even if keyDown + // was cancelled + key_press: function (event) { + if (!event) + event = window.event; + + if (!w3c_slidy.key_wanted) + return w3c_slidy.cancel(event); + + return true; + }, + + // See e.g. http://www.quirksmode.org/js/events/keys.html for keycodes + key_down: function (event) { + var key, target, tag; + + w3c_slidy.key_wanted = true; + + if (!event) + event = window.event; + + // kludge around NS/IE differences + if (window.event) + { + key = window.event.keyCode; + target = window.event.srcElement; + } + else if (event.which) + { + key = event.which; + target = event.target; + } + else + return true; // Yikes! unknown browser + + // ignore event if key value is zero + // as for alt on Opera and Konqueror + if (!key) + return true; + + // avoid interfering with keystroke + // behavior for non-slidy chrome elements + if (!w3c_slidy.slidy_chrome(target) && + w3c_slidy.special_element(target)) + return true; + + // check for concurrent control/command/alt key + // but are these only present on mouse events? + + if (event.ctrlKey || event.altKey || event.metaKey) + return true; + + // dismiss table of contents if visible + if (w3c_slidy.is_shown_toc() && key != 9 && key != 16 && key != 38 && key != 40) + { + w3c_slidy.hide_table_of_contents(true); + + if (key == 27 || key == 84 || key == 67) + return w3c_slidy.cancel(event); + } + + if (key == 34) // Page Down + { + if (w3c_slidy.view_all) + return true; + + w3c_slidy.next_slide(false); + return w3c_slidy.cancel(event); + } + else if (key == 33) // Page Up + { + if (w3c_slidy.view_all) + return true; + + w3c_slidy.previous_slide(false); + return w3c_slidy.cancel(event); + } + else if (key == 32) // space bar + { + w3c_slidy.next_slide(true); + return w3c_slidy.cancel(event); + } + else if (key == 37) // Left arrow + { + w3c_slidy.previous_slide(!event.shiftKey); + return w3c_slidy.cancel(event); + } + else if (key == 36) // Home + { + w3c_slidy.first_slide(); + return w3c_slidy.cancel(event); + } + else if (key == 35) // End + { + w3c_slidy.last_slide(); + return w3c_slidy.cancel(event); + } + else if (key == 39) // Right arrow + { + w3c_slidy.next_slide(!event.shiftKey); + return w3c_slidy.cancel(event); + } + else if (key == 13) // Enter + { + if (w3c_slidy.outline) + { + if (w3c_slidy.outline.visible) + w3c_slidy.fold(w3c_slidy.outline); + else + w3c_slidy.unfold(w3c_slidy.outline); + + return w3c_slidy.cancel(event); + } + } + else if (key == 188) // < for smaller fonts + { + w3c_slidy.smaller(); + return w3c_slidy.cancel(event); + } + else if (key == 190) // > for larger fonts + { + w3c_slidy.bigger(); + return w3c_slidy.cancel(event); + } + else if (key == 189 || key == 109) // - for smaller fonts + { + w3c_slidy.smaller(); + return w3c_slidy.cancel(event); + } + else if (key == 187 || key == 191 || key == 107) // = + for larger fonts + { + w3c_slidy.bigger(); + return w3c_slidy.cancel(event); + } + else if (key == 83) // S for smaller fonts + { + w3c_slidy.smaller(); + return w3c_slidy.cancel(event); + } + else if (key == 66) // B for larger fonts + { + w3c_slidy.bigger(); + return w3c_slidy.cancel(event); + } + else if (key == 90) // Z for last slide + { + w3c_slidy.last_slide(); + return w3c_slidy.cancel(event); + } + else if (key == 70) // F for toggle toolbar + { + w3c_slidy.toggle_toolbar(); + return w3c_slidy.cancel(event); + } + else if (key == 65) // A for toggle view single/all slides + { + w3c_slidy.toggle_view(); + return w3c_slidy.cancel(event); + } + else if (key == 75) // toggle action of left click for next page + { + w3c_slidy.mouse_click_enabled = !w3c_slidy.mouse_click_enabled; + var alert_msg = (w3c_slidy.mouse_click_enabled ? + "enabled" : "disabled") + " mouse click advance"; + + alert(w3c_slidy.localize(alert_msg)); + return w3c_slidy.cancel(event); + } + else if (key == 84 || key == 67) // T or C for table of contents + { + if (w3c_slidy.toc) + w3c_slidy.toggle_table_of_contents(); + + return w3c_slidy.cancel(event); + } + else if (key == 72) // H for help + { + window.location = w3c_slidy.help_page; + return w3c_slidy.cancel(event); + } + //else alert("key code is "+ key); + + return true; + }, + + // safe for both text/html and application/xhtml+xml + create_element: function (name) { + if (this.xhtml && (typeof document.createElementNS != 'undefined')) + return document.createElementNS("http://www.w3.org/1999/xhtml", name) + + return document.createElement(name); + }, + + get_element_style: function (elem, IEStyleProp, CSSStyleProp) { + if (elem.currentStyle) + { + return elem.currentStyle[IEStyleProp]; + } + else if (window.getComputedStyle) + { + var compStyle = window.getComputedStyle(elem, ""); + return compStyle.getPropertyValue(CSSStyleProp); + } + return ""; + }, + + // the string str is a whitespace separated list of tokens + // test if str contains a particular token, e.g. "slide" + has_token: function (str, token) { + if (str) + { + // define pattern as regular expression + var pattern = /\w+/g; + + // check for matches + // place result in array + var result = str.match(pattern); + + // now check if desired token is present + for (var i = 0; i < result.length; i++) + { + if (result[i] == token) + return true; + } + } + + return false; + }, + + get_class_list: function (element) { + if (typeof element.className != 'undefined') + return element.className; + + return element.getAttribute("class"); + }, + + has_class: function (element, name) { + if (element.nodeType != 1) + return false; + + var regexp = new RegExp("(^| )" + name + "\W*"); + + if (typeof element.className != 'undefined') + return regexp.test(element.className); + + return regexp.test(element.getAttribute("class")); + }, + + remove_class: function (element, name) { + var regexp = new RegExp("(^| )" + name + "\W*"); + var clsval = ""; + + if (typeof element.className != 'undefined') + { + clsval = element.className; + + if (clsval) + { + clsval = clsval.replace(regexp, ""); + element.className = clsval; + } + } + else + { + clsval = element.getAttribute("class"); + + if (clsval) + { + clsval = clsval.replace(regexp, ""); + element.setAttribute("class", clsval); + } + } + }, + + add_class: function (element, name) { + if (!this.has_class(element, name)) + { + if (typeof element.className != 'undefined') + element.className += " " + name; + else + { + var clsval = element.getAttribute("class"); + clsval = clsval ? clsval + " " + name : name; + element.setAttribute("class", clsval); + } + } + }, + + // HTML elements that can be used with class="incremental" + // note that you can also put the class on containers like + // up, ol, dl, and div to make their contents appear + // incrementally. Upper case is used since this is what + // browsers report for HTML node names (text/html). + incremental_elements: null, + okay_for_incremental: function (name) { + if (!this.incremental_elements) + { + var inclist = new Array(); + inclist["p"] = true; + inclist["pre"] = true; + inclist["li"] = true; + inclist["blockquote"] = true; + inclist["dt"] = true; + inclist["dd"] = true; + inclist["h2"] = true; + inclist["h3"] = true; + inclist["h4"] = true; + inclist["h5"] = true; + inclist["h6"] = true; + inclist["span"] = true; + inclist["address"] = true; + inclist["table"] = true; + inclist["tr"] = true; + inclist["th"] = true; + inclist["td"] = true; + inclist["img"] = true; + inclist["object"] = true; + this.incremental_elements = inclist; + } + return this.incremental_elements[name.toLowerCase()]; + }, + + next_incremental_item: function (node) { + var br = this.is_xhtml ? "br" : "BR"; + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + + for (;;) + { + node = w3c_slidy.next_node(slide, node); + + if (node == null || node.parentNode == null) + break; + + if (node.nodeType == 1) // ELEMENT + { + if (node.nodeName == br) + continue; + + if (w3c_slidy.has_class(node, "incremental") + && w3c_slidy.okay_for_incremental(node.nodeName)) + return node; + + if (w3c_slidy.has_class(node.parentNode, "incremental") + && !w3c_slidy.has_class(node, "non-incremental")) + return node; + } + } + + return node; + }, + + previous_incremental_item: function (node) { + var br = this.is_xhtml ? "br" : "BR"; + var slide = w3c_slidy.slides[w3c_slidy.slide_number]; + + for (;;) + { + node = w3c_slidy.previous_node(slide, node); + + if (node == null || node.parentNode == null) + break; + + if (node.nodeType == 1) + { + if (node.nodeName == br) + continue; + + if (w3c_slidy.has_class(node, "incremental") + && w3c_slidy.okay_for_incremental(node.nodeName)) + return node; + + if (w3c_slidy.has_class(node.parentNode, "incremental") + && !w3c_slidy.has_class(node, "non-incremental")) + return node; + } + } + + return node; + }, + + // set visibility for all elements on current slide with + // a parent element with attribute class="incremental" + set_visibility_all_incremental: function (value) { + var node = this.next_incremental_item(null); + + if (value == "hidden") + { + while (node) + { + w3c_slidy.add_class(node, "invisible"); + node = w3c_slidy.next_incremental_item(node); + } + } + else // value == "visible" + { + while (node) + { + w3c_slidy.remove_class(node, "invisible"); + node = w3c_slidy.next_incremental_item(node); + } + } + }, + + // reveal the next hidden item on the slide + // node is null or the node that was last revealed + reveal_next_item: function (node) { + node = w3c_slidy.next_incremental_item(node); + + if (node && node.nodeType == 1) // an element + w3c_slidy.remove_class(node, "invisible"); + + return node; + }, + + // exact inverse of revealNextItem(node) + hide_previous_item: function (node) { + if (node && node.nodeType == 1) // an element + w3c_slidy.add_class(node, "invisible"); + + return this.previous_incremental_item(node); + }, + + // left to right traversal of root's content + next_node: function (root, node) { + if (node == null) + return root.firstChild; + + if (node.firstChild) + return node.firstChild; + + if (node.nextSibling) + return node.nextSibling; + + for (;;) + { + node = node.parentNode; + + if (!node || node == root) + break; + + if (node && node.nextSibling) + return node.nextSibling; + } + + return null; + }, + + // right to left traversal of root's content + previous_node: function (root, node) { + if (node == null) + { + node = root.lastChild; + + if (node) + { + while (node.lastChild) + node = node.lastChild; + } + + return node; + } + + if (node.previousSibling) + { + node = node.previousSibling; + + while (node.lastChild) + node = node.lastChild; + + return node; + } + + if (node.parentNode != root) + return node.parentNode; + + return null; + }, + + previous_sibling_element: function (el) { + el = el.previousSibling; + + while (el && el.nodeType != 1) + el = el.previousSibling; + + return el; + }, + + next_sibling_element: function (el) { + el = el.nextSibling; + + while (el && el.nodeType != 1) + el = el.nextSibling; + + return el; + }, + + first_child_element: function (el) { + var node; + + for (node = el.firstChild; node; node = node.nextSibling) + { + if (node.nodeType == 1) + break; + } + + return node; + }, + + first_tag: function (element, tag) { + var node; + + if (!this.is_xhtml) + tag = tag.toUpperCase(); + + for (node = element.firstChild; node; node = node.nextSibling) + { + if (node.nodeType == 1 && node.nodeName == tag) + break; + } + + return node; + }, + + hide_selection: function () { + if (window.getSelection) // Firefox, Chromium, Safari, Opera + { + var selection = window.getSelection(); + + if (selection.rangeCount > 0) + { + var range = selection.getRangeAt(0); + range.collapse (false); + } + } + else // Internet Explorer + { + var textRange = document.selection.createRange (); + textRange.collapse (false); + } + }, + + get_selected_text: function () { + try + { + if (window.getSelection) + return window.getSelection().toString(); + + if (document.getSelection) + return document.getSelection().toString(); + + if (document.selection) + return document.selection.createRange().text; + } + catch (e) + { + } + + return ""; + }, + + // make note of length of selected text + // as this evaluates to zero in click event + mouse_button_up: function (e) { + w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length; + }, + + mouse_button_down: function (e) { + w3c_slidy.selected_text_len = w3c_slidy.get_selected_text().length; + w3c_slidy.mouse_x = e.clientX; + w3c_slidy.mouse_y = e.clientY; + }, + + special_element: function (element) { + if (this.has_class(element, "non-interactive")) + return false; + + var tag = element.nodeName.toLowerCase(); + + return element.onkeydown || + element.onclick || + tag == "a" || + tag == "embed" || + tag == "object" || + tag == "video" || + tag == "audio" || + tag == "svg" || + tag == "canvas" || + tag == "input" || + tag == "textarea" || + tag == "select" || + tag == "option" || + tag == "button"; + }, + + slidy_chrome: function (el) { + while (el) + { + if (el == w3c_slidy.toc || + el == w3c_slidy.toolbar || + w3c_slidy.has_class(el, "outline")) + return true; + + el = el.parentNode; + } + + return false; + }, + + get_key: function (e) + { + var key; + + // kludge around NS/IE differences + if (typeof window.event != "undefined") + key = window.event.keyCode; + else if (e.which) + key = e.which; + + return key; + }, + + get_target: function (e) { + var target; + + if (!e) + e = window.event; + + if (e.target) + target = e.target; + else if (e.srcElement) + target = e.srcElement; + + if (target.nodeType != 1) + target = target.parentNode; + + return target; + }, + + // does display property provide correct defaults? + is_block: function (elem) { + var tag = elem.nodeName.toLowerCase(); + + return tag == "ol" || tag == "ul" || tag == "p" || + tag == "li" || tag == "table" || tag == "pre" || + tag == "h1" || tag == "h2" || tag == "h3" || + tag == "h4" || tag == "h5" || tag == "h6" || + tag == "blockquote" || tag == "address"; + }, + + add_listener: function (element, event, handler) { + if (window.addEventListener) + element.addEventListener(event, handler, false); + else + element.attachEvent("on"+event, handler); + }, + + // used to prevent event propagation from field controls + stop_propagation: function (event) { + event = event ? event : window.event; + event.cancelBubble = true; // for IE + + if (event.stopPropagation) + event.stopPropagation(); + + return true; + }, + + cancel: function (event) { + if (event) + { + event.cancel = true; + event.returnValue = false; + + if (event.preventDefault) + event.preventDefault(); + } + + w3c_slidy.key_wanted = false; + return false; + }, + +// for each language define an associative array +// and also the help text which is longer + + strings_es: { + "slide":"pág.", + "help?":"Ayuda", + "contents?":"Índice", + "table of contents":"tabla de contenidos", + "Table of Contents":"Tabla de Contenidos", + "restart presentation":"Reiniciar presentación", + "restart?":"Inicio" + }, + help_es: + "Utilice el ratón, barra espaciadora, teclas Izda/Dcha, " + + "o Re pág y Av pág. Use S y B para cambiar el tamaño de fuente.", + + strings_ca: { + "slide":"pàg..", + "help?":"Ajuda", + "contents?":"Índex", + "table of contents":"taula de continguts", + "Table of Contents":"Taula de Continguts", + "restart presentation":"Reiniciar presentació", + "restart?":"Inici" + }, + help_ca: + "Utilitzi el ratolí, barra espaiadora, tecles Esq./Dta. " + + "o Re pàg y Av pàg. Usi S i B per canviar grandària de font.", + + strings_cs: { + "slide":"snímek", + "help?":"nápověda", + "contents?":"obsah", + "table of contents":"obsah prezentace", + "Table of Contents":"Obsah prezentace", + "restart presentation":"znovu spustit prezentaci", + "restart?":"restart" + }, + help_cs: + "Prezentaci můžete procházet pomocí kliknutí myši, mezerníku, " + + "šipek vlevo a vpravo nebo kláves PageUp a PageDown. Písmo se " + + "dá zvětšit a zmenšit pomocí kláves B a S.", + + strings_nl: { + "slide":"pagina", + "help?":"Help?", + "contents?":"Inhoud?", + "table of contents":"inhoudsopgave", + "Table of Contents":"Inhoudsopgave", + "restart presentation":"herstart presentatie", + "restart?":"Herstart?" + }, + help_nl: + "Navigeer d.m.v. het muis, spatiebar, Links/Rechts toetsen, " + + "of PgUp en PgDn. Gebruik S en B om de karaktergrootte te veranderen.", + + strings_de: { + "slide":"Seite", + "help?":"Hilfe", + "contents?":"Übersicht", + "table of contents":"Inhaltsverzeichnis", + "Table of Contents":"Inhaltsverzeichnis", + "restart presentation":"Präsentation neu starten", + "restart?":"Neustart" + }, + help_de: + "Benutzen Sie die Maus, Leerschlag, die Cursortasten links/rechts oder " + + "Page up/Page Down zum Wechseln der Seiten und S und B für die Schriftgrösse.", + + strings_pl: { + "slide":"slajd", + "help?":"pomoc?", + "contents?":"spis treści?", + "table of contents":"spis treści", + "Table of Contents":"Spis Treści", + "restart presentation":"Restartuj prezentację", + "restart?":"restart?" + }, + help_pl: + "Zmieniaj slajdy klikając myszą, naciskając spację, strzałki lewo/prawo" + + "lub PgUp / PgDn. Użyj klawiszy S i B, aby zmienić rozmiar czczionki.", + + strings_fr: { + "slide":"page", + "help?":"Aide", + "contents?":"Index", + "table of contents":"table des matières", + "Table of Contents":"Table des matières", + "restart presentation":"Recommencer l'exposé", + "restart?":"Début" + }, + help_fr: + "Naviguez avec la souris, la barre d'espace, les flèches " + + "gauche/droite ou les touches Pg Up, Pg Dn. Utilisez " + + "les touches S et B pour modifier la taille de la police.", + + strings_hu: { + "slide":"oldal", + "help?":"segítség", + "contents?":"tartalom", + "table of contents":"tartalomjegyzék", + "Table of Contents":"Tartalomjegyzék", + "restart presentation":"bemutató újraindítása", + "restart?":"újraindítás" + }, + help_hu: + "Az oldalak közti lépkedéshez kattintson az egérrel, vagy " + + "használja a szóköz, a bal, vagy a jobb nyíl, illetve a Page Down, " + + "Page Up billentyűket. Az S és a B billentyűkkel változtathatja " + + "a szöveg méretét.", + + strings_it: { + "slide":"pag.", + "help?":"Aiuto", + "contents?":"Indice", + "table of contents":"indice", + "Table of Contents":"Indice", + "restart presentation":"Ricominciare la presentazione", + "restart?":"Inizio" + }, + help_it: + "Navigare con mouse, barra spazio, frecce sinistra/destra o " + + "PgUp e PgDn. Usare S e B per cambiare la dimensione dei caratteri.", + + strings_el: { + "slide":"σελίδα", + "help?":"βοήθεια;", + "contents?":"περιεχόμενα;", + "table of contents":"πίνακας περιεχομένων", + "Table of Contents":"Πίνακας Περιεχομένων", + "restart presentation":"επανεκκίνηση παρουσίασης", + "restart?":"επανεκκίνηση;" + }, + help_el: + "Πλοηγηθείτε με το κλίκ του ποντικιού, το space, τα βέλη αριστερά/δεξιά, " + + "ή Page Up και Page Down. Χρησιμοποιήστε τα πλήκτρα S και B για να αλλάξετε " + + "το μέγεθος της γραμματοσειράς.", + + strings_ja: { + "slide":"スライド", + "help?":"ヘルプ", + "contents?":"目次", + "table of contents":"目次を表示", + "Table of Contents":"目次", + "restart presentation":"最初から再生", + "restart?":"最初から" + }, + help_ja: + "マウス左クリック ・ スペース ・ 左右キー " + + "または Page Up ・ Page Downで操作, S ・ Bでフォントサイズ変更", + + strings_zh: { + "slide":"幻灯片", + "help?":"帮助?", + "contents?":"内容?", + "table of contents":"目录", + "Table of Contents":"目录", + "restart presentation":"重新启动展示", + "restart?":"重新启动?" + }, + help_zh: + "用鼠标点击, 空格条, 左右箭头, Pg Up 和 Pg Dn 导航. " + + "用 S, B 改变字体大小.", + + strings_ru: { + "slide":"слайд", + "help?":"помощь?", + "contents?":"содержание?", + "table of contents":"оглавление", + "Table of Contents":"Оглавление", + "restart presentation":"перезапустить презентацию", + "restart?":"перезапуск?" + }, + help_ru: + "Перемещайтесь кликая мышкой, используя клавишу пробел, стрелки" + + "влево/вправо или Pg Up и Pg Dn. Клавиши S и B меняют размер шрифта.", + + strings_sv: { + "slide":"sida", + "help?":"hjälp", + "contents?":"innehåll", + "table of contents":"innehållsförteckning", + "Table of Contents":"Innehållsförteckning", + "restart presentation":"visa presentationen från början", + "restart?":"börja om" + }, + help_sv: + "Bläddra med ett klick med vänstra musknappen, mellanslagstangenten, " + + "vänster- och högerpiltangenterna eller tangenterna Pg Up, Pg Dn. " + + "Använd tangenterna S och B för att ändra textens storlek.", + + strings: { }, + + localize: function (src) { + if (src == "") + return src; + + // try full language code, e.g. en-US + var s, lookup = w3c_slidy.strings[w3c_slidy.lang]; + + if (lookup) + { + s = lookup[src]; + + if (s) + return s; + } + + // strip country code suffix, e.g. + // try en if undefined for en-US + var lg = w3c_slidy.lang.split("-"); + + if (lg.length > 1) + { + lookup = w3c_slidy.strings[lg[0]]; + + if (lookup) + { + s = lookup[src]; + + if (s) + return s; + } + } + + // otherwise string as is + return src; + }, + + init_localization: function () { + var i18n = w3c_slidy; + var help_text = w3c_slidy.help_text; + + // each such language array is declared in the localize array + // this is used as in w3c_slidy.localize("foo"); + this.strings = { + "es":this.strings_es, + "ca":this.strings_ca, + "cs":this.strings_cs, + "nl":this.strings_nl, + "de":this.strings_de, + "pl":this.strings_pl, + "fr":this.strings_fr, + "hu":this.strings_hu, + "it":this.strings_it, + "el":this.strings_el, + "jp":this.strings_ja, + "zh":this.strings_zh, + "ru":this.strings_ru, + "sv":this.strings_sv + }, + + i18n.strings_es[help_text] = i18n.help_es; + i18n.strings_ca[help_text] = i18n.help_ca; + i18n.strings_cs[help_text] = i18n.help_cs; + i18n.strings_nl[help_text] = i18n.help_nl; + i18n.strings_de[help_text] = i18n.help_de; + i18n.strings_pl[help_text] = i18n.help_pl; + i18n.strings_fr[help_text] = i18n.help_fr; + i18n.strings_hu[help_text] = i18n.help_hu; + i18n.strings_it[help_text] = i18n.help_it; + i18n.strings_el[help_text] = i18n.help_el; + i18n.strings_ja[help_text] = i18n.help_ja; + i18n.strings_zh[help_text] = i18n.help_zh; + i18n.strings_ru[help_text] = i18n.help_ru; + i18n.strings_sv[help_text] = i18n.help_sv; + + w3c_slidy.lang = document.body.parentNode.getAttribute("lang"); + + if (!w3c_slidy.lang) + w3c_slidy.lang = document.body.parentNode.getAttribute("xml:lang"); + + if (!w3c_slidy.lang) + w3c_slidy.lang = "en"; + } +}; + +// hack for back button behavior +if (w3c_slidy.ie6 || w3c_slidy.ie7) +{ + document.write(""); +} + +// attach event listeners for initialization +w3c_slidy.set_up(); + +// hide the slides as soon as body element is available +// to reduce annoying screen mess before the onload event +setTimeout(w3c_slidy.hide_slides, 50); + diff --git a/slidy2/styles/.htaccess b/slidy2/styles/.htaccess new file mode 100644 index 0000000..d395348 --- /dev/null +++ b/slidy2/styles/.htaccess @@ -0,0 +1,28 @@ +Options +MultiViews +LanguagePriority en +AddLanguage pt-br .pt-br + + + +ForceType 'text/html; charset=utf-8' + + + + + +ForceType 'application/xhtml+xml; charset=utf-8' + + + + + +ForceType 'text/css; charset=utf-8' + + + + + +ForceType 'text/javascript; charset=utf-8' + + +mkdir diff --git a/slidy2/styles/print.css b/slidy2/styles/print.css new file mode 100644 index 0000000..fbe0e3b --- /dev/null +++ b/slidy2/styles/print.css @@ -0,0 +1,58 @@ +/* print.css + + Copyright (c) 2005 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software +*/ +body { + color: black; + font-family: sans-serif; + font-size: 12pt; +} + +div.slide { page-break-before: always; page-break-inside: avoid; } +div.background { display: none; + visibility: hidden; page-break-after: avoid; } +div.handout { display: block; visibility: visible; } + +div dt +{ + margin-left: 0; + margin-top: 1em; + margin-bottom: 0.5em; + font-weight: bold; +} +div dd +{ + margin-left: 2em; +} + +blockquote { font-style: italic } + +pre { color: rgb(0,128,0); font-size: 80%; + font-weight: bold; line-height: 120%; } + +p.copyright { font-size: smaller } + +a:visited { color: navy } +a:link { color: blue } +a:hover { color: red } +a:active { color: red } + +a {text-decoration : none} +.navbar a:link {color: white} +.navbar a:visited {color: yellow} +.navbar a:active {color: red} +.navbar a:hover {color: red} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; } +li li { font-size: 80%; font-style: italic } +li li li { font-size: 80%; font-style: normal } + diff --git a/slidy2/styles/slidy.css b/slidy2/styles/slidy.css new file mode 100644 index 0000000..5e076e4 --- /dev/null +++ b/slidy2/styles/slidy.css @@ -0,0 +1,411 @@ +/* slidy.css + + Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software +*/ +body +{ + margin: 0 0 0 0; + padding: 0 0 0 0; + width: 100%; + height: 100%; + color: black; + background-color: white; + font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif; + font-size: 14pt; +} + +div.toolbar { + position: fixed; z-index: 200; + top: auto; bottom: 0; left: 0; right: 0; + height: 1.2em; text-align: right; + padding-left: 1em; + padding-right: 1em; + font-size: 60%; + color: red; + background-color: rgb(240,240,240); + border-top: solid 1px rgb(180,180,180); +} + +div.toolbar span.copyright { + color: black; + margin-left: 0.5em; +} + +div.initial_prompt { + position: absolute; + z-index: 1000; + bottom: 1.2em; + width: 100%; + background-color: rgb(200,200,200); + opacity: 0.35; + background-color: rgb(200,200,200, 0.35); + cursor: pointer; +} + +div.initial_prompt p.help { + text-align: center; +} + +div.initial_prompt p.close { + text-align: right; + font-style: italic; +} + +div.slidy_toc { + position: absolute; + z-index: 300; + width: 60%; + max-width: 30em; + height: 30em; + overflow: auto; + top: auto; + right: auto; + left: 4em; + bottom: 4em; + padding: 1em; + background: rgb(240,240,240); + border-style: solid; + border-width: 2px; + font-size: 60%; +} + +div.slidy_toc .toc_heading { + text-align: center; + width: 100%; + margin: 0; + margin-bottom: 1em; + border-bottom-style: solid; + border-bottom-color: rgb(180,180,180); + border-bottom-width: 1px; +} + +div.slide { + z-index: 20; + margin: 0 0 0 0; + padding-top: 0; + padding-bottom: 0; + padding-left: 20px; + padding-right: 20px; + border-width: 0; + clear: both; + top: 0; + bottom: 0; + left: 0; + right: 0; + line-height: 120%; + background-color: transparent; +} + +div.background { + display: none; +} + +div.handout { + margin-left: 20px; + margin-right: 20px; +} + +div.slide.titlepage { + text-align: center; +} + +div.slide.titlepage h1 { + padding-top: 10%; + margin-right: 0; +} + +div.slide h1 { + padding-left: 0; + padding-right: 20pt; + padding-top: 4pt; + padding-bottom: 4pt; + margin-top: 0; + margin-left: 0; + margin-right: 60pt; + margin-bottom: 0.5em; + display: block; + font-size: 160%; + line-height: 1.2em; + background: transparent; +} + +@media screen and (max-device-width: 1024px) +{ + div.slide { font-size: 100%; } +} + +@media screen and (max-device-width: 800px) +{ + div.slide { font-size: 200%; } + div.slidy_toc { + top: 1em; + left: 1em; + right: auto; + width: 80%; + font-size: 180%; + } +} + +div.toc-heading { + width: 100%; + border-bottom: solid 1px rgb(180,180,180); + margin-bottom: 1em; + text-align: center; +} + +img { + image-rendering: optimize-quality; +} + +pre { + font-size: 80%; + font-weight: bold; + line-height: 120%; + padding-top: 0.2em; + padding-bottom: 0.2em; + padding-left: 1em; + padding-right: 1em; + border-style: solid; + border-left-width: 1em; + border-top-width: thin; + border-right-width: thin; + border-bottom-width: thin; + border-color: #95ABD0; + color: #00428C; + background-color: #E4E5E7; +} + +li pre { margin-left: 0; } + +blockquote { font-style: italic } + +img { background-color: transparent } + +p.copyright { font-size: smaller } + +.center { text-align: center } +.footnote { font-size: smaller; margin-left: 2em; } + +a img { border-width: 0; border-style: none } + +a:visited { color: navy } +a:link { color: navy } +a:hover { color: red; text-decoration: underline } +a:active { color: red; text-decoration: underline } + +a {text-decoration: none} +.toolbar a:link {color: blue} +.toolbar a:visited {color: blue} +.toolbar a:active {color: red} +.toolbar a:hover {color: red} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + +div dt +{ + margin-left: 0; + margin-top: 1em; + margin-bottom: 0.5em; + font-weight: bold; +} +div dd +{ + margin-left: 2em; + margin-bottom: 0.5em; +} + + +p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table { + margin-left: 1em; + margin-right: 1em; +} + +p.subhead { font-weight: bold; margin-top: 2em; } + +.smaller { font-size: smaller } +.bigger { font-size: 130% } + +td,th { padding: 0.2em } + +ul { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ol { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } + +ul li { + list-style: square; + margin: 0.1em 0em 0.6em 0; + padding: 0 0 0 0; + line-height: 140%; +} + +ol li { + margin: 0.1em 0em 0.6em 1.5em; + padding: 0 0 0 0px; + line-height: 140%; + list-style-type: decimal; +} + +li ul li { + font-size: 85%; + font-style: italic; + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} +li li ul li { + font-size: 85%; + font-style: normal; + list-style-type: circle; + background: transparent; + padding: 0 0 0 0; +} +li li li ul li { + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} + +li ol li { + list-style-type: decimal; +} + + +li li ol li { + list-style-type: decimal; +} + +/* + setting class="outline on ol or ul makes it behave as an + ouline list where blocklevel content in li elements is + hidden by default and can be expanded or collapsed with + mouse click. Set class="expand" on li to override default +*/ + +ol.outline li:hover { cursor: pointer } +ol.outline li.nofold:hover { cursor: default } + +ul.outline li:hover { cursor: pointer } +ul.outline li.nofold:hover { cursor: default } + +ol.outline { list-style:decimal; } +ol.outline ol { list-style-type:lower-alpha } + +ol.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em; +} +ol.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em; +} +ol.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em; +} + +ul.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.5em; +} +ul.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.5em; +} +ul.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.5em; +} + +/* for slides with class "title" in table of contents */ +a.titleslide { font-weight: bold; font-style: italic } + +/* + hide images for work around for save as bug + where browsers fail to save images used by CSS +*/ +img.hidden { display: none; visibility: hidden } +div.initial_prompt { display: none; visibility: hidden } + + div.slide { + visibility: visible; + position: inherit; + } + div.handout { + border-top-style: solid; + border-top-width: thin; + border-top-color: black; + } + +@media screen { + .hidden { display: none; visibility: visible } + + div.slide.hidden { display: block; visibility: visible } + div.handout.hidden { display: block; visibility: visible } + div.background { display: none; visibility: hidden } + body.single_slide div.initial_prompt { display: block; visibility: visible } + body.single_slide div.background { display: block; visibility: visible } + body.single_slide div.background.hidden { display: none; visibility: hidden } + body.single_slide .invisible { visibility: hidden } + body.single_slide .hidden { display: none; visibility: hidden } + body.single_slide div.slide { position: absolute } + body.single_slide div.handout { display: none; visibility: hidden } +} + +@media print { + .hidden { display: block; visibility: visible } + + div.slide { page-break-after: always; } + + div.slide pre { font-size: 60%; padding-left: 0.5em; } + div.toolbar { display: none; visibility: hidden; } + div.slidy_toc { display: none; visibility: hidden; } + div.background { display: none; visibility: hidden; } + + div.slide { page-break-before: always } + + /* :first-child isn't reliable for print media */ + div.slide.first-slide { page-break-before: avoid } + + div#pagewidth { + display: inline ; + } +} + diff --git a/slidy2/styles/w3c-blue.css b/slidy2/styles/w3c-blue.css new file mode 100644 index 0000000..00ac96a --- /dev/null +++ b/slidy2/styles/w3c-blue.css @@ -0,0 +1,497 @@ +/* w3c-blue.css + + Copyright (c) 2005-2010 W3C (MIT, ERCIM, Keio), All Rights Reserved. + W3C liability, trademark, document use and software licensing + rules apply, see: + + http://www.w3.org/Consortium/Legal/copyright-documents + http://www.w3.org/Consortium/Legal/copyright-software +*/ +body +{ + margin: 0 0 0 0; + padding: 0 0 0 0; + width: 100%; + height: 100%; + color: black; + background-color: white; + font-family: "Gill Sans MT", "Gill Sans", GillSans, sans-serif; + font-size: 14pt; +} + +div.slide.titlepage { + text-align: center; +} + +div.slide.titlepage h1 { + padding-top: 40%; +} + +div.slide { + z-index: 20; + margin: 0 0 0 0; + padding: 0; + border-width: 0; + top: 0; + bottom: 0; + left: 0; + right: 0; + line-height: 100%; + background-color: transparent; +} + +div.background { + z-index: 1; + position: absolute; + vertical-align: bottom; + left: 0; + right: 0; + top: 0; + bottom: auto; + height: 3.8em; /*4.1em; */ + padding: 0 0 0 0.2em; + margin: 0 0 0 0; + border-width: 0; + background-color: #121220; /* #728ec2; */ +} + +div.background img { + height: 4em; +} + +/* this rule is hidden from IE which doesn't support + selector */ +div.slide + div[class].slide { page-break-before: always;} + +div.slide h1 { + padding-left: 6em; + padding-right: 3em; + padding-top: 0.1em; + margin-bottom: 0.8em; + margin-top: 0.9em; /* -0.05em; */ + margin-left: 0; + margin-right: 0; + min-height: 2.3em; + color: white; + height: 2.2em; + font-size: 140%; + line-height: 1.1em; +} + +div.slide h1 a { + color: white; + text-decoration: none; +} + +div.slide h1 a:link { + color: white; + text-decoration: none; +} + +div.slide h1 a:visited { + color: white; + text-decoration: none; +} + +div.slide h1 a:hover { + color: white; + text-decoration: underline; +} + +div.slide h1 a:active { + color: red; + text-decoration: underline; +} + +#head-icon { + margin-top: 0.5em; + margin-bottom: 0; + margin-left: 0;/* + margin-right: 1em; + background: #121220; + border-width: 0; + height: 3em; + max-width: 3em;*/ + z-index: 2; + float: left; +} + +#head-logo { + margin: 0; + margin-top: 0.25em; + padding-top: 0.25em; + padding-bottom: 0.2em; + padding-left: 0; + padding-right: 0; + height: 3.2em; + width: 4.8em; + float: right; + z-index: 2; + background: #121220; +} + +#head-logo-fallback { + margin: 0; + padding: 0; + margin-top: -0.8em; + width: 4.8em; + float: right; + z-index: 2; +} + +/* the next two classes support vertical and horizontal centering */ +div.vbox { + float: left; + height: 40%; + width: 50%; + margin-top: -240px; +} +div.hbox { + width:60%; + margin-top: 0; + margin-left:auto; + margin-right:auto; + height: 60%; + border:1px solid silver; + background:#F0F0F0; + overflow:auto; + text-align:left; + clear:both; +} + +/* styling for named background */ +div.background.slanty { + z-index: 2; + bottom: 0; + height: 100%; + background: transparent; +} + +div.background.slanty img { margin-top: 4em; width: 100%; height: 80% } + +/* the following makes the pre background translucent */ +/* opacity is a CSS3 property but supported by Mozilla family */ +/* filter is an IE specific feature that also requires width */ +div.slide.slanty pre { + width: 93%; /* needed for IE filter to work */ + opacity: .8; + filter: alpha(opacity=80); +} + +img.withBorder { + border: 2px solid #c60; + padding: 4px; +} + +li pre { margin-left: 0; } + +@media print { pre { font-size: 60% } } + +blockquote { font-style: italic } + +img { background-color: transparent } + +p.copyright { font-size: smaller } + +.center { text-align: center } +.footnote { font-size: smaller; margin-left: 2em; } + +a img { border-width: 0; border-style: none } + +a:visited { color: navy } +a:link { color: navy } +a:hover { color: red; text-decoration: underline } +a:active { color: red; text-decoration: underline } + +a {text-decoration: none} +.navbar a:link {color: white} +.navbar a:visited {color: yellow} +.navbar a:active {color: red} +.navbar a:hover {color: red} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + +div dt +{ + margin-left: 0; + margin-top: 1em; + margin-bottom: 0.5em; + font-weight: bold; +} +div dd +{ + margin-left: 2em; + margin-bottom: 0.5em; +} + + +p,pre,ul,ol,blockquote,h2,h3,h4,h5,h6,dl,table { + margin-left: 1em; + margin-right: 1em; +} + +p.subhead { font-weight: bold; margin-top: 2em; } + +div.cover p.explanation { + font-style: italic; + margin-top: 3em; +} + + +.smaller { font-size: smaller } + +td,th { padding: 0.2em } + +ul { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ol { + margin: 0.5em 1.5em 0.5em 1.5em; + padding: 0; +} + +ul { list-style-type: square; } +ul ul { list-style-type: disc; } +ul ul ul { list-style-type: circle; } +ul ul ul ul { list-style-type: disc; } +li { margin-left: 0.5em; margin-top: 0.5em; } +li li { font-size: 85%; font-style: italic } +li li li { font-size: 85%; font-style: normal } + + +ul li { + list-style: none; + margin: 0.1em 0em 0.6em 0; + padding: 0 0 0 40px; + background: transparent url(../graphics/bullet.png) no-repeat 5px 0.3em; + line-height: 140%; +} + +/* workaround IE's failure to support background on li for print media */ +@media print { ul li { list-style: disc; padding-left: 0; background: none; } } + +ol li { + margin: 0.1em 0em 0.6em 1.5em; + padding: 0 0 0 0px; + line-height: 140%; +} + +li li { + font-size: 85%; + font-style: italic; + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} +li li li { + font-size: 85%; + font-style: normal; + list-style-type: circle; + background: transparent; + padding: 0 0 0 0; +} +li li li li { + list-style-type: disc; + background: transparent; + padding: 0 0 0 0; +} + +/* rectangular blue bullet + unfold/nofold/fold widget */ + +/* + setting class="outline on ol or ul makes it behave as an + ouline list where blocklevel content in li elements is + hidden by default and can be expanded or collapsed with + mouse click. Set class="expand" on li to override default +*/ + +ol.outline li:hover { cursor: pointer } +ol.outline li.nofold:hover { cursor: default } + +ul.outline li:hover { cursor: pointer } +ul.outline li.nofold:hover { cursor: default } + +ol.outline { list-style:decimal; } +ol.outline ol { list-style-type:lower-alpha } + +ol.outline li.nofold { + padding: 0 0 0 20px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.unfolded { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.folded { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 0px 0.3em; +} +ol.outline li.unfolded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/fold.gif) no-repeat 0px 0.3em; +} +ol.outline li.folded:hover { + padding: 0 0 0 20px; + background: transparent url(../graphics/unfold.gif) no-repeat 0px 0.3em; +} + +ul.outline li.nofold { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-nofold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.unfolded { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-fold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.folded { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-unfold-dim.gif) no-repeat 5px 0.3em; +} +ul.outline li.unfolded:hover { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-fold.gif) no-repeat 5px 0.3em; +} +ul.outline li.folded:hover { + padding: 0 0 0 52px; + background: transparent url(../graphics/bullet-unfold.gif) no-repeat 5px 0.3em; +} + +li ul.outline li.nofold { + padding: 0 0 0 21px; + background: transparent url(../graphics/nofold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.unfolded { + padding: 0 0 0 21px; + background: transparent url(../graphics/fold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.folded { + padding: 0 0 0 21px; + background: transparent url(../graphics/unfold-dim.gif) no-repeat 5px 0.3em; +} +li ul.outline li.unfolded:hover { + padding: 0 0 0 21px; + background: transparent url(../graphics/fold.gif) no-repeat 5px 0.3em; +} +li ul.outline li.folded:hover { + padding: 0 0 0 21px; + background: transparent url(../graphics/unfold.gif) no-repeat 5px 0.3em; +} + +img { + image-rendering: optimize-quality; +} + +img.withBorder { + border: 2px solid #c60; + padding: 4px; +} + +div.header { + position: absolute; + z-index: 2; + left: 0; + right: 0; + top: 0; + bottom: auto; + height: 2.95em; + width: 100%; + padding: 0 0 0 0; + margin: 0 0 0 0; + border-width: 0; + border-style: solid; + background-color: #005A9C; + border-bottom-width: thick; + border-bottom-color: #95ABD0; +} + +div.footer { + position: absolute; + z-index: 80; + left: 0; + right: 0; + top: auto; + bottom: 0; + height: 3.5em; + margin: 0; + font-size: 80%; + font-weight: bold; + padding-left: 1em; + padding-right: 0; + padding-top: 0.3em; + padding-bottom: 0; + color: #003366; + background-color: #95ABD0; +} + +/* this is a hack to hide property from IE6 and below */ +div[class="footer"] { + position: fixed; +} + +#hidden-bullet { + visibility: hidden; + display: none; +} + +div.slide.cover { + color: white; + background-color: #121220; + padding-top: 0; + padding-right: 0; + padding-left: 3em; + height: 100%; +} + +div.slide.cover h1 { + margin: 0; + padding: 0.5em; + color: white; + height: auto; +} + +div.slide.cover h2 { + color: white; +} + +div.slide.cover a { + color: white; +} + +div.slide.cover a:visited { color: white } +div.slide.cover a:link { color: white } +div.slide.cover a:hover { color: yellow; text-decoration: underline } +div.slide.cover a:active { color: yellow; text-decoration: underline } + +div.slide.cover a:hover, div.slide.cover a:active { + color: yellow; text-decoration: underline; +} + +div.slide.cover img.cover { + margin: 0 0 0 0; + float: right; + padding-bottom: 4em; + width: 50%; + overflow: hidden; +} + +div.slide.cover a:hover, div.slide.cover a:active { + color: yellow; text-decoration: underline; +} + +/* for Bert as an ardent user of the old W3C slidemaker tool */ + +div.comment { display: none; visibility: hidden } + +@media print { + div.slide h1 { background: transparent; color: black } + div.slide.cover { background: transparent; color: black } + div.slide.cover h1 { background: transparent; color: black } + div.comment { display: block; visibility: visible } +}