5 # Copyright (C) 2011-2012 Matteo Nastasi
6 # mailto: nastasi@alternativeoutput.it
7 # matteo.nastasi@milug.org
8 # web: http://www.alternativeoutput.it
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 # General Public License for more details. You should have received a
19 # copy of the GNU General Public License along with this program; if
20 # not, write to the Free Software Foundation, Inc, 59 Temple Place -
21 # Suite 330, Boston, MA 02111-1307, USA.
25 IMGPATHBASE="../brisk-img/"
31 # echo 'header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1'
32 # echo 'header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past'
36 function imglist_fla () {
43 for i in $(find "$pname" -maxdepth 1 -type f -name '*.jpg' -o -name '*.png' -o -name '*.gif' | grep -v '/src_' | sort); do
44 if [ "$rex" != "" ]; then
45 echo "$i" | grep -q "$rex"
47 if [ "$wrex" = "y" -a $rt -ne 0 ]; then
50 if [ "$wrex" = "n" -a $rt -eq 0 ]; then
54 echo "$i" | grep -q '.*\-[a-z][a-z]\....$'
56 # se file con suffisso di lingua
57 suff="$(echo "$i" | sed 's/\(.*\)\-\([a-z][a-z]\)\.\(...\)$/\2/g')"
59 if [ "$lang" = "$suff" ]; then
63 eni="$(echo "$i" | sed 's/\(.*\)\.\(...\)$/\1-en.\2/g')"
65 # esiste la versione _en
66 if [ "$lang" = "it" ]; then
67 # se lingua italiana le img mlang nn hanno estensione quindi va presa
71 # NON esiste la versione _en quindi e' una immagine NON mlang e va comunque presa
80 abspa="${IMGPATHBASE}${1}img"
81 if [ "$1" = "" ]; then
82 ls -S $( imglist_fla "$abspa" "$2" )
83 elif [ "$1" = "briskin5/" ]; then
84 rex='/[0-9][0-9][^/]*$'
85 ls -S $( imglist_fla "$abspa" "$2" "$rex" "y" )
86 ls -S $( imglist_fla "$abspa" "$2" "$rex" "n" )
91 if [ "$lang" = "it" ]; then
97 for dpath in "" briskin5/ ; do
98 OUTFILE="web/${dpath}"preload_img${fsuf}.js
99 echo "creating $OUTFILE ..."
101 IMGPATH="${IMGPATHBASE}${dpath}img"
103 echo "var g_preload_img_arr = new Array( "
106 ltri="`echo "$IMGPATH" | wc -c`"
107 for i in $(imglist "$dpath" "$lang"); do
108 if [ $first -ne 1 ]; then
110 if [ $((ct % 2)) -eq 0 ]; then
117 outna="img/`echo "$i" | cut -c $((ltri + 1))-`"
127 echo "var g_preload_imgsz_arr = new Array( "
132 ltri="`echo "$IMGPATH" | wc -c`"
133 for i in $(imglist "$dpath" "$lang"); do
134 outna="`echo "$i" | cut -c $((ltri + 1))-`"
135 sz="`stat -c '%s' $IMGPATH/$outna`"
139 for i in $(imglist "$dpath" "$lang"); do
140 outna="`echo "$i" | cut -c $((ltri + 1))-`"
141 if [ $first -ne 1 ]; then
143 if [ $((ct % 8)) -eq 0 ]; then
150 sz="`stat -c '%s' $IMGPATH/$outna`"
152 cur="`echo "100.0 * $sum / $tot" | bc -l | sed 's/\(\.[0-9]\)[0-9]*/\1/g'`"