Adding size sort
This commit is contained in:
@@ -99,6 +99,13 @@ def getfiletimes(path,list):
|
||||
times.append(int(os.path.getmtime(os.path.join(path,p))))
|
||||
return times
|
||||
|
||||
def getfilesizes(path,list):
|
||||
''' Returns a list of sizes '''
|
||||
sizes=[]
|
||||
for p in list:
|
||||
sizes.append(int(os.path.getsize(os.path.join(path,p))))
|
||||
return sizes
|
||||
|
||||
def getnonimagelist(path,options):
|
||||
''' Returns a list of files not matching the image match regex '''
|
||||
list=os.listdir(path)
|
||||
@@ -172,6 +179,7 @@ def imagescript(path,list):
|
||||
strout='<script language="javascript">var imagelist=['
|
||||
descriptions=getdescriptions(path,list)
|
||||
times=getfiletimes(path,list)
|
||||
sizes=getfilesizes(path,list)
|
||||
n=0
|
||||
elements=[]
|
||||
for i in list:
|
||||
@@ -181,6 +189,7 @@ def imagescript(path,list):
|
||||
desc=singlequotes.sub("\\'",filter(lambda x: x in string.printable, descriptions[n]).encode('ascii', 'xmlcharrefreplace'))
|
||||
this_str='\n{name:"'+unicode(i,encoding="utf8").encode('ascii', 'xmlcharrefreplace')+'", '
|
||||
this_str+='desc:\''+desc+'\', '
|
||||
this_str+='size:\''+str(sizes[n])+'\', '
|
||||
this_str+='time:'+str(times[n])+'}'
|
||||
elements.append(this_str)
|
||||
n+=1
|
||||
|
||||
@@ -1275,6 +1275,11 @@ function sortlist(property) {
|
||||
return a.time-b.time
|
||||
})
|
||||
}
|
||||
if (property=='size') {
|
||||
templist.sort(function(a,b) {
|
||||
return a.size-b.size
|
||||
})
|
||||
}
|
||||
if (property=='alpha') {
|
||||
templist.sort(function(a, b){
|
||||
if (a.name < b.name)
|
||||
@@ -1713,6 +1718,7 @@ function getsetupwindow() {
|
||||
'<input type="submit" id="configZoom" value="Zoom" onclick="flipzoom();" title="Use zoomer on images. [z]"/></div>'+
|
||||
'<div><input type="submit" id="configSortName" value="Sort by name" onclick="sortlist(\'alpha\');" title="Sort thumbnail list by image name."/>'+
|
||||
'<input type="submit" id="configSortTime" value="Sort by time" onclick="sortlist(\'time\');" title="Sort thumbnail list by image modification time."/>'+
|
||||
'<input type="submit" id="configSortSize" value="Sort by size" onclick="sortlist(\'size\');" title="Sort thumbnail list by image byte size."/>'+
|
||||
'<input type="submit" id="configSortRev" value="Reverse sort" onclick="sortlist(\'rev\');" title="Sort thumbnail list in reverse order."/></div>'+
|
||||
'<div><input type="submit" value="All thumbnails" onclick="allthumbs();" title="all thumbnails view. [a]"/>'+
|
||||
'<input type="submit" value="All medium images" onclick="allmediums();" title="all medium images view. [m]"/></div>'+
|
||||
|
||||
Reference in New Issue
Block a user