X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=bin%2Fpreload.sh;h=dd7ce6b982d5a822b866f9fa23b87a3058847e89;hb=55ecf06dfdaa1f95a77f689d38eeb4faeea91ee5;hp=12e49b97cdaed4c2a60ec5776c562240b99cfa36;hpb=f18bac8374119fa1f3c826e82cfc74ce2ce52dd7;p=brisk.git diff --git a/bin/preload.sh b/bin/preload.sh index 12e49b9..dd7ce6b 100755 --- a/bin/preload.sh +++ b/bin/preload.sh @@ -1,7 +1,27 @@ #!/bin/bash +# +# brisk - preload.sh +# +# Copyright (C) 2006 matteo.nastasi@milug.org +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. You should have received a +# copy of the GNU General Public License along with this program; if +# not, write to the Free Software Foundation, Inc, 59 Temple Place - +# Suite 330, Boston, MA 02111-1307, USA. +# +# + OUTFILE=web/preload_img.js -IMGPATH=../brisk-img/img +IMGPATH=../brisk-img # ( # echo '' # ) > $OUTFILE +function imglist () { + ls -S `find $1 -type f -name '*.jpg' -o -name '*.png' -o -name '*.gif' | grep -v '/src_' | sort` +} + rm -f $OUTFILE ( echo "var g_preload_img_arr = new Array( " first=1 spa=" " -for i in `ls -S $IMGPATH/*.{jpg,png} | grep -v '/src_'`; do +ltri="`echo "$IMGPATH" | wc -c`" +for i in `imglist $IMGPATH`; do if [ $first -ne 1 ]; then echo -n ", " - if [ $ct -eq 4 ]; then + if [ $((ct % 2)) -eq 0 ]; then echo echo -n "$spa" - ct=0 fi else echo -n "$spa" fi - outna="img/`basename $i`" + outna="`echo "$i" | cut -c $((ltri + 1))-`" echo -n "\"$outna\"" ct=$((ct + 1)) first=0 done - +echo "CT: $ct" >&2 echo ");" ) >> $OUTFILE @@ -42,18 +66,17 @@ first=1 sum=0 spa=" " tot=0 -for i in `ls -S $IMGPATH`; do +for i in `imglist $IMGPATH`; do sz="`stat -c '%s' $IMGPATH/$i`" tot=$((tot + sz)) done -for i in `ls -S $IMGPATH`; do +for i in `imglist $IMGPATH`; do if [ $first -ne 1 ]; then echo -n ", " - if [ $ct -eq 8 ]; then + if [ $((ct % 8)) -eq 0 ]; then echo echo -n "$spa" - ct=0 fi else echo -n "$spa" @@ -66,6 +89,8 @@ for i in `ls -S $IMGPATH`; do first=0 done +echo "CT2: $ct" >&2 + echo ");" ) >> $OUTFILE