diff --git a/for1st/mop.js b/for1st/mop.js new file mode 100644 index 0000000..c7527f5 --- /dev/null +++ b/for1st/mop.js @@ -0,0 +1,430 @@ +// +// MoP - Mozilla de Presentation +// Main JavaScript Source +// (C)2005 by HIROSE, Yuuji [yuuji@yatex.org] +// $Id: mop.js,v 1.6 2007/06/28 02:15:51 yuuji Exp $ +// Last modified Thu Jun 28 11:05:55 2007 on firestorm +// Update count: 206 +// +MSIE = navigator.userAgent.indexOf("MSIE")!=-1; +document.onkeypress = keyExec; +self.focus(); + +function getMyNumber() { + if (location.pathname.match(/(\d+)\.html?/i)) + return RegExp.$1-0; + return 0; +} +function getMaxNumber() { + var title = document.getElementsByTagName("title").item(0).innerHTML; + if (title.match(/\/(\d+) /)) + return RegExp.$1-0; + else + return 2; +} + +function gotoPage(n) { + var cur = location.pathname; + var file = cur.substring(cur.lastIndexOf("/")+1); + var l, m, r, dest, dstr; + l = "slide-", m="00", r=".html"; + if (n) numericarg = n; + if (file.match(/(.*-)(\d+)(\.html?)/i)) { + l = RegExp.$1; + m = RegExp.$2; + r = RegExp.$3; + } + dest = (numericarg==0 ? getMaxNumber() : numericarg); + dest = "0"+dest; + dest = dest.substring(dest.length-2);// substr(-2) doesn't work on IE :( + dstr = l+dest+r; + location.href = dstr; + numericarg = 0; +} + +function pageNext() { + var n = (numericarg==0 ? 1 : numericarg); + var goal = getMyNumber()+n; + if (goal > 1 && goal <= totalpages) + gotoPage(goal); + numericarg = 0; +} + +function getKEYCODE(e){ + + if (document.getElementById && !MSIE ) + return e.charCode||e.keyCode; + else if(document.all) return event.keyCode; + else if(document.layers) return e.which; +} +function keyExec(e) { + key = getKEYCODE(e); + mods = null; + if (!MSIE) mods = e.shiftKey|e.ctrlKey|e.altKey; + + switch (key) { + case 107: + if (mods) break; + case 38: + dialogue(-1); break; // up + case 106: + if (mods) break; + case 40: + stepOne(); break; // down + case 104: + if (mods) break; + case 37: + if (document.getElementById("_prev")) + history.back(); + break; // left + case 103: + gotoPage(); + break; + case 108: + if (mods) break; + case 39: + pageNext(); break; // right + case 48: case 49: case 50: case 51: case 52: + case 53: case 54: case 55: case 56: case 57: + numericarg = 10*numericarg+key-48; + break; + case 45: // '-' + decFontSize(); + break; + case 43: // '+' + incFontSize(); + break; + default: + numericarg = 0; + } +} + +function resetHandler(id) { + target = document.getElementById(id); + target.onmouseover = null; // �ϥ�ɥ��� + target.onclick = null; + target.setAttribute("onMouseOver", null); + target.setAttribute("onclick", null); +} + +rcnt=new Array(); +function rcutin(id) { + w = 600; + if (document.getElementById) { //Moz,NN6,IE5�� + if (!rcnt[id]) { + rcnt[id] = 0; + } + target = document.getElementById(id); + target.style.borderLeft = "2px none"; + document.getElementById(id+"p").style.borderLeft = "2px none"; + target.style.visibility = "visible"; + target.style.paddingLeft=w*(1.0-rcnt[id]/10.0); + target.style.visibility = 'visible'; + target.style.borderTop = 'none'; + resetHandler(id+"p"); + if (rcnt[id]<10) { + rcnt[id]++; + myname="rcutin('"+id+"')"; + setTimeout(myname, 50); + } + } +} +function emerge(id) { + if (document.getElementById) { //Moz,NN6,IE5�� + target = document.getElementById(id); + target.style.visibility = 'visible'; + target.style.borderTop = 'none'; + resetHandler(id+"p"); + document.getElementById(id+"p").style.border = '1px none'; + } +} + +function setOpacity(obj, op) { + ua = navigator.userAgent; + if (ua && ua.indexOf("Gecko") != -1) { + obj.style.MozOpacity = op; + } else if (document.all) { + /* ���ޤ������� IE6 */ + obj.style.filter="alpha(opacity=0)"; + obj.filters.alpha.opacity = (op * 100); + } +} +opaquecount=new Array(); +function opaque(id) { + obj = document.getElementById(id); + pnt = document.getElementById(id+"p"); + if (!opaquecount[obj]) { + resetHandler(id+"p"); + obj.style.border = "1px none"; + obj.style.visibility = 'visible'; + opaquecount[obj]=0; + document.getElementById(id+"p") + pnt.style.border = "1px none"; + if (true || document.all) { + obj.style.position = "relative"; + } + } + if (opaquecount[obj]>10) return; // for too many calls + obj.style.top = 100*(1-opaquecount[obj]/10.0); + //obj.style.posTop = 100*(1-opaquecount[obj]/10.0); + setOpacity(obj, (opaquecount[obj]++)/10.0); + if (opaquecount[obj] <= 10) { + setTimeout("opaque('"+id+"')", 200); + } else { + if (document.all) { + obj.style.position = "static"; + pnt.style.position = "static"; + } + } +} + +function revealOne() { + top: + for (var i=1; obj=document.getElementById("id"+i); i++) { + targets = new Array("id"+i, "id"+i+"p"); + for (ts in targets) { + obj=document.getElementById(targets[ts]); + if (!obj) continue; + for (j=0; j0) + dir = arguments[0]; + else + dir = 1; + + /* if (dlog>=bqs.length) + return null; + // dialog�Τ��Ȥ˥��˥᡼���������줿���ʤ餳�줬ɬ�� + */ + + // a, b�ΰ��� + area_a = searchTagByClass("div", "a"); + + dlog=(dlog>=0? (dlog>=bqs.length?bqs.length-1:dlog) :0); + while (dlog=0 && bqs[dlog].nodeType != element_node) + dlog+=dir; + // numericarg ʬ���������åס���Υ롼�פȤ��ä���ˤǤ��� + while (--numericarg > 0) { + dlog+=dir; + while (dlog=0 && bqs[dlog].nodeType != element_node) + dlog+=dir; + } + //alert("o="+odlog+", na="+na+", dlog="+dlog); + numericarg=0; + if (dlog>=0 && dlog 500) { + fs = 500; break; + } + } + body.style.fontSize = fs+"%"; + numericarg = 0; +} + +function decFontSize() { + var n = (numericarg==0 ? 1 : numericarg); + numericarg = -n; + incFontSize(); +} + + +function autoAdjust() { + if (!document.getElementsByTagName("h1")) return; + if (document.getElementById("noresize")) return; // id="noresize" �ʤ餷�ʤ� + h1 = document.getElementsByTagName("h1")[0]; + h1height = h1.offsetHeight; + bottom = document.getElementById("_bottom"); + y = bottom.offsetTop; + body = document.getElementsByTagName("body").item(0); + height = (MSIE ? document.body.clientHeight : innerHeight); + bodyrule=getCSSRule("body"); + fs = (bodyrule&&bodyrule.style.fontSize + ? parseInt(bodyrule.style.fontSize) + : 200); +//alert("hh="+h1height+"y="+y+"/"+height+", fs="+fs); + body.style.fontSize = fs+"%"; + for ( ; y>height && fs > 80; fs-=10) { +//alert("hh="+h1height+"y="+y+"/"+height+", fs="+fs); + body.style.fontSize = fs+"%"; + y = bottom.offsetTop; + h1height = h1.offsetHeight; + } +} + +var numericarg = 0; +var totalpages = 99; +function init(total) { + /* �Ϥ߽Ф�����򾮤�����;�פʤ�����?? */ + if (total) totalpages = total; + autoAdjust(); + + var pnt; + numericarg = 0; + for (i=1; child=document.getElementById("id"+i); i++) { + pnt=document.getElementById("id"+i+"p"); + if (!pnt) continue; + width = child.offsetWidth; + height = child.offsetHeight; + if (width==undefined || height==undefined) + continue; + pnt.style.width = width; + if (!MSIE) pnt.style.height = height; + child.style.position = "relative"; + + //alert("i="+i+", "+width+"x"+height); + } +}