script.js

来自「可作为课程设计或者毕业设计 也可以作为学校精品课程网站使用」· JavaScript 代码 · 共 1,089 行 · 第 1/3 页

JS
1,089
字号
function LoadSld()
{
	var sld=GetObj("SlideObj")
	if( !g_supportsPPTHTML ) {		
		sld.style.visibility="visible"
		return
	}

	if( MakeNotesVis() ) return

	runAnimations = _InitAnimations();
	
	if( IsWin("PPTSld") )
		parent.SldUpdated(GetSldId())
	g_origSz=parseInt(SlideObj.style.fontSize)
	g_origH=sld.style.posHeight
	g_origW=sld.style.posWidth
	g_scaleHyperlinks=(document.all.tags("AREA").length>0)
	if( g_scaleHyperlinks )
		InitHLinkArray()
	if( g_scaleInFrame||(IsWin("PPTSld") && parent.IsFullScrMode() ) )
		document.body.scroll="no"
	_RSW()
	if( IsWin("PPTSld") && parent.IsFullScrMode() )
		FullScrInit();
	
	MakeSldVis();
	ChkAutoAdv()

	if( runAnimations )
	{
		if( document.all("NSPlay") )
			document.all("NSPlay").autoStart = false;

		if( sld.filters && sld.filters.revealtrans )
			setTimeout( "document.body.start()", sld.filters.revealtrans.duration * 1000 );
		else
			document.body.start();
	}
}

function MakeSldVis() 
{
	var fTrans=g_showAnimation && SldHasTrans()
	if( fTrans )	
	{
		if( g_bgSound ) {
			idx=g_bgSound.indexOf(",");
			pptSound.src=g_bgSound.substr( 0, idx );
			pptSound.loop= -(parseInt(g_bgSound.substr(idx+1)));
		}
		SlideObj.filters.revealtrans.Apply()	
    }
	SlideObj.style.visibility="visible"
	if( fTrans )
		SlideObj.filters.revealtrans.Play()
}
function MakeNotesVis() 
{
	if( !IsNts() ) return false 
	SlideObj.style.display="none"
	nObj = document.all.item("NotesObj")
	parent.SetHasNts(0)
	if( nObj ) { 
		nObj.style.display=""
		parent.SetHasNts(1)
	}
	return 1
}
function ChkAutoAdv()
{
	if(SldHasTrans())
		SlideObj.onfilterchange=AutoAdv
	else
		AutoAdv()
}
function AutoAdv()
{
	if(!IsWin("PPTSld") || !gUseSldTimings )return
	var sld=GetCurSld()
	if( (sld.mAdvDelay>0) && !parent.IsFramesMode() )
		setTimeout("parent.GoToNextSld()",sld.mAdvDelay)
}
function GetObj(id)
{
	if(g_supportsPPTHTML) return document.all(id);
	else return document.getElementById(id);
}
function SldHasTrans() { return SlideObj.style.filter != ""; }
function GetSldId() { return sId=location.href.substring(location.href.lastIndexOf('/')+1) }
function HideMenu() { if( frames["PPTSld"] && PPTSld.document.all.item("ctxtmenu") && PPTSld.ctxtmenu.style.display!="none" ) { PPTSld.ctxtmenu.style.display='none'; return true } return false }
function IsWin( name ) { return window.name == name }
function IsNts() { return IsWin("PPTNts") }
function IsSldOrNts() { return( IsWin("PPTSld")||IsWin("PPTNts") ) }
function SupportsPPTAnimation() { return( navigator.platform == "Win32" && navigator.appVersion.indexOf("Windows")>0 ) }
function SupportsPPTHTML()
{
	var appVer=navigator.appVersion, msie=appVer.indexOf("MSIE "), ver=0
	if( msie >= 0 )
		ver=parseFloat( appVer.substring( msie+5, appVer.indexOf(";",msie) ) )
	else
		ver=parseInt(appVer)

	return( ver >= 4 && msie >= 0 )
}
function _RSW()
{
	if( !g_supportsPPTHTML || IsNts() ||
	  ( !g_scaleInFrame && (!IsWin("PPTSld") || !parent.IsFullScrMode()) ) )
		return

        var padding=0;
        if( IsWin("PPTSld") && parent.IsFramesMode() ) padding=6

	cltWidth=document.body.clientWidth-padding
	cltHeight=document.body.clientHeight-padding
	factor=(1.0*cltWidth)/g_origW
	if( cltHeight < g_origH*factor )
		factor=(1.0*cltHeight)/g_origH

	newSize = g_origSz * factor
	if( newSize < 1 ) newSize=1

	s=SlideObj.style
	s.fontSize=newSize+"px"
	s.posWidth=g_origW*factor
	s.posHeight=g_origH*factor
	s.posLeft=(cltWidth-s.posWidth+padding)/2
	s.posTop=(cltHeight-s.posHeight+padding)/2

	if( g_scaleHyperlinks )
		ScaleHyperlinks( factor )
}
function _InitAnimations()
{
	animRuntimeInstalled = ''+document.body.localTime != 'undefined';
	isFullScreen = (window.name == "PPTSld") && !parent.IsFramesMode();
	g_animUseRuntime = g_showAnimation && animRuntimeInstalled && !(isFullScreen && parent.IsSldVisited());
	if( g_animUseRuntime ) {
		collSeq = document.all.tags("seq");
		if( collSeq != null ) {
			for(ii=0;ii<collSeq.length;ii++) {
				if( collSeq[ii].getAttribute( "p:nodeType" ) == "mainSeq" ) {
					g_animMainSequence = collSeq[ii];
					break;
				}
			}
		}
	
		if( g_animItemsToHide && document.body.playAnimations != false ) {
			for(jj = 0; jj < g_animItemsToHide.length; jj++) {
				if( hideObj = GetObj(g_animItemsToHide[jj]) )
					hideObj.runtimeStyle.visibility="hidden";
			}
		}

		if( g_animInteractiveItems ){
			for(jj = 0; jj < g_animInteractiveItems.length; jj++) {
				if( triggerObj = GetObj(g_animInteractiveItems[jj]) )
					triggerObj.runtimeStyle.cursor="hand";
			}
		}
		
		if( gUseSldTimings && ''+g_animSlideTime != 'undefined' ) {
			adjustedTime = document.body.calculateAutoAdvanceTimes( g_animSlideTime, g_animEffectTimings );
			if( IsWin("PPTSld") && adjustedTime != g_animSlideTime ) {
			   var sld = GetCurSld();
			   sld.mAdvDelay = adjustedTime * 1000;
			}
		}
	}

	return g_animUseRuntime;
}

gSldJump = 0, gSldJumpTrack = 0, gSldJumpIdx = "";

function _KPH()
{ 
	if( IsNts() ) return;

	if( !parent.IsFramesMode() && event.keyCode == 27 && !HideMenu() )
		parent.window.close( self );
	else if( event.keyCode == 32 ) {
		if( window.name == "PPTSld" )
			parent.PPTSld.DocumentOnClick();
		else
			parent.GoToNextSld();
	}

	CatchNumKeys( parent, event );
}

function CatchNumKeys( win, event ) {
	if( win.IsFullScrMode() && (48<=event.keyCode) && (event.keyCode<=57) ) {
		gSldJump = 1;
		gSldJumpIdx += (event.keyCode-48).toString();
	}
	if( win.IsFullScrMode() && gSldJump && event.keyCode == 13 ) {
		var numSlds = parent.GetSldList().mList.length
		if ( gSldJumpIdx > numSlds )
			gSldJumpIdx = numSlds;
		if ( gSldJumpIdx >= 0 ) {
			if ( gSldJumpIdx == 0 )
				gSldJumpIdx = 1;
			var jumpTo = parseInt(gSldJumpIdx);
			gSldJump = 0; gSldJumpIdx = "";
			win.GoToSld( parent.GetSldList().mList[jumpTo-1].mSldHref )
		}
	}
}

function _KDH()
{
	if( event.keyCode == 8 ) {
		event.returnValue = 0;
		parent.GoToPrevSld();
	}
}
var g_HLinkArray = new Array();
 
function IMapAreaObj( areaObj, coords )
{
  this.areaObj = areaObj;
  this.coords = coords;
}

function InitHLinkArray()
{
  var appVer = navigator.appVersion;
  var msie = appVer.indexOf ( "MSIE " )
  var ver = 0;
  if ( msie >= 0 )
    ver = parseInt ( appVer.substring( msie+5 ) );

  linkNum = 0;

  for (i=0; i<document.all.tags("AREA").length; i++) {
    areaObj = document.all.tags("AREA").item(i);
    if( ( areaObj.id != "pptxscale" ) || ( ver > 4 ) )
      g_HLinkArray[linkNum++] = new IMapAreaObj( areaObj, ParseCoords( areaObj.coords ) );
  }
}

function ScaleHyperlinks( factor )
{   
  for ( ii=0; ii< g_HLinkArray.length; ii++) {
    coordsStr="";
    imaObj = g_HLinkArray[ii];
    for ( jj=0; jj < imaObj.coords.length-1; jj++ )
  	  coordsStr += (imaObj.coords[jj]*factor) + ",";
    coordsStr += (imaObj.coords[jj]*factor);
    imaObj.areaObj.coords = coordsStr;
  }
}

function ParseCoords( coordsStr )
{
  var numArray = new Array();
  var i = curPos = commaPos = 0;

  while ( ( commaPos = coordsStr.indexOf(",", curPos) ) != -1 ) { 
    numArray[i++] = parseInt( coordsStr.substr( curPos, commaPos ) );
    curPos = commaPos + 1;
  }
  numArray[i] = parseInt( coordsStr.substr( curPos ) );

  return numArray;
}

function DocumentOnClick()
{
	if( IsNts() || parent.HideMenu() ) return;

	if( ( g_allowAdvOnClick && (window.name=="PPTSld") && !parent.IsFramesMode() ) ||
	    (event && event.keyCode==32) ) {
		
		if( g_animUseRuntime && g_animMainSequence && g_animMainSequence.cangonext )
			return;

		parent.GoToNextSld();
	}
}


var g_supportsPPTHTML = SupportsPPTHTML(), g_scaleInFrame = 1, gId="", g_bgSound="",
    g_scaleHyperlinks = false, g_allowAdvOnClick = 1, g_showInBrowser = 0, gLoopCont = 0, gUseSldTimings = 1;
var g_showAnimation = g_supportsPPTHTML && SupportsPPTAnimation() && ( (window.name=="PPTSld" && !parent.IsFramesMode()) || g_showInBrowser );var g_animManager = null;
var g_animUseRuntime = false;
var g_animItemsToHide, g_animInteractiveItems, g_animSlideTime;
var g_animMainSequence = null;

var ENDSHOW_MESG="放映结束,单击鼠标退出。", SCREEN_MODE="Frames", gIsEndShow=0, NUM_VIS_SLDS=68, SCRIPT_HREF="script.js", FULLSCR_HREF="fullscreen.htm";
var gCurSld = gPrevSld = 1, g_offset = 0, gNtsOpen = gHasNts = gOtlTxtExp = 0, gHasNarration = 0, gOtlOpen = true
window.gPPTHTML=SupportsPPTHTML()
var gMainDoc=new Array(new hrefList("slide0051.htm",1,-1,1),new hrefList("slide0052.htm",1,-1,1),new hrefList("slide0053.htm",1,-1,1),new hrefList("slide0054.htm",1,-1,1),new hrefList("slide0055.htm",1,-1,1),new hrefList("slide0056.htm",1,-1,1),new hrefList("slide0057.htm",1,-1,1),new hrefList("slide0058.htm",1,-1,1),new hrefList("slide0059.htm",1,-1,1),new hrefList("slide0060.htm",1,-1,1),new hrefList("slide0061.htm",1,-1,1),new hrefList("slide0062.htm",1,-1,1),new hrefList("slide0063.htm",1,-1,1),new hrefList("slide0064.htm",1,-1,1),new hrefList("slide0065.htm",1,-1,1),new hrefList("slide0066.htm",1,-1,1),new hrefList("slide0067.htm",1,-1,1),new hrefList("slide0068.htm",1,-1,1),new hrefList("slide0069.htm",1,-1,1),new hrefList("slide0070.htm",1,-1,1),new hrefList("slide0071.htm",1,-1,1),new hrefList("slide0072.htm",1,-1,1),new hrefList("slide0073.htm",1,-1,1),new hrefList("slide0108.htm",1,-1,1),new hrefList("slide0074.htm",1,-1,1),new hrefList("slide0109.htm",1,-1,1),new hrefList("slide0075.htm",1,-1,1),new hrefList("slide0076.htm",1,-1,1),new hrefList("slide0077.htm",1,-1,1),new hrefList("slide0078.htm",1,-1,1),new hrefList("slide0079.htm",1,-1,1),new hrefList("slide0080.htm",1,-1,1),new hrefList("slide0081.htm",1,-1,1),new hrefList("slide0082.htm",1,-1,1),new hrefList("slide0083.htm",1,-1,1),new hrefList("slide0084.htm",1,-1,1),new hrefList("slide0085.htm",1,-1,1),new hrefList("slide0086.htm",1,-1,1),new hrefList("slide0110.htm",1,-1,1),new hrefList("slide0087.htm",1,-1,1),new hrefList("slide0088.htm",1,-1,1),new hrefList("slide0111.htm",1,-1,1),new hrefList("slide0089.htm",1,-1,1),new hrefList("slide0112.htm",1,-1,1),new hrefList("slide0090.htm",1,-1,1),new hrefList("slide0091.htm",1,-1,1),new hrefList("slide0092.htm",1,-1,1),new hrefList("slide0113.htm",1,-1,1),new hrefList("slide0093.htm",1,-1,1),new hrefList("slide0094.htm",1,-1,1),new hrefList("slide0095.htm",1,-1,1),new hrefList("slide0096.htm",1,-1,1),new hrefList("slide0114.htm",1,-1,1),new hrefList("slide0097.htm",1,-1,1),new hrefList("slide0098.htm",1,-1,1),new hrefList("slide0115.htm",1,-1,1),new hrefList("slide0099.htm",1,-1,1),new hrefList("slide0116.htm",1,-1,1),new hrefList("slide0100.htm",1,-1,1),new hrefList("slide0101.htm",1,-1,1),new hrefList("slide0102.htm",1,-1,1),new hrefList("slide0117.htm",1,-1,1),new hrefList("slide0103.htm",1,-1,1),new hrefList("slide0104.htm",1,-1,1),new hrefList("slide0105.htm",1,-1,1),new hrefList("slide0106.htm",1,-1,1),new hrefList("slide0107.htm",1,-1,1),new hrefList("slide0050.htm",1,-1,1));

/*********************************************
 Frameset functions

 These functions control slide navigation
 and state of the frameset.
**********************************************/

function FullScrInit()
{
	g_allowAdvOnClick = GetCurSld().mAdvOnClk
	document.body.style.backgroundColor="black"
	document.oncontextmenu=parent._CM;
	document.onkeydown = _KDH;
	document.ondragstart=Cancel
	document.onselectstart=Cancel
	self.focus()
}

function Redirect( frmId )
{	
	var str=document.location.hash,idx=str.indexOf('#'), sId=GetSldId()
	if(idx>=0) str=str.substr(1);
	if( window.name != frmId && ( sId != str) ) {
		obj = GetObj("Main-File")
		window.location.href=obj.href+"#"+sId
		return 1
	}
	return 0
}

var MHTMLPrefix = CalculateMHTMLPrefix(); 
function CalculateMHTMLPrefix()
{
	if ( document.location.protocol == 'mhtml:') { 
		href=new String(document.location.href) 
		Start=href.indexOf('!')+1 
		End=href.lastIndexOf('/')+1 
		if (End < Start) 
			return href.substring(0, Start) 
		else 
		return href.substring(0, End) 
	}
	return '';
}

function GetTags(base,tag)
{
	if(g_supportsPPTHTML) return base.all.tags(tag);
	else return base.getElementsByTagName(tag);
}


function UpdNtsPane(){ if(frames["PPTNts"]) PPTNts.location.replace( MHTMLPrefix+GetHrefObj( gCurSld ).mNtsHref ) }

function UpdNavPane( sldIndex ){ if(gNavLoaded) PPTNav.UpdNav() }

function UpdOtNavPane(){ if(gOtlNavLoaded) PPTOtlNav.UpdOtlNav() }

function UpdOtlPane(){ if(gOtlLoaded) PPTOtl.UpdOtl() }

function SetHasNts( fVal )
{
	if( gHasNts != fVal ) {
		gHasNts=fVal
		UpdNavPane()
	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?