Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

imam mali problem sa skiptom oko sortiranja

[es] :: Javascript i AJAX :: imam mali problem sa skiptom oko sortiranja

[ Pregleda: 2087 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

zrnoo
Vukašin
dizajn, programiranje
Beograd

Član broj: 73204
Poruke: 312
*.adsl.beotel.net.

ICQ: 56375637
Sajt: www.Tjuner.com


Profil

icon imam mali problem sa skiptom oko sortiranja24.08.2007. u 23:17 - pre 202 meseci
imam sledecu skriotu ,ona vadi sve slike iz jednog direktorijuma i prikazuje ih u ajax formi. E sada imam mali problem oko sortiranja. asc,dsc ili "" . E sada ja zelim da podesim da idu po redu po ime...Znaci 1,2,3...iktd ili a,b,c,d ... znaci u tom obliku, al on mi stalno radi 1,3,4,5,6,7,2 . KAPIRATe, uvek mi na kraj gurne 2 i mozda jos jednu iz sredine. Neznam zasto to radi.. Znaci treba mi pomoc oko sortiranja po nazivu!!!

Obratite paznju na deo kod:
//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

probao sam to li neradi, uvek daje isti problem odozgo!!!

molim vas jako mi je hitno , ako je moguce i ako neko zna. Hvala punooo unapred.

ovo je deo koji se stabvi u html fajl
Code:

<script src="adresa sajta" type="text/javascript"></script>
                        <script type="text/javascript">

/***********************************************
* PHP Photo Album script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
* This notice must stay intact for legal use
***********************************************/

var dimension="2x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="adresa sajta" //Absolute path to image directory. Include trailing slash (/)
var href_target="new" //Enter target attribute of links, if applicable

//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[1, "Slika "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option
var targetlinkdir="adresa sajta"

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath=(targetlinkdir!="")? targetlinkdir+galleryarray[i][0] : imagepath+galleryarray[i][0]
var tempcontainer='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+' ['+galleryarray[i][1]+']" />'
tempcontainer+='</a><br />'
tempcontainer+=(descriptionprefix[0]==1)? descriptionprefix[1]+(i+1) : ""
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('<br style="clear: left" />')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false
}
else
return true
}

                  </script>
                        <!--Below HTML code refers to the navigational links for the gallery-->


getipics.php
Code:

<?
Header("content-type: application/x-javascript");

function returnimages($dirname=".") {
   $pattern="\.(jpg|jpeg|png|gif|bmp)$";
   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle))){
               if(eregi($pattern, $file)){
         $filedate=date ("M d, Y H:i:s", filemtime($file));
                 echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
                 $curimage++;
               }
       }

       closedir($handle);
   }
   return($files);
}

echo "var galleryarray=new Array();" . "\n";
returnimages();
?> 

 
Odgovor na temu

zrnoo
Vukašin
dizajn, programiranje
Beograd

Član broj: 73204
Poruke: 312
*.adsl.beotel.net.

ICQ: 56375637
Sajt: www.Tjuner.com


Profil

icon Re: imam mali problem sa skiptom oko sortiranja27.08.2007. u 09:54 - pre 202 meseci
dal je moguce da niko nezna!? Barem neka informacija!!!
 
Odgovor na temu

bzero
dev null
europe

Član broj: 5907
Poruke: 371
*.dynamic.sbb.co.yu.

Jabber: bzero@elitesecurity.org
Sajt: www.google.com/search?q=b..


Profil

icon Re: imam mali problem sa skiptom oko sortiranja27.08.2007. u 10:21 - pre 202 meseci
Pa ne moze da sortira po imenu kada sortiranje vrsis po datumu, cak se i funkcija koju koristis zove sortbydate :)

http://www.javascriptkit.com/javatutors/arraysort.shtml

Never trust an operating system you don't have sources for.
 
Odgovor na temu

zrnoo
Vukašin
dizajn, programiranje
Beograd

Član broj: 73204
Poruke: 312
*.adsl.beotel.net.

ICQ: 56375637
Sajt: www.Tjuner.com


Profil

icon Re: imam mali problem sa skiptom oko sortiranja29.09.2007. u 23:35 - pre 201 meseci
pa jr moze neko da mi nekak opomogne posto ja nemam pojma javu (javascript) a jako jako mi je bitno i hitno). oteglo se a nisam nista uspeo da uradim...pleaseeeee!!!!!
 
Odgovor na temu

Br@nkoR
http://localhost

Član broj: 2597
Poruke: 1603

Sajt: localhost


+23 Profil

icon Re: imam mali problem sa skiptom oko sortiranja30.09.2007. u 09:57 - pre 201 meseci
Pa dosad si mogao da naučiš JavaScript

Kao što si rekao da obratimo pažnju na deo kôda.
Citat:
zrnoo:
//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder="desc"


i ukoliko u kôdu portažiš gde uzima ovu vrednost.
Citat:
zrnoo:
Code:
if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

videćeš da on samo sortira niz za dve vrednosti asc i desc, ukoliko nije ništa upisano u gore citiranu promenljivu biće prikazano onako kako vraća sever, pa ti to proveri. I ukoliko je portebno ti dodatno sortiraj, kada ništa nije definisano u gsortorder, na server strani, to nije pitanje za ovaj forum ili na client strani, a za to ti je bzero dao link.
Ili kontaktiraj autora od koga si preuzeo skriptu.

Banned - Not available
 
Odgovor na temu

[es] :: Javascript i AJAX :: imam mali problem sa skiptom oko sortiranja

[ Pregleda: 2087 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.