照片自动播放程序怎样跳过非照片?
我做了一个slideshow即幻灯秀,就是网页中照片自动播放,
程序运行良好,可以循环。
但是,如果目录里有其他文件如:txt 等等非jpg文件时我的幻灯秀就不动了,
怎么样让程序跳过那些文件,或者是不是可以写一行代码判断一下?
那么怎么判断是不是jpg文件文件呢?
完整代码如下:
<body vLink="#336699" aLink="#ff0000" link="#336699" bgColor="#ffffff" leftMargin="0" topMargin="0" MS_POSITIONING="FlowLayout" marginwidth="0" marginheight="0">
<center>
<form id="ShowFile" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="100%" border="0"></table>
<table cellSpacing="0" cellPadding="0" align="center" border="0">
<tr><td>
<div align="center">
<div align="left">
<%
//fileID = GetIntParam("fileID"); // is it safe? already assigned in base
String view = GetStrParam("view");
String sort = GetStrParam("sort");
String isInc = GetStrParam("isInc");
int curPage = GetIntParam("curPage");
String share = GetStrParam("share");
long shareID = GetLongParam("shareID");
long parentID = GetLongParam("parentID");
String isGallery= GetStrParam("isGallery");
String filePath = "";
if(file!=null)
filePath = file.filePath;
//int seq = seq // member variable, is it safe?
if(fileName==null) fileName="";
DataTable filesDT = (DataTable)Session["filesDT" + shareID+parentID];
%>
<% String pageClass = "ShowFolder"; //isGallery=="true"? "ShowGallery": "ShowFolder";
%>
<asp:HyperLink ID="PrevHyperLink" runat="server"></asp:HyperLink>
<asp:HyperLink ID="NextHyperLink" runat="server"></asp:HyperLink>
</a>
<table width="100%" border=0>
<tr>
<td align="center" valign="top">
<% int i;
for(i=0; filesDT!=null && i<filesDT.Rows.Count; ++i) {
%>
<a id="photo_urls_<%=i%>" href='DF.aspx/<%=filesDT.Rows[i]["fileName"]%>?size=pv&isGallery=<%=isGallery%>&share=<%=share%>&shareID=<%=shareID%>&fileID=<%=filesDT.Rows[i]["fileID"]%>&sesID=<%=Session.SessionID%>&type=text/html&ft=<%=filesDT.Rows[i]["modifyTime"]%>'></a>
<a id="full_photo_urls_<%=i%>" href='DF.aspx/<%=filesDT.Rows[i]["fileName"]%>?isGallery=<%=isGallery%>&share=<%=share%>&shareID=<%=shareID%>&fileID=<%=filesDT.Rows[i]["fileID"]%>&sesID=<%=Session.SessionID%>&type=text/html&ft=<%=filesDT.Rows[i]["modifyTime"]%>'></a>
<% } %>
<script language="JavaScript" SRC="client_sniff.js"></script>
<script language="JavaScript">
var timer;
var current_location = 1;
var next_location = 1;
var pics_loaded = 0;
var onoff = 0;
var fullsized = 0;
var direction = 1;
var timeout_value;
var images = new Array;
var photo_urls = new Array;
var full_photo_urls = new Array;
var photo_captions = new Array;
var transitionNames = new Array;
var transitions = new Array;
var current_transition = 15;
var loop = 0;
transitions[0] = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
transitions[1] = "progid:DXImageTransform.Microsoft.Blinds(Duration=1,bands=20)";
transitions[2] = "progid:DXImageTransform.Microsoft.Checkerboard(Duration=1,squaresX=20,squaresY=20)";
transitions[3] = "progid:DXImageTransform.Microsoft.Strips(Duration=1,motion=rightdown)";
transitions[4] = "progid:DXImageTransform.Microsoft.Barn(Duration=1,orientation=vertical)";
transitions[5] = "progid:DXImageTransform.Microsoft.GradientWipe(duration=1)";
transitions[6] = "progid:DXImageTransform.Microsoft.Iris(Duration=1,motion=out)";
transitions[7] = "progid:DXImageTransform.Microsoft.Wheel(Duration=1,spokes=12)";
transitions[8] = "progid:DXImageTransform.Microsoft.Pixelate(maxSquare=10,duration=1)";
transitions[9] = "progid:DXImageTransform.Microsoft.RadialWipe(Duration=1,wipeStyle=clock)";
transitions[10] = "progid:DXImageTransform.Microsoft.RandomBars(Duration=1,orientation=vertical)";
transitions[11] = "progid:DXImageTransform.Microsoft.Slide(Duration=1,slideStyle=push)";
transitions[12] = "progid:DXImageTransform.Microsoft.RandomDissolve(Duration=1,orientation=vertical)";
transitions[13] = "progid:DXImageTransform.Microsoft.Spiral(Duration=1,gridSizeX=40,gridSizeY=40)";
transitions[14] = "progid:DXImageTransform.Microsoft.Stretch(Duration=1,stretchStyle=push)";
transitions[15] = "special case";
var transition_count = 15;
var photo_count ="<%=i%>";
if ( (is_ie && !is_ie4up) || (is_opera && !is_opera5up) || (is_nav && !is_nav6up)) {
document.location = slideShowLow;
}
var browserCanBlend = (is_ie5_5up);
function stopOrStart() {
if (onoff) {
stop();
} else {
play();
}
}
function fullOrNormal() {
images = new Array;
pics_loaded=0;
if (fullsized) {
normal();
} else {
full();
}
next_location = current_location;
preload_photo(next_location);
go_to_next_photo();
}
function toggleLoop() {
if (loop) {
loop = 0;
} else {
loop = 1;
}
}
function changeElementText(id, newText) {
element = document.getElementById(id);
element.innerHTML = newText;
}
function stop() {
changeElementText("stopOrStartText", "播放");
onoff = 0;
status = "幻灯秀已停止点击播放继续";
clearTimeout(timer);
}
function play() {
changeElementText("stopOrStartText", "停止");
onoff = 1;
status = "幻灯秀正在运行";
go_to_next_photo();
}
function full() {
changeElementText("fullOrNormalText", "小图");
fullsized = 1;
status = "The slide is showing full sized images, Click [normal size] to view resized images.";
}
function normal() {
changeElementText("fullOrNormalText", "大图");
fullsized = 0;
status = "The slide is showing normal sized images, Click [full size] to view full sized images.";
}
function changeDirection() {
if (direction == 1) {
direction = -1;
changeElementText("changeDirText", "往后");
} else {
direction = 1;
changeElementText("changeDirText", "往前");
}
preload_next_photo();
}
function change_transition() {
current_transition = document.ShowFile.transitionType.selectedIndex;
}
function preload_complete() {
}
function reset_timer() {
clearTimeout(timer);
if (onoff) {
timeout_value = document.ShowFile.time.options[document.ShowFile.time.selectedIndex].value * 1000;
timer = setTimeout('go_to_next_photo()', timeout_value);
}
}
function wait_for_current_photo() {
if (!show_current_photo()) {
status = "正在载入(" + current_location + " of" + photo_count +
"). " + "请稍候..." ;
clearTimeout(timer);
timer = setTimeout('wait_for_current_photo()', 500);
return 0;
} else {
status = "幻灯秀正在运行..." ;
preload_next_photo();
reset_timer();
}
}