|
|
|
| Приветствую, есть скрипт:
<script type="text/javascript">
var mygallery=new simpleGallery({
wrapperid: "simplegallery1",
dimensions: [899, 260],
imagearray: [
["slide/slide.jpg", "slide.htm", "", ""],
["slide/slide2.jpg", "slide2.htm", "", ""],
],
autoplay: [true, 5000, 2],
persist: false,
fadeduration: 500,
oninit:function(){
},
onslide:function(curslide, i){
}
})
</script>
|
можно ли как нибуть добавить в этот скрипт следующую функцию:
чтобы руками не забивать новые добавленые строки дописать так чтобы скрипт выводил названия файлов в находящиейся папке допустим images и вставлял их типа такого:
["slide/переменная с именем файла.jpg", "переменная с именем файла.htm", "", ""],
["slide/переменная с именем файла2.jpg", "переменная с именем файла2.htm", "", ""],
["slide/переменная с именем файла3.jpg", "переменная с именем файла3.htm", "", ""],
...
|
| |
|
|
|
|
|
|
|
для: tima2010
(01.03.2010 в 15:33)
| | На PHP это выглядит так
<?php
$test_dir_slide = "slide";
$dir_slide = dir($test_dir_slide);
$i_slide = 0;
$names_slide = "";
while ($entry_slide = $dir_slide->read())
{
if(($entry_slide != "..") && ($entry_slide != "."))
{
$p_slide = strcspn($entry_slide,".");
$names_slide[$i_slide] = substr($entry_slide,0,"$p_slide");
$i_slide++;
}
}
$dir_slide->close();
$count_slide = $i_slide;
for($i_slide = 0; $i_slide < $count_slide; $i_slide++)
{
print '
<li><a href="'.$names_slide[$i_slide].'.html"><img src="slide/'.$names_slide[$i_slide].'.jpg" /></a></li>
';
}
?>
|
| |
|
|
|
|
|
|
|
для: tima2010
(01.03.2010 в 15:51)
| | js не сможет прочитать содержимое папки | |
|
|
|
|
|
|
|
для: AlexSol
(01.03.2010 в 16:00)
| | а вот этот скрипт что делает тогда? он вроде как считывает файлы?
var bxs,bxe,fxs,fxe,ys,ye,ta,ia,ie,st,ss,ft,fs,xp,yp,ci,t,tar,tarl;
ta = document.getElementById(thumbid);
ia = document.getElementById(imgid);
t = ta.getElementsByTagName('li')
ie = document.all ? true : false;
st = 3;
ss = 3;
ft = 10;
fs = 5;
xp,yp = 0;
document.onmousemove = getPos;
function slideShow(){
var taw = ta.parentNode.offsetWidth;
var taa = taw / 4;
bxs = leftPos(ta);
bxe = bxs + taa;
fxe = bxs + taw;
fxs = fxe - taa;
ys = topPos(ta);
ye = ys + ta.offsetHeight;
var len = t.length;
tar = [];
for(i=0; i < len; i++){
var id = t[i].id;
tar[i] = id;
t[i].onclick = new Function("getImg('" + id + "')");
if(i == 0) {
getImg(id);
}
}
tarl = tar.length;
}
function scrlThumbs(d){
clearInterval(ta.timer);
var l;
if(d == -1){
l = 0;
}else{
l = t[tarl-1].offsetLeft - (ta.parentNode.offsetWidth - t[tarl-1].offsetWidth) + 10;
}
ta.timer = setInterval(function(){scrlMv(d,l)},st);
}
function scrlMv(d,l){
ta.style.left = ta.style.left || '0px';
var left = ta.style.left.replace('px','');
if(d == 1){
if(l - Math.abs(left) <= ss){
cnclScrl(ta.id);
ta.style.left = '-' + l + 'px';
}else{
ta.style.left = left - ss + 'px';
}
}else{
if(Math.abs(left) - l <= ss){
cnclScrl(ta.id);
ta.style.left = l + 'px';
}else{
ta.style.left = parseInt(left) + ss + 'px';
}
}
}
function cnclScrl(){clearTimeout(ta.timer)}
function getImg(id){
var hl = id.indexOf('_');
var is,ip,il;
if(hl != -1){
ip = id.split('_');
is = ip[0];
il = ip[1];
}else{
is = id;
}
if(auto){clearTimeout(ia.timer)}
if(ci != null){
var ts = ia.getElementsByTagName('img');
var tsl = ts.length;
var x = 0;
for(x; x < tsl; x++){
if(ci.id != id){
var o = ts[x];
clearInterval(o.timer);
o.timer = setInterval(function(){fdOut(o)},fs);
}
}
}
var i;
if(!document.getElementById(ie)){
if(hl != -1){
a = document.createElement('a');
a.setAttribute('href',il);
ia.appendChild(a);
i = document.createElement('img');
a.appendChild(i);
}else{
i = document.createElement('img');
ia.appendChild(i);
}
i.id = id;
i.av = 0;
i.style.opacity = 0;
i.style.filter = 'alpha(opacity=0)';
i.src = imgdir + '/' + is;
i.onclick= function(){
location.href= id + '.html';
}
}else{
i = document.getElementById(is);
clearInterval(i.timer);
}
i.timer = setInterval(function(){fdIn(i)},fs);
}
function imgNav(d){
var curr = 0;
var ae,ie;
for(key in tar){
ae = tar[key].split('_');
if(ae[0] == ci.id){
curr = key;
}
}
if(tar[parseInt(curr) + d]){
ie = tar[parseInt(curr) + d];
}else{
if(d == 1){
ie = tar[0];
}else{
ie = tar[tarl - 1];
}
}
getImg(ie);
}
function autoSlide(){
ia.timer = setInterval(function(){imgNav(1)}, autodelay * 1000);
}
function fdIn(i){
if(i.complete){
i.av = i.av + fs;
i.style.opacity = i.av / 100;
i.style.filter = 'alpha(opacity=' + i.av + ')';
}
if(i.av >= 100){
if(auto){autoSlide()}
clearInterval(i.timer);
ci = i;
}
}
function fdOut(i){
i.av = i.av - fs;
i.style.opacity = i.av / 100;
i.style.filter = 'alpha(opacity=' + i.av + ')';
if(i.av <= 0){
clearInterval(i.timer);
if(i.parentNode){i.parentNode.removeChild(i)}
}
}
function getPos(e){
if(ie){
xp = event.clientX + document.body.scrollLeft;
yp = event.clientY + document.body.scrollTop;
}else{
xp = e.pageX;
yp = e.pageY;
}
if(xp < 0){xp = 0}
if(yp < 0){yp = 0}
if(xp > bxs && xp < bxe && yp > ys && yp < ye){
scrlThumbs(-1);
}else if(xp > fxs && xp < fxe && yp > ys && yp < ye){
scrlThumbs(1);
}else{
cnclScrl();
}
}
function leftPos(t){
var left = 0;
if(t.offsetParent){
while(1){
left += t.offsetLeft;
if(!t.offsetParent){break}
t = t.offsetParent;
}
}else if(t.x){
left += t.x;
}
return left;
}
function topPos(t){
var top = 0;
if(t.offsetParent){
while(1){
top += t.offsetTop;
if(!t.offsetParent){break}
t = t.offsetParent;
}
}else if(t.y){
top += t.y;
}
return top;
}
|
| |
|
|
|
|