📄 slidy.js
字号:
var contents = document.createElement("a");
contents.setAttribute("href", "javascript:toggleTableOfContents()");//xuan
contents.setAttribute("title", "目录列表".localize());
contents.innerHTML = " 目录 ".localize();
toolbar.appendChild(contents);
var smaller = document.createElement("a");
smaller.setAttribute("href", "javascript:smaller()");//xuan addsmaller
smaller.setAttribute("title", "字体变小".localize());
smaller.innerHTML = " 缩小 ".localize();
toolbar.appendChild(smaller);
var bigger = document.createElement("a");
bigger.setAttribute("href", "javascript:bigger()");//xuan addbigger
bigger.setAttribute("title", "字体变大".localize());
bigger.innerHTML = " 放大 ".localize();
toolbar.appendChild(bigger);
var copyright = findCopyright();
var help = document.createElement("a");
help.setAttribute("href", helpPage);
//help.setAttribute("title", helpText.localize());
help.innerHTML = " 帮助 ".localize();
toolbar.appendChild(help);
var return00 = document.createElement("a");
return00.setAttribute("href", "arithmetic.html");
//help.setAttribute("title", helpText.localize());
return00.innerHTML = " 返回".localize();
toolbar.appendChild(return00);
helpAnchor = return00;
if (copyright)
{
var span = document.createElement("div");
span.setAttribute("class", "toolbar");
span.innerHTML = copyright;
//copyright0.style.color = "blue";
//span.innerHTML = "<br> "+copyright+"";
span.style.fontSize = "70%";
span.style.fontFamily="Times New Roman";
span.style.position = "absolute";
//span.style.marginLeft = "26em";
//span.style.right= "0";
span.style.height = "1.2em";
span.style.top = "auto";
span.style.right = "0";
span.style.fontWeight="bold";
span.style.width = "auto";
span.style.textAlign = "right";
span.style.color = "#C4AE2D";
//copyright0.style.background = "rgb(0,72,178)";
toolbar.appendChild(span);
}
slideCounter = document.createElement("div")
slideCounter.style.position = "absolute";
slideCounter.style.width = "auto"; //"20%";
slideCounter.style.height = "1.2em";
slideCounter.style.top = "auto";
slideCounter.style.bottom = 0;
slideCounter.style.right = "0";
slideCounter.style.textAlign = "right";
slideCounter.style.color = "white";
slideCounter.style.background = "rgb(28,72,120)";
toolbar.appendChild(slideCounter);
}
// ensure that click isn't passed through to the page
toolbar.onclick = stopPropagation;
document.body.appendChild(toolbar);
slideNumElement = slideCounter;
setEosStatus(false);
return toolbar;
}
function isShownToc()
{
if (toc && toc.style.visible == "visible")
return true;
return false;
}
function showTableOfContents()//xuan
{
if (toc)
{
if (toc.style.visible != "visible")
{
toc.style.visible = "visible";
toc.style.display = "block";
toc.focus();
if (ie7 && slidenum == 0)
setTimeout("ieHack()", 100);
}
else
hideTableOfContents();
}
}
function hideTableOfContents()//xuan
{
if (toc && toc.style.visible != "hidden")
{
toc.style.visible = "hidden";
toc.style.display = "none";
try
{
if (!opera)
helpAnchor.focus();
}
catch (e)
{
}
}
}
function toggleTableOfContents()//xuan
{
if (toc)
{
if (toc.style.visible != "visible")
showTableOfContents();//xuan
else
hideTableOfContents();
}
}
// called on clicking toc entry
function gotoEntry(e)
{
var target;
if (!e)
var e = window.event;
if (e.target)
target = e.target;
else if (e.srcElement)
target = e.srcElement;
// work around Safari bug
if (target.nodeType == 3)
target = target.parentNode;
if (target && target.nodeType == 1)
{
var uri = target.getAttribute("href");
if (uri)
{
//alert("going to " + uri);
var slide = slides[slidenum];
hideSlide(slide);
slidenum = findSlideNumber(uri);
slide = slides[slidenum];
lastShown = null;
setLocation();
setVisibilityAllIncremental("hidden");
setEosStatus(!nextIncrementalItem(lastShown));
showSlide(slide);
//target.focus();
try
{
if (!opera)
helpAnchor.focus();
}
catch (e)
{
}
}
}
hideTableOfContents(e);
if (ie7) ieHack();
stopPropagation(e);
return cancel(e);
}
// called onkeydown for toc entry
function gotoTocEntry(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 = slides[slidenum];
hideSlide(slide);
slidenum = findSlideNumber(uri);
slide = slides[slidenum];
lastShown = null;
setLocation();
setVisibilityAllIncremental("hidden");
setEosStatus(!nextIncrementalItem(lastShown));
showSlide(slide);
//target.focus();
try
{
if (!opera)
helpAnchor.focus();
}
catch (e)
{
}
}
hideTableOfContents();
if (ie7) ieHack();
return cancel(event);
}
if (key == 40 && this.next)
{
this.next.focus();
return cancel(event);
}
if (key == 38 && this.previous)
{
this.previous.focus();
return cancel(event);
}
return true;
}
function isTitleSlide(slide)
{
return hasClass(slide, "title");
}
// create div element with links to each slide xuan
function tableOfContents()//xuan
{
var toc = document.createElement("div");
addClass(toc, "toc");
//toc.setAttribute("tabindex", "0");
var heading = document.createElement("div");
addClass(heading, "toc-heading");
heading.innerHTML = "目录".localize();
heading.style.textAlign = "center";
heading.style.width = "80%";
heading.style.margin = "0";
heading.style.marginBottom = "1em";
heading.style.borderBottomStyle = "solid";
heading.style.borderBottomColor = "rgb(180,180,180)";
heading.style.borderBottomWidth = "1px";
heading.style.color = "white";
toc.appendChild(heading);
var previous = null;
for (var i = 0; i < slides.length; ++i)
{
var title = hasClass(slides[i], "title");
//var num = document.createTextNode((i + 1) + ". ");
//toc.appendChild(num);
var a = document.createElement("a");
a.setAttribute("href", "#(" + (i+1) + ")");
if (title)
addClass(a, "titleslide");
var name = document.createTextNode((i + 1) + ". "+slideName(i));
a.appendChild(name);
a.onclick = gotoEntry;
a.onkeydown = gotoTocEntry;
a.previous = previous;
if (previous)
previous.next = a;
toc.appendChild(a);
if (i == 0)
toc.first = a;
if (i < slides.length - 1)
{
var br = document.createElement("br");
toc.appendChild(br);
}
previous = a;
}
toc.focus = function () {
if (this.first)
this.first.focus();
}
toc.onclick = function (e) {
e||(e=window.event);
hideTableOfContents();
stopPropagation(e);
if (e.cancel != undefined)
e.cancel = true;
if (e.returnValue != undefined)
e.returnValue = false;
return false;
};
toc.style.position = "absolute";
toc.style.zIndex = "300";
toc.style.width = "40%";
toc.style.maxWidth = "30em";
toc.style.height = "30em";
toc.style.overflow = "auto";
toc.style.top = "auto";
toc.style.right = "auto";
toc.style.left = "4em";
toc.style.bottom = "4em";
toc.style.padding = "1em";
toc.style.background = "#2C2C2C";
toc.style.borderStyle = "solid";
toc.style.borderWidth = "2px";
toc.style.fontSize = "60%";
document.body.insertBefore(toc, document.body.firstChild);
return toc;
}
function replaceByNonBreakingSpace(str)
{
for (var i = 0; i < str.length; ++i)
str[i] = 160;
}
function initOutliner()
{
var items = document.getElementsByTagName("LI");
for (var i = 0; i < items.length; ++i)
{
var target = items[i];
if (!hasClass(target.parentNode, "outline"))
continue;
target.onclick = outlineClick;
if (!ns_pos)
{
target.onmouseover = hoverOutline;
target.onmouseout = unhoverOutline;
}
if (foldable(target))
{
target.foldable = true;
target.onfocus = function () {outline = this;};
target.onblur = function () {outline = null;};
if (!target.getAttribute("tabindex"))
target.setAttribute("tabindex", "0");
if (hasClass(target, "expand"))
unfold(target);
else
fold(target);
}
else
{
addClass(target, "nofold");
target.visible = true;
target.foldable = false;
}
}
}
function foldable(item)
{
if (!item || item.nodeType != 1)
return false;
var node = item.firstChild;
while (node)
{
if (node.nodeType == 1 && isBlock(node))
return true;
node = node.nextSibling;
}
return false;
}
function fold(item)
{
if (item)
{
removeClass(item, "unfolded");
addClass(item, "folded");
}
var node = item ? item.firstChild : null;
while (node)
{
if (node.nodeType == 1 && isBlock(node)) // element
{
// note that getElementStyle won't work for Safari 1.3
node.display = getElementStyle(node, "display", "display");
node.style.display = "none";
node.style.visibility = "hidden";
}
node = node.nextSibling;
}
item.visible = false;
}
function unfold(item)
{
if (item)
{
addClass(item, "unfolded");
removeClass(item, "folded");
}
var node = item ? item.firstChild : null;
while (node)
{
if (node.nodeType == 1 && isBlock(node)) // element
{
// with fallback for Safari, see above
node.style.display = (node.display ? node.display : "block");
node.style.visibility = "visible";
}
node = node.nextSibling;
}
item.visible = true;
}
function outlineClick(e)
{
var rightclick = false;
var target;
if (!e)
var e = window.event;
if (e.target)
target = e.target;
else if (e.srcElement)
target = e.srcElement;
// work around Safari bug
if (target.nodeType == 3)
target = target.parentNode;
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)
fold(target);
else
unfold(target);
}
stopPropagation(e);
e.cancel =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -