diff --git a/pandoc/defaults/docx.yaml b/pandoc/defaults/docx.yaml index ab27c0e..e051e0a 100644 --- a/pandoc/defaults/docx.yaml +++ b/pandoc/defaults/docx.yaml @@ -2,9 +2,9 @@ from: markdown citeproc: true csl: chicago-fullnote-bibliography-sl -filters: - - localize_quotes.lua - - delink.lua reference-doc: reference-sl.docx to: docx +filters: +- localize_quotes.lua +- delink.lua ... diff --git a/pandoc/defaults/bavbavhaus.net.yaml b/pandoc/defaults/html.yaml similarity index 100% rename from pandoc/defaults/bavbavhaus.net.yaml rename to pandoc/defaults/html.yaml diff --git a/pandoc/defaults/s5.yaml b/pandoc/defaults/s5.yaml deleted file mode 100644 index 56bcfd4..0000000 --- a/pandoc/defaults/s5.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -template: default -from: markdown+wikilinks_title_before_pipe -to: s5 -standalone: true -embed-resources: true -citeproc: true -csl: chicago-fullnote-bibliography-sl -filters: - - pandoc-quotes.lua -... diff --git a/pandoc/filters/resolve_internal_links.lua b/pandoc/filters/resolve_internal_links.lua index 73067c8..632ee0d 100644 --- a/pandoc/filters/resolve_internal_links.lua +++ b/pandoc/filters/resolve_internal_links.lua @@ -5,20 +5,17 @@ local Inlines = pandoc.Inlines return { { Link = function(l) - -- early return for external links - if l.target:find("^https?%:%/%/") then return end -- @todo resolve external links - if l.target:find("^mailto%:") then return end - - local fp, slug, anchor = l.target:match("^((.+)%.md)#?(.*)$") - -- early return for non markdown files + local fp = l.target:match("^(.+%.md)#?.*$") if not fp then return end - + local f = io.open(fp) - -- early return for broken internal links - if f == nil then return l.content else f:close() end -- @todo maybe log broken internal links + if f == nil then + print(("[WARNING] Broken link: %s"):format(l.target)) -- TODO: update for pandoc.info + return l.content + end + f:close() - l.target = ("%s.html#%s"):format(slug, anchor) - l.attributes.target = "internal" + l.target = l.target:gsub("^(.+)%.md(#?.*)$", "%1.html%2") return l end } diff --git a/pandoc/filters/wordcount.lua b/pandoc/filters/wordcount.lua new file mode 100644 index 0000000..ed72778 --- /dev/null +++ b/pandoc/filters/wordcount.lua @@ -0,0 +1,29 @@ +-- counts words in a document + +words = 0 + +wordcount = { + Str = function(el) + -- we don't count a word if it's entirely punctuation: + if el.text:match("%P") then + words = words + 1 + end + end, + + Code = function(el) + _,n = el.text:gsub("%S+","") + words = words + n + end, + + CodeBlock = function(el) + _,n = el.text:gsub("%S+","") + words = words + n + end +} + +function Pandoc(el) + -- skip metadata, just count body: + el.blocks:walk(wordcount) + print(words .. " words in body") + os.exit(0) +end \ No newline at end of file diff --git a/pandoc/logging.lua b/pandoc/logging.lua deleted file mode 100644 index c96bb08..0000000 --- a/pandoc/logging.lua +++ /dev/null @@ -1,270 +0,0 @@ ---[[ - logging.lua: pandoc-aware logging functions (can also be used standalone) - Copyright: (c) 2022 William Lupton - License: MIT - see LICENSE file for details - Usage: See README.md for details -]] - --- if running standalone, create a 'pandoc' global -if not pandoc then - _G.pandoc = {utils = {}} -end - --- if there's no pandoc.utils, create a local one -if not pcall(require, 'pandoc.utils') then - pandoc.utils = {} -end - --- if there's no pandoc.utils.type, create a local one -if not pandoc.utils.type then - pandoc.utils.type = function(value) - local typ = type(value) - if not ({table=1, userdata=1})[typ] then - -- unchanged - elseif value.__name then - typ = value.__name - elseif value.tag and value.t then - typ = value.tag - if typ:match('^Meta.') then - typ = typ:sub(5) - end - if typ == 'Map' then - typ = 'table' - end - end - return typ - end -end - --- namespace -local logging = {} - --- helper function to return a sensible typename -logging.type = function(value) - -- this can return 'Inlines', 'Blocks', 'Inline', 'Block' etc., or - -- anything that built-in type() can return, namely 'nil', 'number', - -- 'string', 'boolean', 'table', 'function', 'thread', or 'userdata' - local typ = pandoc.utils.type(value) - - -- it seems that it can also return strings like 'pandoc Row'; replace - -- spaces with periods - -- XXX I'm not sure that this is done consistently, e.g. I don't think - -- it's done for pandoc.Attr or pandoc.List? - typ = typ:gsub(' ', '.') - - -- map Inline and Block to the tag name - -- XXX I guess it's intentional that it doesn't already do this? - return ({Inline=1, Block=1})[typ] and value.tag or typ -end - --- derived from https://www.lua.org/pil/19.3.html pairsByKeys() -logging.spairs = function(list, comp) - local keys = {} - for key, _ in pairs(list) do - table.insert(keys, tostring(key)) - end - table.sort(keys, comp) - local i = 0 - local iter = function() - i = i + 1 - return keys[i] and keys[i], list[keys[i]] or nil - end - return iter -end - --- helper function to dump a value with a prefix (recursive) --- XXX should detect repetition/recursion --- XXX would like maxlen logic to apply at all levels? but not trivial -local function dump_(prefix, value, maxlen, level, add) - local buffer = {} - if prefix == nil then prefix = '' end - if level == nil then level = 0 end - if add == nil then add = function(item) table.insert(buffer, item) end end - local indent = maxlen and '' or (' '):rep(level) - - -- get typename, mapping to pandoc tag names where possible - local typename = logging.type(value) - - -- don't explicitly indicate 'obvious' typenames - local typ = (({boolean=1, number=1, string=1, table=1, userdata=1}) - [typename] and '' or typename) - - -- light userdata is just a pointer (can't iterate over it) - -- XXX is there a better way of checking for light userdata? - if type(value) == 'userdata' and not pcall(pairs(value)) then - value = tostring(value):gsub('userdata:%s*', '') - - -- modify the value heuristically - elseif ({table=1, userdata=1})[type(value)] then - local valueCopy, numKeys, lastKey = {}, 0, nil - for key, val in pairs(value) do - -- pandoc >= 2.15 includes 'tag', nil values and functions - if key ~= 'tag' and val and type(val) ~= 'function' then - valueCopy[key] = val - numKeys = numKeys + 1 - lastKey = key - end - end - if numKeys == 0 then - -- this allows empty tables to be formatted on a single line - -- XXX experimental: render Doc objects - value = typename == 'Doc' and '|' .. value:render() .. '|' or - typename == 'Space' and '' or '{}' - elseif numKeys == 1 and lastKey == 'text' then - -- this allows text-only types to be formatted on a single line - typ = typename - value = value[lastKey] - typename = 'string' - else - value = valueCopy - -- XXX experimental: indicate array sizes - if #value > 0 then - typ = typ .. '[' .. #value .. ']' - end - end - end - - -- output the possibly-modified value - local presep = #prefix > 0 and ' ' or '' - local typsep = #typ > 0 and ' ' or '' - local valtyp = type(value) - if valtyp == 'nil' then - add('nil') - elseif ({boolean=1, number=1, string=1})[valtyp] then - typsep = #typ > 0 and valtyp == 'string' and #value > 0 and ' ' or '' - -- don't use the %q format specifier; doesn't work with multi-bytes - local quo = typename == 'string' and '"' or '' - add(string.format('%s%s%s%s%s%s%s%s', indent, prefix, presep, typ, - typsep, quo, value, quo)) - -- light userdata is just a pointer (can't iterate over it) - -- XXX is there a better way of checking for light userdata? - elseif valtyp == 'userdata' and not pcall(pairs(value)) then - add(string.format('%s%s%s%s %s', indent, prefix, presep, typ, - tostring(value):gsub('userdata:%s*', ''))) - elseif ({table=1, userdata=1})[valtyp] then - add(string.format('%s%s%s%s%s{', indent, prefix, presep, typ, typsep)) - -- Attr and Attr.attributes have both numeric and string keys, so - -- ignore the numeric ones - -- XXX this is no longer the case for pandoc >= 2.15, so could remove - -- the special case? - local first = true - if prefix ~= 'attributes:' and typ ~= 'Attr' then - for i, val in ipairs(value) do - local pre = maxlen and not first and ', ' or '' - dump_(string.format('%s[%s]', pre, i), val, maxlen, - level + 1, add) - first = false - end - end - -- report keys in alphabetical order to ensure repeatability - for key, val in logging.spairs(value) do - local pre = maxlen and not first and ', ' or '' - -- this check can avoid an infinite loop, e.g. with metatables - -- XXX should have more general and robust infinite loop avoidance - if key:match('^__') and type(val) ~= 'string' then - add(string.format('%s%s: %s', pre, key, tostring(val))) - - -- pandoc >= 2.15 includes 'tag' - elseif not tonumber(key) and key ~= 'tag' then - dump_(string.format('%s%s:', pre, key), val, maxlen, - level + 1, add) - end - first = false - end - add(string.format('%s}', indent)) - end - return table.concat(buffer, maxlen and '' or '\n') -end - -logging.dump = function(value, maxlen) - if maxlen == nil then maxlen = 70 end - local text = dump_(nil, value, maxlen) - if #text > maxlen then - text = dump_(nil, value, nil) - end - return text -end - -logging.output = function(...) - local need_newline = false - for i, item in ipairs({...}) do - -- XXX space logic could be cleverer, e.g. no space after newline - local maybe_space = i > 1 and ' ' or '' - local text = ({table=1, userdata=1})[type(item)] and - logging.dump(item) or tostring(item) - io.stderr:write(maybe_space, text) - need_newline = text:sub(-1) ~= '\n' - end - if need_newline then - io.stderr:write('\n') - end -end - --- basic logging support (-1=errors, 0=warnings, 1=info, 2=debug, 3=debug2) --- XXX should support string levels? -logging.loglevel = 0 - --- set log level and return the previous level -logging.setloglevel = function(loglevel) - local oldlevel = logging.loglevel - logging.loglevel = loglevel - return oldlevel -end - --- verbosity default is WARNING; --quiet -> ERROR and --verbose -> INFO --- --trace sets TRACE or DEBUG (depending on --verbose) -if type(PANDOC_STATE) == 'nil' then - -- use the default level -elseif PANDOC_STATE.trace then - logging.loglevel = PANDOC_STATE.verbosity == 'INFO' and 3 or 2 -elseif PANDOC_STATE.verbosity == 'INFO' then - logging.loglevel = 1 -elseif PANDOC_STATE.verbosity == 'WARNING' then - logging.loglevel = 0 -elseif PANDOC_STATE.verbosity == 'ERROR' then - logging.loglevel = -1 -end - -logging.error = function(...) - if logging.loglevel >= -1 then - logging.output('(E)', ...) - end -end - -logging.warning = function(...) - if logging.loglevel >= 0 then - logging.output('(W)', ...) - end -end - -logging.info = function(...) - if logging.loglevel >= 1 then - logging.output('(I)', ...) - end -end - -logging.debug = function(...) - if logging.loglevel >= 2 then - logging.output('(D)', ...) - end -end - -logging.debug2 = function(...) - if logging.loglevel >= 3 then - logging.warning('debug2() is deprecated; use trace()') - logging.output('(D2)', ...) - end -end - -logging.trace = function(...) - if logging.loglevel >= 3 then - logging.output('(T)', ...) - end -end - --- for temporary unconditional debug output -logging.temp = function(...) - logging.output('(#)', ...) -end - -return logging diff --git a/pandoc/s5/default/framing.css b/pandoc/s5/default/framing.css deleted file mode 100644 index bd71c97..0000000 --- a/pandoc/s5/default/framing.css +++ /dev/null @@ -1,23 +0,0 @@ -/* layout */ -body { - width: 100vw; - height: 100vh; - max-width: 100vw; - max-height: 100vh; - display: grid; - grid-template-rows: 1fr auto; -} - -body>main { - max-width: 100%; - max-height: 100%; - display: grid; -} - -body>footer { - z-index: 100; -} - -.slide { - z-index: 2; -} diff --git a/pandoc/s5/default/iepngfix.htc b/pandoc/s5/default/iepngfix.htc deleted file mode 100644 index 7099619..0000000 --- a/pandoc/s5/default/iepngfix.htc +++ /dev/null @@ -1,103 +0,0 @@ - - - - - diff --git a/pandoc/s5/default/opera.css b/pandoc/s5/default/opera.css deleted file mode 100644 index 9e9d2a3..0000000 --- a/pandoc/s5/default/opera.css +++ /dev/null @@ -1,7 +0,0 @@ -/* DO NOT CHANGE THESE unless you really want to break Opera Show */ -.slide { - visibility: visible !important; - position: static !important; - page-break-before: always; -} -#slide0 {page-break-before: avoid;} diff --git a/pandoc/s5/default/outline.css b/pandoc/s5/default/outline.css deleted file mode 100644 index 62db519..0000000 --- a/pandoc/s5/default/outline.css +++ /dev/null @@ -1,15 +0,0 @@ -/* don't change this unless you want the layout stuff to show up in the outline view! */ - -.layout div, #footer *, #controlForm * {display: none;} -#footer, #controls, #controlForm, #navLinks, #toggle { - display: block; visibility: visible; margin: 0; padding: 0;} -#toggle {float: right; padding: 0.5em;} -html>body #toggle {position: fixed; top: 0; right: 0;} - -/* making the outline look pretty-ish */ - -#slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;} -#slide0 h1 {padding-top: 1.5em;} -.slide h1 {margin: 1.5em 0 0; padding-top: 0.25em; - border-top: 1px solid #888; border-bottom: 1px solid #AAA;} -#toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;} diff --git a/pandoc/s5/default/pretty.css b/pandoc/s5/default/pretty.css deleted file mode 100644 index 91811e1..0000000 --- a/pandoc/s5/default/pretty.css +++ /dev/null @@ -1,322 +0,0 @@ -/* variables */ -:root { - --font-size: 18pt; - --line-height: 1.25; - --font-family: monospace; - - /* font-derived width and height units */ - --w-un: 1ch; - --h-un: calc(var(--font-size) * var(--line-height)); - - /* colors */ - --fg-c: #e2e2e2; - --bg-c: #000000; - --blue-c: #856cff; - --magenta-c: #ff1170; -} - -/* reset */ -* { - box-sizing: inherit; - margin: unset; -} - -:root { - box-sizing: border-box; - color: var(--fg-c); - background-color: var(--bg-c); - font: var(--font-size)/var(--line-height) var(--font-family); -} - -:link, :visited { - text-decoration: none; - color: var(--blue-c); -} - -h1, h2, h3, h4, h5, h6 { - color: var(--magenta-c); - font: inherit; -} - -button { - border: unset; - background: unset; - font: inherit; - cursor: pointer; -} - -select { - appearance: none; - border: unset; - background: unset; - font: inherit; - cursor: pointer; -} - -div { - max-height: 100%; -} - -.float { - height: 100%; - display: grid; - grid-template-rows: 1fr auto; -} - -img { - background: var(--fg-c); -} - -.figcaption { - -} - -/* layout */ -.slide { - max-height: 100%; - padding: var(--h-un) var(--w-un); -} - - -/* footer */ -body>footer { - display: grid; - grid-auto-flow: column; - grid-auto-columns: 1fr; - justify-items: center; -} - -body>footer * { - max-width: 100%; - color: var(--blue-c); - text-transform: lowercase; - overflow-x: hidden; - text-overflow: ellipsis; -} - -body>footer :active { - color: var(--magenta-c); -} - -/* s5 #slide0 */ -#slide0 { -} - -#slide0 h1 { /* title */ - /* position: static; - margin: 1em 0 0; - padding: 0; - font: bold 2em Helvetica, sans-serif; - white-space: normal; - background: transparent; */ -} - -#slide0 h2 { /* subtitle */ -} - -#slide0 h3 { /* author */ -} - -#slide0 h4 { /* date */ -} - -#slide0 #footer { - -} - - -ul, pre { - margin: 0; - line-height: 1em; -} - -blockquote { - padding: 0 2em 0.5em; - margin: 0 1.5em 0.5em; - text-align: center; - font-size: 1em; -} - -blockquote p { - margin: 0; -} - -blockquote i { - font-style: normal; -} - -blockquote b { - display: block; - margin-top: 0.5em; - font-weight: normal; - font-size: smaller; - font-style: normal; -} - -blockquote b i { - font-style: italic; -} - -kbd { - font-weight: bold; - font-size: 1em; -} - -sup { - font-size: smaller; - line-height: 1px; -} - -.slide code { - padding: 2px 0.25em; - font-weight: bold; - color: #533; -} - -.slide code.bad, code del { - color: red; -} - -.slide code.old { - color: silver; -} - -.slide pre { - padding: 0; - margin: 0.25em 0 0.5em 0.5em; - color: #533; - font-size: 90%; -} - -.slide pre code { - display: block; -} - -.slide ul { - margin-left: 5%; - margin-right: 7%; - list-style: disc; -} - -.slide li { - margin-top: 0.75em; - margin-right: 0; -} - -.slide ul ul { - line-height: 1; -} - -.slide ul ul li { - margin: .2em; - font-size: 85%; - list-style: square; -} - -.slide img.leader { - display: block; - margin: 0 auto; -} - -div.long { - font-size: 0.75em; -} - -.slide h1 { -} - -.slide h3 { -} - -h1 abbr { - font-variant: small-caps; -} - -div#controls { - position: absolute; - left: 50%; - bottom: 0; - width: 50%; - text-align: right; - /* font: bold 0.9em Verdana, Helvetica, sans-serif; */ -} - -html>body div#controls { - position: fixed; - padding: 0 0 1em 0; - top: auto; -} - -div#controls form { - position: absolute; - bottom: 0; - right: 0; - width: 100%; - margin: 0; - padding: 0; -} - -#controls #navLinks a { - padding: 0; - margin: 0 0.5em; - - background: #005; - border: none; - color: #779; - - cursor: pointer; -} - -#controls #navList { - height: 1em; -} - -#controls #navList #jumplist { - position: absolute; - bottom: 0; - right: 0; - background: #DDD; - color: #227; -} - -ul.urls { - list-style: none; - display: inline; - margin: 0; -} - -.urls li { - display: inline; - margin: 0; -} - -.note { - display: none; -} - -.external { - border-bottom: 1px dotted gray; -} - -html>body .external { - border-bottom: none; -} - -.external:after { - content: " \274F"; - font-size: smaller; - color: #77B; -} - -.incremental, .incremental *, .incremental *:after { - color: #DDE; - visibility: visible; -} - -img.incremental { - visibility: hidden; -} - -.slide .current { - color: #B02; -} diff --git a/pandoc/s5/default/print.css b/pandoc/s5/default/print.css deleted file mode 100644 index 46b2c00..0000000 --- a/pandoc/s5/default/print.css +++ /dev/null @@ -1 +0,0 @@ -/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */ .slide, ul {page-break-inside: avoid; visibility: visible !important;} h1 {page-break-after: avoid;} body {font-size: 12pt; background: white;} * {color: black;} #slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;} #slide0 h3 {margin: 0; padding: 0;} #slide0 h4 {margin: 0 0 0.5em; padding: 0;} #slide0 {margin-bottom: 3em;} h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;} .extra {background: transparent !important;} div.extra, pre.extra, .example {font-size: 10pt; color: #333;} ul.extra a {font-weight: bold;} p.example {display: none;} #header {display: none;} #footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;} #footer h2, #controls {display: none;} /* The following rule keeps the layout stuff out of print. Remove at your own risk! */ .layout, .layout * {display: none !important;} \ No newline at end of file diff --git a/pandoc/s5/default/s5-core.css b/pandoc/s5/default/s5-core.css deleted file mode 100644 index e1be216..0000000 --- a/pandoc/s5/default/s5-core.css +++ /dev/null @@ -1,37 +0,0 @@ -/* Do not edit or override these styles! The system will likely break if you do. */ - -/*div#header, div#footer, div#controls, .slide {position: absolute;}*/ -/* -html>body div#header, -html>body div#footer, -html>body div#controls, -html>body .slide { - position: fixed; -} -*/ -body>main>article.presentation { - display: grid; - grid-template-areas: "slide"; -} - -body>main>article.presentation>.slide { - grid-area: slide; -} - -.handout { - display: none; -} - -/* -.layout { - display: block; -} -*/ - -.slide, .hideme, .incremental { - visibility: hidden; -} - -#slide0 { - visibility: visible; -} diff --git a/pandoc/s5/default/slides.css b/pandoc/s5/default/slides.css deleted file mode 100644 index 0786d7d..0000000 --- a/pandoc/s5/default/slides.css +++ /dev/null @@ -1,3 +0,0 @@ -@import url(s5-core.css); /* required to make the slide show run at all */ -@import url(framing.css); /* sets basic placement and size of slide components */ -@import url(pretty.css); /* stuff that makes the slides look better than blah */ \ No newline at end of file diff --git a/pandoc/s5/default/slides.js b/pandoc/s5/default/slides.js deleted file mode 100644 index ff9ea23..0000000 --- a/pandoc/s5/default/slides.js +++ /dev/null @@ -1,553 +0,0 @@ -// S5 v1.1 slides.js -- released into the Public Domain -// -// Please see http://www.meyerweb.com/eric/tools/s5/credits.html for information -// about all the wonderful and talented contributors to this code! - -var undef; -var slideCSS = ''; -var snum = 0; -var smax = 1; -var incpos = 0; -var number = undef; -var s5mode = true; -var defaultView = 'slideshow'; -var controlVis = 'visible'; - -var isIE = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0; -var isOp = navigator.userAgent.indexOf('Opera') > -1 ? 1 : 0; -var isGe = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('Safari') < 1 ? 1 : 0; - -function hasClass(object, className) { - if (!object.className) return false; - return (object.className.search('(^|\\s)' + className + '(\\s|$)') != -1); -} - -function hasValue(object, value) { - if (!object) return false; - return (object.search('(^|\\s)' + value + '(\\s|$)') != -1); -} - -function removeClass(object,className) { - if (!object) return; - object.className = object.className.replace(new RegExp('(^|\\s)'+className+'(\\s|$)'), RegExp.$1+RegExp.$2); -} - -function addClass(object,className) { - if (!object || hasClass(object, className)) return; - if (object.className) { - object.className += ' '+className; - } else { - object.className = className; - } -} - -function GetElementsWithClassName(elementName,className) { - var allElements = document.getElementsByTagName(elementName); - var elemColl = new Array(); - for (var i = 0; i< allElements.length; i++) { - if (hasClass(allElements[i], className)) { - elemColl[elemColl.length] = allElements[i]; - } - } - return elemColl; -} - -function isParentOrSelf(element, id) { - if (element == null || element.nodeName=='BODY') return false; - else if (element.id == id) return true; - else return isParentOrSelf(element.parentNode, id); -} - -function nodeValue(node) { - var result = ""; - if (node.nodeType == 1) { - var children = node.childNodes; - for (var i = 0; i < children.length; ++i) { - result += nodeValue(children[i]); - } - } - else if (node.nodeType == 3) { - result = node.nodeValue; - } - return(result); -} - -function slideLabel() { - var slideColl = GetElementsWithClassName('*','slide'); - var list = document.getElementById('jumplist'); - smax = slideColl.length; - for (var n = 0; n < smax; n++) { - var obj = slideColl[n]; - - var did = 'slide' + n.toString(); - obj.setAttribute('id',did); - if (isOp) continue; - - var otext = ''; - var menu = obj.firstChild; - if (!menu) continue; // to cope with empty slides - while (menu && menu.nodeType == 3) { - menu = menu.nextSibling; - } - if (!menu) continue; // to cope with slides with only text nodes - - var menunodes = menu.childNodes; - for (var o = 0; o < menunodes.length; o++) { - otext += nodeValue(menunodes[o]); - } - list.options[list.length] = new Option(n + ': ' + otext, n); - } -} - -function currentSlide() { - var cs; - if (document.getElementById) { - cs = document.getElementById('currentSlide'); - } else { - cs = document.currentSlide; - } - cs.innerHTML = '' + snum + '<\/span> ' + - '\/<\/span> ' + - '' + (smax-1) + '<\/span>'; - // if (snum == 0) { - // cs.style.visibility = 'hidden'; - // } else { - // cs.style.visibility = 'visible'; - // } -} - -function go(step) { - if (document.getElementById('slideProj').disabled || step == 0) return; - var jl = document.getElementById('jumplist'); - var cid = 'slide' + snum; - var ce = document.getElementById(cid); - if (incrementals[snum].length > 0) { - for (var i = 0; i < incrementals[snum].length; i++) { - removeClass(incrementals[snum][i], 'current'); - removeClass(incrementals[snum][i], 'incremental'); - } - } - if (step != 'j') { - snum += step; - lmax = smax - 1; - if (snum > lmax) snum = lmax; - if (snum < 0) snum = 0; - } else - snum = parseInt(jl.value); - var nid = 'slide' + snum; - var ne = document.getElementById(nid); - if (!ne) { - ne = document.getElementById('slide0'); - snum = 0; - } - if (step < 0) {incpos = incrementals[snum].length} else {incpos = 0;} - if (incrementals[snum].length > 0 && incpos == 0) { - for (var i = 0; i < incrementals[snum].length; i++) { - if (hasClass(incrementals[snum][i], 'current')) - incpos = i + 1; - else - addClass(incrementals[snum][i], 'incremental'); - } - } - if (incrementals[snum].length > 0 && incpos > 0) - addClass(incrementals[snum][incpos - 1], 'current'); - ce.style.visibility = 'hidden'; - ne.style.visibility = 'visible'; - jl.selectedIndex = snum; - currentSlide(); - number = 0; -} - -function goTo(target) { - if (target >= smax || target == snum) return; - go(target - snum); -} - -function subgo(step) { - if (step > 0) { - removeClass(incrementals[snum][incpos - 1],'current'); - removeClass(incrementals[snum][incpos], 'incremental'); - addClass(incrementals[snum][incpos],'current'); - incpos++; - } else { - incpos--; - removeClass(incrementals[snum][incpos],'current'); - addClass(incrementals[snum][incpos], 'incremental'); - addClass(incrementals[snum][incpos - 1],'current'); - } -} - -function toggle() { - var slideColl = GetElementsWithClassName('*','slide'); - var slides = document.getElementById('slideProj'); - var outline = document.getElementById('outlineStyle'); - if (!slides.disabled) { - slides.disabled = true; - outline.disabled = false; - s5mode = false; - fontSize('1em'); - for (var n = 0; n < smax; n++) { - var slide = slideColl[n]; - slide.style.visibility = 'visible'; - } - } else { - slides.disabled = false; - outline.disabled = true; - s5mode = true; - fontScale(); - for (var n = 0; n < smax; n++) { - var slide = slideColl[n]; - slide.style.visibility = 'hidden'; - } - slideColl[snum].style.visibility = 'visible'; - } -} - -function showHide(action) { - var obj = GetElementsWithClassName('*','hideme')[0]; - switch (action) { - case 's': obj.style.visibility = 'visible'; break; - case 'h': obj.style.visibility = 'hidden'; break; - case 'k': - if (obj.style.visibility != 'visible') { - obj.style.visibility = 'visible'; - } else { - obj.style.visibility = 'hidden'; - } - break; - } -} - -// 'keys' code adapted from MozPoint (http://mozpoint.mozdev.org/) -function keys(key) { - if (!key) { - key = event; - key.which = key.keyCode; - } - if (key.which == 84) { - toggle(); - return; - } - if (s5mode) { - switch (key.which) { - case 10: // return - case 13: // enter - if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; - if (key.target && isParentOrSelf(key.target, 'controls')) return; - if(number != undef) { - goTo(number); - break; - } - case 32: // spacebar - case 34: // page down - case 39: // rightkey - case 40: // downkey - if(number != undef) { - go(number); - } else if (!incrementals[snum] || incpos >= incrementals[snum].length) { - go(1); - } else { - subgo(1); - } - break; - case 33: // page up - case 37: // leftkey - case 38: // upkey - if(number != undef) { - go(-1 * number); - } else if (!incrementals[snum] || incpos <= 0) { - go(-1); - } else { - subgo(-1); - } - break; - case 36: // home - goTo(0); - break; - case 35: // end - goTo(smax-1); - break; - case 67: // c - showHide('k'); - break; - } - if (key.which < 48 || key.which > 57) { - number = undef; - } else { - if (window.event && isParentOrSelf(window.event.srcElement, 'controls')) return; - if (key.target && isParentOrSelf(key.target, 'controls')) return; - number = (((number != undef) ? number : 0) * 10) + (key.which - 48); - } - } - return false; -} - -function clicker(e) { - number = undef; - var target; - if (window.event) { - target = window.event.srcElement; - e = window.event; - } else target = e.target; - if (target.getAttribute('href') != null || target.getAttribute("onclick") != null || target.getAttribute("onchange") != null || hasValue(target.rel, 'external') || isParentOrSelf(target, 'controls') || isParentOrSelf(target,'embed') || isParentOrSelf(target,'object') || isParentOrSelf(target, "jumplist")) return true; - if (!e.which || e.which == 1) { - if (!incrementals[snum] || incpos >= incrementals[snum].length) { - go(1); - } else { - subgo(1); - } - } -} - -function findSlide(hash) { - var target = null; - var slides = GetElementsWithClassName('*','slide'); - for (var i = 0; i < slides.length; i++) { - var targetSlide = slides[i]; - if ( (targetSlide.name && targetSlide.name == hash) - || (targetSlide.id && targetSlide.id == hash) ) { - target = targetSlide; - break; - } - } - while(target != null && target.nodeName != 'BODY') { - if (hasClass(target, 'slide')) { - return parseInt(target.id.slice(5)); - } - target = target.parentNode; - } - return null; -} - -function slideJump() { - if (window.location.hash == null) return; - var sregex = /^#slide(\d+)$/; - var matches = sregex.exec(window.location.hash); - var dest = null; - if (matches != null) { - dest = parseInt(matches[1]); - } else { - dest = findSlide(window.location.hash.slice(1)); - } - if (dest != null) - go(dest - snum); -} - -function fixLinks() { - var thisUri = window.location.href; - thisUri = thisUri.slice(0, thisUri.length - window.location.hash.length); - var aelements = document.getElementsByTagName('A'); - for (var i = 0; i < aelements.length; i++) { - var a = aelements[i].href; - var slideID = a.match('\#slide[0-9]{1,2}'); - if ((slideID) && (slideID[0].slice(0,1) == '#')) { - var dest = findSlide(slideID[0].slice(1)); - if (dest != null) { - if (aelements[i].addEventListener) { - aelements[i].addEventListener("click", new Function("e", - "if (document.getElementById('slideProj').disabled) return;" + - "go("+dest+" - snum); " + - "if (e.preventDefault) e.preventDefault();"), true); - } else if (aelements[i].attachEvent) { - aelements[i].attachEvent("onclick", new Function("", - "if (document.getElementById('slideProj').disabled) return;" + - "go("+dest+" - snum); " + - "event.returnValue = false;")); - } - } - } - } -} - -function externalLinks() { - if (!document.getElementsByTagName) return; - var anchors = document.getElementsByTagName('a'); - for (var i=0; i' + - '