📄 mcprintx.htm
字号:
{
var oPage = DisplayPage(g_nDispPage + g_cPagesDisplayed - 1);
if (oPage != null)
{
oPage.style.top = "-20000px";
if (g_fRTL)
oPage.style.right = "10px";
else
oPage.style.left = "10px";
}
g_cPagesDisplayed--;
}
}
function PositionPages(nDispPage)
{
var strDispDoc = DisplayDocument(nDispPage);
if ( g_aDocTree != null
&& g_aDocTree[strDispDoc] != null
&& g_aDocTree[strDispDoc].Pages() > 0)
{
UndisplayPages();
var xPageWidth = getPageWidth();
var yPageHeight = getPageHeight();
var nMaxPage = TotalDisplayPages();
g_cxDisplaySlots = Math.max(1, Math.floor((OverflowContainer.offsetWidth*100)/(g_nZoomFactor*(xPageWidth+10))));
g_cyDisplaySlots = Math.max(1, Math.floor((OverflowContainer.offsetHeight*100)/(g_nZoomFactor*(yPageHeight+10))));
var nMaxPageRequest = Math.max(nMaxPage - g_cxDisplaySlots * g_cyDisplaySlots + 1, 1);
if ( nDispPage < 1 )
nDispPage = 1;
else if (nDispPage > nMaxPageRequest)
nDispPage = nMaxPageRequest;
g_nDispPage = nDispPage;
document.all.spanPageTotal.innerText = nMaxPage;
document.all.inputPageNum.value = g_nDispPage;
updateNavButtons();
var xDisplaySlot = 1;
var yDisplaySlot = 1;
var iPage = g_nDispPage;
g_cPagesDisplayed = 0;
while (iPage <= nMaxPage && yDisplaySlot <= g_cyDisplaySlots)
{
var xPos = xDisplaySlot*10 + (xDisplaySlot-1)*xPageWidth;
var yPos = yDisplaySlot*10 + (yDisplaySlot-1)*yPageHeight;
var oPage = DisplayPage(iPage);
if (g_fRTL)
oPage.style.right = xPos;
else
oPage.style.left = xPos;
oPage.style.top = yPos;
iPage++;
if (++xDisplaySlot > g_cxDisplaySlots)
{
xDisplaySlot = 1;
yDisplaySlot++;
}
g_cPagesDisplayed++;
}
}
}
function ChangeDispPage(nDispPageNew)
{
if (isNaN(nDispPageNew))
{
inputPageNum.value = g_nDispPage;
}
else
{
if (nDispPageNew < 1)
nDispPageNew = 1;
else if (nDispPageNew > TotalDisplayPages())
nDispPageNew = TotalDisplayPages();
OverflowContainer.scrollTop = 0;
PositionPages(nDispPageNew);
}
return g_nDispPage;
}
function DisplayDocument(nWhichPage)
{
switch (g_nFramesetLayout)
{
case 0:
return "C";
break;
case 1:
return g_strActiveFrame;
break;
case 2:
var i;
if (!nWhichPage)
return null;
;
for (i in g_aDocTree)
{
if ( nWhichPage >= g_aDocTree[i]._nStartingPage
&& nWhichPage < (g_aDocTree[i]._nStartingPage + g_aDocTree[i].Pages()))
return i;
}
default:
HandleError("Display document cannot be found!", document.URL, "DisplayDocument");
}
}
function TotalDisplayPages()
{
if (g_nFramesetLayout == 2)
return g_nTotalPages;
return g_aDocTree[DisplayDocument()].Pages();
}
function DisplayPage(nWhichPage)
{
;
if (g_nFramesetLayout != 2)
return g_aDocTree[DisplayDocument(nWhichPage)].Page(nWhichPage);
return g_aDocTree[DisplayDocument(nWhichPage)].Page(nWhichPage - g_aDocTree[DisplayDocument(nWhichPage)]._nStartingPage + 1);
}
function ChangeZoom(nNewVal)
{
if (nNewVal < 10)
nNewVal = 10;
else if (nNewVal > 1000)
nNewVal = 1000;
else if (isNaN(nNewVal))
nNewVal = g_nZoomFactor;
if (nNewVal != g_nZoomFactor)
{
MasterContainer.style.zoom = nNewVal + "%";
g_nZoomFactor = nNewVal;
updateZoomButtons();
PositionPages(g_nDispPage);
}
return g_nZoomFactor;
}
function BuildTableOfLinks( docSource )
{
var aLinks = docSource.links;
var nLinks = aLinks.length;
if (nLinks > 0)
{
var fDuplicate;
var i;
var j;
var newHTM;
var docLinkTable = document.createElement("BODY");
var L_LINKSHEADER1_Text = "Shortcut Text";
var L_LINKSHEADER2_Text = "Internet Address";
newHTM = "<CENTER><TABLE BORDER=1>";
newHTM += "<THEAD style=\"display:table-header-group\"><TR><TH>"
+ L_LINKSHEADER1_Text
+ "</TH><TH>" + L_LINKSHEADER2_Text + "</TH></TR></THEAD><TBODY>";
for (i = 0; i < nLinks; i++)
{
fDuplicate = false;
for (j = 0; (!fDuplicate) && (j < i); j++)
{
if (aLinks[i].href == aLinks[j].href)
fDuplicate = true;
}
if (!fDuplicate)
newHTM += ("<TR><TD>" + aLinks[i].innerText + "</TD><TD>" + aLinks[i].href + "</TD></TR>");
}
newHTM += "</TBODY></TABLE></CENTER>";
docLinkTable.innerHTML = newHTM;
return docLinkTable.document;
}
return null;
}
function CreateDocument( docURL, strDocID, fUseStreamHeader )
{
if (g_aDocTree[strDocID])
return;
g_aDocTree[strDocID] = new CPrintDoc( strDocID, docURL );
g_aDocTree[strDocID].InitDocument( fUseStreamHeader );
}
function ChangeFramesetLayout( nNewLayout, fForce )
{
if ( g_nFramesetLayout == nNewLayout
&& !fForce)
return;
UndisplayPages();
g_nFramesetLayout = nNewLayout;
switch ( nNewLayout )
{
case 0:
case 1:
break;
case 2:
g_nTotalPages = 0;
for (i in g_aDocTree)
{
if ( g_aDocTree[i]._fFrameset
|| i == "S")
g_aDocTree[i]._nStartingPage = 0;
else
{
g_aDocTree[i]._nStartingPage = g_nTotalPages + 1;
g_nTotalPages += g_aDocTree[i].Pages();
}
}
break;
default:
HandleError("Impossible frameset layout type: " + nNewLayout, document.URL, "ChangeFramesetLayout");
}
ChangeDispPage(1);
}
function EnsureDocuments()
{
var i;
var tmp;
// captain: "Math.max" safety checks
var top = Math.max(Printer.marginTop / 100, 0);
var bottom = Math.max(Printer.marginBottom / 100, 0);
var left = Math.max(Printer.marginLeft / 100, 0);
var right = Math.max(Printer.marginRight / 100, 0);
var pageWidth = Math.max(Printer.pageWidth / 100, 0);
var pageHeight = Math.max(Printer.pageHeight / 100, 0);
var linktable = Printer.tableOfLinks;
var upTop = Math.max(Printer.unprintableTop / 100, 0);
var upBottom = Math.max(Printer.unprintableBottom / 100, 0);
var header = Printer.header;
var footer = Printer.footer;
if (header)
{
tmp = upTop + (27 / 100);
if (tmp > top)
top = tmp;
}
if (footer)
{
tmp = upBottom + (27 / 100);
if (tmp > bottom)
bottom = tmp;
}
if (upTop != g_nUnprintTop)
{
g_nUnprintTop = upTop;
oRule = GetRuleFromSelector(".divHead");
if (oRule == null)
{
HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.top = upTop + "in";
}
if (upBottom != g_nUnprintBottom)
{
g_nUnprintBottom= upBottom;
oRule = GetRuleFromSelector(".divFoot");
if (oRule == null)
{
HandleError("'.divFoot' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.bottom = upBottom + "in";
}
if ( top != g_nMarginTop
|| bottom != g_nMarginBottom
|| left != g_nMarginLeft
|| right != g_nMarginRight
|| pageWidth != g_nPageWidth
|| pageHeight != g_nPageHeight
|| header != g_strHeader
|| footer != g_strFooter )
{
var conWidth = pageWidth - left - right;
var conHeight = pageHeight - top - bottom;
var oStyleSheet = document.styleSheets[0];
var oRule;
if (conWidth < 0)
conWidth = 0;
if (conHeight < 0)
conHeight = 0;
UndisplayPages();
g_nTotalPages = 0;
g_nDocsToCalc = 0;
for (i in g_aDocTree)
{
g_nDocsToCalc++;
g_aDocTree[i].ResetDocument();
}
g_nMarginTop = top;
g_nMarginBottom = bottom;
g_nMarginLeft = left;
g_nMarginRight = right;
g_nPageWidth = pageWidth;
g_nPageHeight = pageHeight;
g_fTableofLinks = linktable;
g_strHeader = header;
g_strFooter = footer;
HeadFoot.textHead = g_strHeader;
HeadFoot.textFoot = g_strFooter;
oRule = GetRuleFromSelector(".page");
if (oRule == null)
{
HandleError("'.page' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.width = pageWidth + "in";
oRule.style.height = pageHeight + "in";
oRule = GetRuleFromSelector(".mRect");
if (oRule == null)
{
HandleError("'.mRect' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.marginLeft = left + "in";
oRule.style.marginRight = right + "in";
oRule.style.marginTop = top + "in";
oRule.style.marginBottom = bottom + "in";
oRule.style.width = conWidth + "in";
oRule.style.height = conHeight + "in";
oRule = GetRuleFromSelector(".divHead");
if (oRule == null)
{
HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.left = left + "in";
oRule.style.width = conWidth + "in";
oRule = GetRuleFromSelector(".divFoot");
if (oRule == null)
{
HandleError("'.divHead' rule does not exist!", document.URL, "CPrintDoc::EnsureDocuments");
}
oRule.style.left = left + "in";
oRule.style.width = conWidth + "in";
for (i in g_aDocTree)
{
g_aDocTree[i].InitDocument((g_aDocTree[i]._anMerge[1] == 1));
}
if (g_nFramesetLayout == 2)
ChangeFramesetLayout(g_nFramesetLayout, true);
PositionPages(g_nDispPage);
}
else if (linktable != g_fTableOfLinks)
{
g_fTableOfLinks = linktable;
for (i in g_aDocTree)
{
g_aDocTree[i].ResetTableOfLinks();
}
}
}
function buttonRaise( elem )
{
elem.style.borderStyle = "outset";
elem.style.borderColor = "threedhighlight";
}
function buttonLower( elem )
{
elem.style.borderStyle = "solid";
elem.style.borderColor = "threedface";
}
function buttonDepress(elem)
{
elem.style.borderStyle = "inset";
elem.style.borderColor = "threedshadow";
}
function buttonOver()
{
var imgSrc = event.srcElement;
g_imgUnderMouse = imgSrc;
if (imgSrc == begin ||
imgSrc == prev ||
imgSrc == next ||
imgSrc == end)
{
updateNavButtons();
}
else if (imgSrc == zoomIn ||
imgSrc == zoomOut)
{
updateZoomButtons();
}
else
{
imgSrc.src= "" + imgSrc.id + "_hilite.gif";
buttonRaise( imgSrc.parentNode );
}
}
function buttonOut()
{
var imgSrc = event.srcElement;
g_imgUnderMouse = null;
if (imgSrc == begin ||
imgSrc == prev ||
imgSrc == next ||
imgSrc == end)
{
updateNavButtons();
}
else if (imgSrc == zoomIn ||
imgSrc == zoomOut)
{
updateZoomButtons();
}
else
{
imgSrc.src= "" + imgSrc.id + ".gif";
buttonLower( imgSrc.parentNode );
}
}
function buttonDown()
{
buttonDepress(event.srcElement);
}
function HandlePageSelect()
{
event.srcElement.value = ChangeDispPage(parseInt(inputPageNum.value));
MasterContainer.focus();
}
function HandlePageSetup()
{
if (Printer.showPageSetupDialog())
EnsureDocuments();
}
function HandleForwardPage()
{
ChangeDispPage(g_nDispPage + 1);
MasterContainer.focus();
}
function HandleBackPage()
{
ChangeDispPage(g_nDispPage - 1);
MasterContainer.focus();
}
function HandleFirstPage()
{
ChangeDispPage(1);
MasterContainer.focus();
}
function HandleLastPage()
{
ChangeDispPage(TotalDisplayPages());
MasterContainer.focus();
}
function NumericFromSpecialZoom(fnBounder)
{
var iMaxNumericZoom = selectZoom.options.length-1-3;
var iBelow = -1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -