@echo off

rem ----------------------------------------------------------------------------
rem -----                     makeSlideShow.bat
rem ----------------------------------------------------------------------------
rem -----
rem ----- Generates <html> files for Peter's Web Gallery
rem -----
rem -----               Slideshow and a Thumbnailshow
rem -----
rem ----- If the images have been edited with a program like Adobe Lightroom,
rem ----- the slideshow can extract the metadata and use for title and caption.
rem ----- This way you avoid editing of title and caption in the slideshow file.
rem -----
rem ----- More or less important parameters are located in the file
rem ----- slideShowParams.bat (same folder)
rem ----- Customize these parameters before executing makeSlideShow.bat !!!
rem -----
rem -----
rem ----- peter@danninger.eu                                      09.02.2020
rem ----------------------------------------------------------------------------

rem   UTF-8 Codepage (important evtl. for TITEL)
rem   Important: Save file as UTF8 (without BOM) !!!!!
chcp 65001

set VERSION=09.02.2020

set SCRIPTNAME="Peters_Slideshow_Script_%VERSION%"

rem ----- important if running as Administrator: (current directory)
cd /d "%~dp0"

rem ----- This Script got started from the WebShow folder
rem -----   an actual version will evtl. be copied from %SCRIPTSDIR% or %SCRIPTSROOT%
rem -----   and restarted with the parameter "restart"

set Restart=restart
rem ----- x take car of missing parameter %1 on 1. start
if x%1x EQU x%Restart%x (
  echo.
  echo restarted .......
)

rem evtl. for der "Simple" demo-files (makeSlideShowSimple.bat)
set SIMPLE=
if "%1"=="Simple"     set SIMPLE=Simple

echo.
echo ---------------------------------------------------------------------------
echo %0
echo Author:        peter@danninger.eu
echo Version:       %SCRIPTNAME%
echo ---------------------------------------------------------------------------
echo The script generates ^<html^> files for a slideshow and a thumbnailshow.
echo.
echo   =====^>    pay attention to the conventions: "\help\help.html"     ^<=====
echo.
echo   =====^>    check "slideShowParams%SIMPLE%.bat" before the start    ^<=====
echo ---------------------------------------------------------------------------
echo.

set AUTHOR=http://www.danninger.eu
set EMAIL=peter@danninger.eu

set DATE=%date%

rem name of the parameter file, in the same folder !!!
set PARAMS=slideShowParams%SIMPLE%.bat

rem search string for optional startnumber (first slide)
set STARTNR=startNr

rem ATTENTION:
rem If modifying DIV class names ===> modify slideshow.css too !
rem -------------------------------------------------------------------------
rem class name of the DIV with the slideshow
set SLIDESHOWD=slideShow
if %SLIDESHOWD% NEQ slideShow    echo   ===^> "slideshow.css" has to be modified:   slideShow

rem class name of the DIV with the slides
set SLIDESD=slides
if %SLIDESD% NEQ slides          echo   ===^> "slideshow.css" has to be modified:   slides

rem class name of the DIV with the optional page title
set PAGETITLED=pageTitle
if %PAGETITLED% NEQ pageTitle    echo   ===^> "slideshow.css" has to be modified:   pageTitle

rem class name of the DIV with the optional slide title
set FIGTITLED=figTitle
if %FIGTITLED% NEQ figTitle      echo   ===^> "slideshow.css" has to be modified:   figTitle

rem class name of the DIV for the help- and meta-informations
set HELP_METAD=helpMeta
if %HELP_METAD% NEQ helpMeta     echo   ===^> "slideshow.css" has to be modified:   helpMeta
rem -------------------------------------------------------------------------
echo.

if not exist "%~dp0%PARAMS%"  goto :paramErr
goto :paramOK

:paramErr
echo.
color 0C
echo   not found:   %~dp0%PARAMS%
echo   is the script in the slideshow folder ?
echo.
pause
exit

:paramOK
rem ----------------------------------------------------------------------------
rem ----- call and evaluate the parameter file
rem ----------------------------------------------------------------------------
call "%~dp0%PARAMS%" %SIMPLE%
echo call and evaluate parameter file:
echo.
echo %~dp0%PARAMS%
echo.
echo Header:         %PARAMSHEADER% (%PARAMSDATE%)
echo.

if x%1x EQU x%Restart%x goto :restarted1

rem \ statt / because of copy
set SCRIPTSDIR1=%SCRIPTSDIR:/=\%
rem to be sure ...
set SCRIPTSROOT=%SCRIPTSROOT:/=\%

if %SCRIPTSDIR% EQU ./ (
  echo local scripts and styles folders: ./
  if "%SCRIPTSROOT%"=="false" (
    echo no scripts and styles root folder, p.e. in the demo folder
  ) else if "%SCRIPTSROOT%" NEQ "" (
    echo scripts and styles root folder: %SCRIPTSROOT%
    if not exist "%SCRIPTSROOT%" (
      echo.
      color 0C
      echo   error in %PARAMS%:   %SCRIPTSROOT% not found
      pause
      exit
    )
    rem copy makeSlideShow.bat from %SCRIPTSROOT% and restart it .....
    echo.
    copy /b %SCRIPTSROOT%makeSlideShow.bat %~dp0makeSlideShow.bat > NUL
    if %ERRORLEVEL% NEQ 0 (
      color 0C
      echo %SCRIPTSROOT%makeSlideShow.bat copy error
      pause
      exit
    )
    pause
    call %~dp0makeSlideShow.bat %Restart%
    exit
  )
  echo.
) else if "%SCRIPTSDIR1%" NEQ "" (
  echo common scripts and styles folders: %SCRIPTSDIR1%
  if not exist "%SCRIPTSDIR1%" (
    color 0C
    echo   error in %PARAMS%:   %SCRIPTSDIR1% not found
    pause
    exit
  )
  echo   copy makeSlideShow.bat from %SCRIPTSDIR1% and restart it .....
  echo.
  copy /b %SCRIPTSDIR1%makeSlideShow.bat %~dp0makeSlideShow.bat > NUL
  if %ERRORLEVEL% NEQ 0 (
    color 0C
    echo %SCRIPTSDIR1%makeSlideShow.bat copy error
    pause
    exit
  )
  pause
  call %~dp0makeSlideShow.bat %Restart%
  exit
)

:restarted
pause
echo.
:restarted1

if "%SCRIPTSDIR%"=="" (
  echo   if just one slideshow, the scripts are evtl. locally "./"
  echo   if more slideshows, then evtl. in a shared folder "../slideShow/"
  ver > NUL
  echo.
  set /p SCRIPTSDIR=folder with the scripts and styles:
  if %ERRORLEVEL% NEQ 0       set SCRIPTSDIR=./
  echo.
)
if "%SCRIPTSDIR%"==""         set SCRIPTSDIR=./

echo   folder with the scripts and styles:    %SCRIPTSDIR%

if "%SCRIPTSROOT%"=="false" (
  set SCRIPTSROOT=
)
if not "%SCRIPTSDIR%"=="./" (
  set SCRIPTSROOT=
)

echo   cripts and styles root folder :  %SCRIPTSROOT%

if %SCRIPTSDIR% EQU ./ (
  if "%SCRIPTSROOT%" NEQ "" (
    if not exist "%SCRIPTSROOT%" (
      echo.
      color 0C
      echo   Fehler in %PARAMS%:   %SCRIPTSROOT% not found
      pause
      exit
    ) else (
      if not exist .\js\            mkdir .\js
      if not exist .\css\           mkdir .\css
      if not exist .\fonts\         mkdir .\fonts
      if not exist .\help\          mkdir .\help
      if not exist .\icons\         mkdir .\icons
      echo   copy scripts and styles files from:  %SCRIPTSROOT%
      ver > NUL
      xcopy %SCRIPTSROOT%js .\js\ /Y /E /Q > NUL
      if %ERRORLEVEL% NEQ 0   echo folder "js" could not be copied
      ver > NUL
      xcopy %SCRIPTSROOT%css .\css\ /Y /E /Q > NUL
      if %ERRORLEVEL% NEQ 0   echo folder "css" could not be copied
      ver > NUL
      xcopy %SCRIPTSROOT%fonts .\fonts\ /Y /E /Q > NUL
      if %ERRORLEVEL% NEQ 0   echo folder "fonts" could not be copied
      ver > NUL
      xcopy %SCRIPTSROOT%help .\help\ /Y /E /Q > NUL
      if %ERRORLEVEL% NEQ 0   echo folder "help" could not be copied
      ver > NUL
      xcopy %SCRIPTSROOT%icons .\icons\ /Y /E /Q > NUL
      if %ERRORLEVEL% NEQ 0   echo folder "icons" could not be copied
      ver > NUL
    )
  )
)

rem page title, if not in slideShowParams.bat:
if "%TITEL%"=="" (
  :ein1
  ver > nul
  echo.
  set /p TITEL=please input page title:
  if %ERRORLEVEL% NEQ 0     goto :ein1
)
if "%TITEL%"==""            goto :ein1

echo   page title:                            %TITEL%

if "%BILDNAME%"=="" (
  echo   Convention: the following input without the 3 digit sequence at the end !
  echo   Examples for slide names:  "slidename_001" ... "slidename_125".
  echo   You have to input: "slidename_".
  echo.
  :ein2
  ver > nul
  set /p BILDNAME=Please input the basename of the slides:
  if %ERRORLEVEL% NEQ 0     goto :ein2
  echo.
)
if "%BILDNAME%"==""         goto :ein2

echo   slide name (+ 3 digit sequence):       %BILDNAME%

if "%BILDANZ%"==""  (
  :ein3
  ver > nul
  echo.
  set /p BILDANZ=please input number of slides, max 999:
  if %ERRORLEVEL% NEQ 0     goto :ein3
  echo.
)
if "%BILDANZ%"==""          goto :ein3
if %BILDANZ% LSS 1          goto :ein3
if %BILDANZ% GTR 999        goto :ein3

echo   number of slides:                      %BILDANZ%

rem number of images, from that on additional thumbnails will be added depending on the scrollbar position
if "%SCROLLANZ%"==""              set SCROLLANZ=64
if %SCROLLANZ% NEQ false (
  if %BILDANZ% LSS %SCROLLANZ%    set SCROLLANZ=false
)

echo   add thumbnails dynamically from:       %SCROLLANZ%

rem name of the thumbnailshow, if not defined in slideShowParams.bat:
if "%FILE1%"==""            set FILE1=index.html
if exist %FILE1%            copy %FILE1% %FILE1%.bak > nul
echo   thumbnailshow:                         %FILE1%

rem name of the slideshow, if not defined in slideShowParams.bat
if "%FILE2%"==""            set FILE2=slideshow.html
if exist %FILE2%            copy %FILE2% %FILE2%.bak > nul
echo   slideshow:                             %FILE2%

rem name of the folder with the slides, if not defined in slideShowParams.bat
if "%SLIDES%"==""           set SLIDES=slides
echo   slides folder:                         %SLIDES%

rem name of the folder with the thumbnails, if not defined in slideShowParams.bat
if "%THUMBNAILS%"==""       set THUMBNAILS=thumbnails
echo   thumbnail folder:                      %THUMBNAILS%

rem name of the folder with the original(big) images, if not defined in slideShowParams.bat
if "%ORIPICDIR%"==""        set ORIPICDIR=false
echo   original(big) pics folder:             %ORIPICDIR%

rem enlarge slides on big displayes, if not defined in slideShowParams.bat
if "%ENLARGE%"==""          set ENLARGE=true
echo   enlarge slides on big displayes:       %ENLARGE%

rem evtl. heading text over the thumbnailshow, if not defined in slideShowParams.bat:
if "%THUMB_TEXT%"=="" (
  echo.
  set /p THUMB_TEXT=please input heading text for the thumbnailshow:
  if %ERRORLEVEL% NEQ 0       set THUMB_TEXT=
)
if "%THUMB_TEXT%"=="false" (
  set THUMB_TEXT=
)
if THUMB_TEXT=="" (
  echo   no heading text over the thumbnailshow
) else (
  echo   heading text over the thumbnailshow: %THUMB_TEXT%
)

if "%EMPTYCAPTION%"=="true" (
  goto :weiter1
) else if "%EMPTYCAPTION%"=="false" (
  goto :weiter1
) else if "%EMPTYCAPTION%"=="" (
  echo   does make sense only if the ^<figcaption^> will be edited manually
  :ein4
  ver > nul
  set /p EMPTYCAPTION=should be generated empty ^<figcaption^> [y ^| n]:
  if %ERRORLEVEL% NEQ 0         goto :ein4
  echo.
)
if "%EMPTYCAPTION%"=="" (
  goto :ein4
}
if /I "%EMPTYCAPTION%"=="y" (
  set EMPTYCAPTION=true
  goto :weiter1
) else if /I "%EMPTYCAPTION%"=="n" (
  set EMPTYCAPTION=false
  goto :weiter1
) else (
  goto :ein4
)

:weiter1
echo   generate empty ^<figcaption^>:           %EMPTYCAPTION%

if "%MAKE_PAGETITLE%"=="true" (
  goto :weiter2
) else if "%MAKE_PAGETITLE%"=="false" (
  goto :weiter2
)
if "%MAKE_PAGETITLE%"=="" (
  echo   does make sense only if no individual image title.
  :ein5
  ver > nul
  set /p MAKE_PAGETITLE=should be generated a common image title [y ^| n]:
  if %ERRORLEVEL% NEQ 0         goto :ein5
  echo.
)
if /I %MAKE_PAGETITLE%==y (
  set MAKE_PAGETITLE=true
  goto :weiter2
) else if /I %MAKE_PAGETITLE%==n (
  set MAKE_PAGETITLE=false
  goto :weiter2
) else (
  goto :ein5
)

:weiter2
echo   common image title in the slideshow:   %MAKE_PAGETITLE%

if "%SENOTTO%"=="true" (
  echo   generate thumbnailshow for www.senotto.de
  goto :senotto
) else if "%SENOTTO%"=="false" (
  set SENOTTO_ROOT=false
  set SENOTTO_PARENT=false
  echo   generate standard thumbnailshow
  goto :weiter3
) else if "%SENOTTO%"=="" (
  :ein6
  ver > nul
  set /p SENOTTO=generate thumbnailshow for www.senotto.de [y, n]:
  if %ERRORLEVEL% NEQ 0     goto :ein6
  echo.
)
if "%SENOTTO%"=="" (
  goto :ein6
)
if /I %SENOTTO%==y (
  set SENOTTO=true
  echo   generate thumbnailshow for www.senotto.de
  goto :senotto
) else if /I %SENOTTO%==n (
  set SENOTTO=false
  echo   generate standard thumbnailshow
  goto :weiter3
) else (
  goto :ein6
)

:senotto
if "%SENOTTO_ROOT%"=="" (
  :ein7
  ver > nul
  set /p SENOTTO_ROOT=path to senotto root folder, p.e: "../../" :
  if %ERRORLEVEL% NEQ 0         goto :ein7
  echo.
)
if "%SENOTTO_ROOT%"==""         goto :ein7

echo   path to senotto root folder:           %SENOTTO_ROOT%

if "%SENOTTO_PARENT%"=="" (
  :ein8
  ver > nul
  set /p SENOTTO_PARENT=name of the senotto home page, default: "Bilder und Videos" :
  if %ERRORLEVEL% NEQ 0         goto :ein8
  echo.
)
if "%SENOTTO_PARENT%"==""       goto :ein8

echo   senotto home page:                     %SENOTTO_PARENT%

:weiter3

if "%THUMB_HEIGHT%"=="" (
  set THUMB_HEIGHT=100
)
if %THUMB_HEIGHT% LSS 50 (
  set THUMB_HEIGHT=50
) else if %THUMB_HEIGHT% GTR 200 (
  set THUMB_HEIGHT=200
)

echo   thumbnail height (px) :                %THUMB_HEIGHT%

rem evaluate slideshow parameters

if "%DOWNLOADBUT%"==""          set DOWNLOADBUT=true
if %DOWNLOADBUT% NEQ true       set DOWNLOADBUT=false

if "%PRINTBUT%"==""             set PRINTBUT=true
if %PRINTBUT% NEQ true          set PRINTBUT=false

if "%METABUT%"==""              set METABUT=true
if %METABUT% NEQ true           set METABUT=false

if "%GOOGLEMAPSBUT%"==""        set GOOGLEMAPSBUT=true
if %GOOGLEMAPSBUT% NEQ true     set GOOGLEMAPSBUT=false

if "%GOOGLEMAPSMAP%"==""        set GOOGLEMAPSMAP=hybrid

if "%GOOGLEMAPSKEY%"==""        set GOOGLEMAPSKEY=false

if "%EXITBUT%"==""              set EXITBUT=true
if %EXITBUT% NEQ true           set EXITBUT=false

if "%FULLSCREENBUT%"==""        set FULLSCREENBUT=true
if %FULLSCREENBUT% NEQ true     set FULLSCREENBUT=false

if "%HELPBUT%"==""              set HELPBUT=true
if %HELPBUT% NEQ true           set HELPBUT=false

if "%PLAYPAUSEBUT%"==""         set PLAYPAUSEBUT=true
if %PLAYPAUSEBUT% NEQ true      set PLAYPAUSEBUT=false

if "%PLAYMODUS%"==""            set PLAYMODUS=3
if %PLAYMODUS% GTR 3            set PLAYMODUS=3

if "%WRAPAROUND%"==""           set WRAPAROUND=false
if %WRAPAROUND% NEQ true        set WRAPAROUND=false

if "%AUTOSPEED%"==""            set AUTOSPEED=3
if %AUTOSPEED% LSS 2            set AUTOSPEED=2

if "%TRANSITION%"==""           set TRANSITION=1
if %TRANSITION% GTR 3           set TRANSITION=3

if "%WAITPROCEED%"==""          set WAITPROCEED=1
if %WAITPROCEED% GTR 2          set WAITPROCEED=2
if %WAITPROCEED% LSS 0.2        set WAITPROCEED=0.2

if "%ADDTITLE%"==""             set ADDTITLE=false
if %ADDTITLE% EQU true (
  echo   metadata title:                        %TITEL_LI_1%  %TITEL_LI_2%      %TITEL_RE_1%  %TITEL_RE_2%
  if "%TITEL_LI_1%"==""           set TITEL_LI_1=false
  if "%TITEL_LI_2%"==""           set TITEL_LI_2=false
  if "%TITEL_RE_1%"==""           set TITEL_RE_1=false
  if "%TITEL_RE_2%"==""           set TITEL_RE_2=false
) else (
  echo   no metadata title
  set ADDTITLE=false
)

if "%ADDCAPTION%"==""           set ADDCAPTION=false
if %ADDCAPTION% EQU true (
  echo   metadata caption:                      %CAPTION_LI_1%  %CAPTION_LI_2%      %CAPTION_RE_1%  %CAPTION_RE_2%
  if "%CAPTION_LI_1%"==""         set CAPTION_LI_1=false
  if "%CAPTION_LI_2%"==""         set CAPTION_LI_2=false
  if "%CAPTION_RE_1%"==""         set CAPTION_RE_1=false
  if "%CAPTION_RE_2%"==""         set CAPTION_RE_2=false
) else (
  echo   no metadata caption
  set ADDCAPTION=false
  if %ADDTITLE% EQU false (
    if %METABUT% EQU false (
      set GOOGLEMAPSBUT=false
      set GOOGLEMAPSKEY=false
      echo   don't read the image metadata !
    )
  )
)

echo.
echo   =====^>    please evaluate these parameters    ^<=====
echo.
pause

echo.
echo generate the thumbnailshow . . . . .
echo.

echo ^<?xml version="1.0" encoding="UTF-8"?^> > %FILE1%
echo ^<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"^> >> %FILE1%
echo ^<!-- >> %FILE1%
echo    *  this file was generated by "makeSlideShow%SIMPLE%.bat" on %DATE% >> %FILE1%
echo    *  feel free to modify for finetuning >> %FILE1%
echo    *  but before look at the settings in "slideShowParams.bat" >> %FILE1%
echo --^> >> %FILE1%
echo ^<html xmlns="https://www.w3.org/1999/xhtml"^> >> %FILE1%
echo   ^<head^> >> %FILE1%
echo     ^<meta charset="utf-8" /^> >> %FILE1%
echo     ^<!-- >> %FILE1%
echo       *  T h u m b n a i l s h o w >> %FILE1%
echo       * >> %FILE1%
echo       *  to be used together with the responsive Slideshow: %FILE2% >> %FILE1%
echo       * >> %FILE1%
echo       *  peter@danninger.eu                 %VERSION% >> %FILE1%
echo     --^> >> %FILE1%
echo     ^<title^>%TITEL%^</title^> >> %FILE1%
echo     ^<meta name="description" content="%TITEL%" lang="de" /^> >> %FILE1%
echo     ^<meta http-equiv="content-type" content="text/html; charset=utf-8" /^> >> %FILE1%
echo     ^<meta http-equiv="content-language" content="de" /^> >> %FILE1%
echo     ^<meta http-equiv="cache-control" content="no-cache" /^> >> %FILE1%
echo     ^<meta http-equiv="pragma" content="no-cache" /^> >> %FILE1%
echo     ^<meta http-equiv="expires" content="0" /^> >> %FILE1%
echo     ^<meta name="robots" content="index,follow" /^> >> %FILE1%
echo     ^<meta name="viewport" content="width=device-width, initial-scale=1" /^> >> %FILE1%
echo     ^<meta name="keywords" content="%TITEL%, Responsive, Web Galerie, Thumbnailshow, Slideshow, Titel, Caption, EXIF, IPTC, XMP, Metadaten, HTML5, CSS3" lang="de" /^> >> %FILE1%
echo     ^<meta name="DC.Title" content="%TITEL%" /^> >> %FILE1%
echo     ^<meta name="DC.Subject" content="%TITEL%" /^> >> %FILE1%
echo     ^<meta name="DC.Description" content="%TITEL%" /^> >> %FILE1%
echo     ^<meta name="DC.Date" content="%DATE%" /^> >> %FILE1%
echo     ^<meta name="DC.Type" content="Text" /^> >> %FILE1%
echo     ^<meta name="DC.Format" content="text/html" /^> >> %FILE1%
echo     ^<meta name="DC.Identifier" content="%AUTHOR%" /^> >> %FILE1%
echo     ^<meta name="DC.Source" content="%TITEL%" /^> >> %FILE1%
echo     ^<meta name="DC.Language" content="de" /^> >> %FILE1%
if /I %SENOTTO%==true (
  echo     ^<link rel="stylesheet" type="text/css" href="%SENOTTO_ROOT%Impressum/resize.css"^> >> %FILE1%
  echo     ^<script type="text/javascript" src="%SENOTTO_ROOT%Impressum/browser.js"^>^</script^> >> %FILE1%
  echo     ^<script type="text/javascript" src="%SENOTTO_ROOT%Impressum/resize.js"^>^</script^> >> %FILE1%
)
echo     ^<link rel="stylesheet" type="text/css" href="%SCRIPTSDIR%css/thumbshow.css" /^>      ^<!-- evtl. modify path --^> >> %FILE1%

if %SCROLLANZ% NEQ false (
  echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/thumbshow.js"^>^</script^>          ^<!-- evtl. modify path --^> >> %FILE1%
  echo     ^<script type="text/javascript"^> >> %FILE1%
  echo       var opts = {                       // the thumbshow options >> %FILE1%
  echo         iconDir: "%SCRIPTSDIR%icons/",  // directory with the icons >> %FILE1%
  echo         thumbDir: "%THUMBNAILS%/",         // directory with the thumbnails >> %FILE1%
  echo         slideShow: "%FILE2%",     // slideshow file >> %FILE1%
  echo         imageNam: "%BILDNAME%",     // name of images without 3 digit sequence at the end >> %FILE1%
  echo         imageNum: %BILDANZ%,                   // number of images >> %FILE1%
  echo         thumbHeight: %THUMB_HEIGHT%,                // thumbnail height >> %FILE1%
  echo         thumbClass: "thumbnail",         // className of thumbnails >> %FILE1%
  echo         scrollDIV: "thumbs"              // ID of scrolling DIV >> %FILE1%
  echo       } >> %FILE1%
  echo       function _scroll ^(^) { >> %FILE1%
  if /I %SENOTTO%==false (
    echo         if ^(window.opener == null^) {      // remove exit icon if there is one >> %FILE1%
    echo           var exi = document.getElementById ^("exit"^); >> %FILE1%
    echo           if ^(exi != null^)                exi.parentNode.removeChild ^(exi^); >> %FILE1%
    echo         } >> %FILE1%
  )
  echo         thumbShow.scrollPos ^(opts^); >> %FILE1%
  echo       } >> %FILE1%
  echo     ^</script^> >> %FILE1%
) else (
  if /I %SENOTTO%==false (
    echo     ^<script type="text/javascript"^> >> %FILE1%
    echo       function _openertest ^(^) { >> %FILE1%
    echo         if ^(window.opener == null^) {      // remove exit icon if there is one >> %FILE1%
    echo           var exi = document.getElementById ^("exit"^); >> %FILE1%
    echo           if ^(exi != null^)                exi.parentNode.removeChild ^(exi^); >> %FILE1%
    echo         } >> %FILE1%
    echo       } >> %FILE1%
    echo     ^</script^> >> %FILE1%
  )
)

echo   ^</head^> >> %FILE1%
rem TAB leer !!!
set TAB=
if /I %SENOTTO%==true (
  if %SCROLLANZ% NEQ false (
    echo   ^<body onload="resize.ResizeFont(1);_scroll()" onresize="resize.ResizeFont(1);_scroll()"^> >> %FILE1%
  ) else (
    echo   ^<body onload="resize.ResizeFont(1)" onresize="resize.ResizeFont(1)"^> >> %FILE1%
  )
  rem TAB 2 Spaces !!!
  set TAB=
  echo     ^<div class="navi"^> >> %FILE1%
  echo       ^<a href="Javascript:parent.location.replace(resize.getParentURL())"^>%SENOTTO_PARENT%^</a^> ^&raquo; >> %FILE1%
  echo       %TITEL% >> %FILE1%
  echo       ^<span class="bookmark"^>^<a href="Javascript:location.replace(resize.getBookmark())"^>Lesezeichen^</a^>^</span^> >> %FILE1%
  echo     ^</div^> >> %FILE1%
  echo     ^<div class="disp"^> >> %FILE1%
) else (
  if %SCROLLANZ% NEQ false (
    echo   ^<body onload="_scroll()" onresize="_scroll()"^> >> %FILE1%
  ) else (
    echo   ^<body onload="_openertest()"^> >> %FILE1%
  )
)
echo     %TAB%^<h2^> >> %FILE1%
echo       %TAB%%TITEL% >> %FILE1%
if /I %SENOTTO%==false (
  echo       %TAB%^<!-- Exit Icon depending from window.opener test --^> >> %FILE1%
  echo       %TAB%^<img id="exit" src="%SCRIPTSDIR%icons/exit.png" onclick="window.close()"^> >> %FILE1%
)
echo     %TAB%^</h2^> >> %FILE1%

if "%THUMB_TEXT%" NEQ ""      echo     %TAB%^<p^>%THUMB_TEXT%^</p^> >> %FILE1%

echo     %TAB%^<div id="thumbs"^> >> %FILE1%
if %SCROLLANZ% NEQ false (
  echo     %TAB%  ^<!-- Thumbnails are loaded depending on the scrollbar --^> >> %FILE1%
) else (
  for /L %%G in (001,1,%BILDANZ%) do (
    if %%G LSS 10 (
      echo       %TAB%^<a href="%FILE2%?%STARTNR%=00%%G" target="_blank"^>^<img class="thumbnail" src="%THUMBNAILS%/%BILDNAME%00%%G.jpg" height="%THUMB_HEIGHT%"^>^</a^> >> %FILE1%
    ) else if %%G LSS 100 (
      echo       %TAB%^<a href="%FILE2%?%STARTNR%=0%%G" target="_blank"^>^<img class="thumbnail" src="%THUMBNAILS%/%BILDNAME%0%%G.jpg" height="%THUMB_HEIGHT%"^>^</a^> >> %FILE1%
    ) else (
      echo       %TAB%^<a href="%FILE2%?%STARTNR%=%%G" target="_blank"^>^<img class="thumbnail" src="%THUMBNAILS%/%BILDNAME%%%G.jpg" height="%THUMB_HEIGHT%"^>^</a^> >> %FILE1%
    )
  )
  echo       %TAB%^<br^> >> %FILE1%
)
echo     %TAB%^</div^> >> %FILE1%

if %SCROLLANZ% NEQ false (
  echo     %TAB%^<span id="version"^> ^</span^>^<br^> >> %FILE1%
)
echo     %TAB%^<a href="%SCRIPTSDIR%help/help.html"^>About this web gallery^</a^> >> %FILE1%
echo     %TAB%^<br^> ^<br^> >> %FILE1%

if /I %SENOTTO%==true (
  echo     ^</div^> >> %FILE1%
)
echo   ^</body^> >> %FILE1%
echo ^</html^> >> %FILE1%

echo generate the slideshow . . . . .
echo.

echo ^<?xml version="1.0" encoding="UTF-8"?^> > %FILE2%
echo ^<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"^> >> %FILE2%
echo ^<!-- >> %FILE2%
echo    *  this file was generated by "makeSlideShow%SIMPLE%.bat" on %DATE% >> %FILE2%
echo    *  feel free to modify for finetuning >> %FILE2%
echo    *  but before look at the settings in "slideShowParams.bat" >> %FILE2%
echo    *   >> %FILE2%
echo    *  local tests may cause problems like "cross-origin-request-error" >> %FILE2%
echo    *  best for local tests is "Firefox" >> %FILE2%
echo --^> >> %FILE2%
echo ^<html xmlns="https://www.w3.org/1999/xhtml"^> >> %FILE2%
echo   ^<head^> >> %FILE2%
echo     ^<meta charset="utf-8" /^> >> %FILE2%
echo     ^<!-- >> %FILE2%
echo       *  S l i d e s h o w >> %FILE2%
echo       * >> %FILE2%
echo       *  Made with HTML5, CSS3, and Vanilla JavaScript >> %FILE2%
echo       * >> %FILE2%
echo       *  Idea from:           https://github.com/leemark/better-simple-slideshow   (*) >> %FILE2%
echo       *  Swipe-Support from:  https://hammerjs.github.io/api/                      (**) >> %FILE2%
echo       *  Symbol-Icons from:   https://fortawesome.github.io/Font-Awesome/icons/    (**) >> %FILE2%
echo       *  EXIF-metadata from:  https://github.com/exif-js/exif-js                   (*) >> %FILE2%
echo       * >> %FILE2%
echo       *  (*)  substantially modified and extended >> %FILE2%
echo       *  (**) unmodified >> %FILE2%
echo       * >> %FILE2%
echo       *  Modifications and extensions by:       peter@danninger.eu        %VERSION% >> %FILE2%
echo     --^> >> %FILE2%
echo     ^<title^>%TITEL%^</title^> >> %FILE2%
echo     ^<meta name="description" content="%TITEL%" lang="de" /^> >> %FILE2%
echo     ^<meta http-equiv="content-type" content="text/html; charset=utf-8" /^> >> %FILE2%
echo     ^<meta http-equiv="content-language" content="de" /^> >> %FILE2%
echo     ^<meta http-equiv="cache-control" content="no-cache" /^> >> %FILE2%
echo     ^<meta http-equiv="pragma" content="no-cache" /^> >> %FILE2%
echo     ^<meta http-equiv="expires" content="0" /^> >> %FILE2%
echo     ^<meta name="robots" content="index,follow" /^> >> %FILE2%
echo     ^<meta name="viewport" content="width=device-width, initial-scale=1" /^> >> %FILE2%
echo     ^<meta name="keywords" content="%TITEL%, Responsive, Web Galerie, Thumbnailshow, Slideshow, Titel, Caption, EXIF, IPTC, XMP, Metadaten, HTML5, CSS3" lang="de" /^> >> %FILE2%
echo     ^<meta name="DC.Title" content="%TITEL%" /^> >> %FILE2%
echo     ^<meta name="DC.Subject" content="%TITEL%" /^> >> %FILE2%
echo     ^<meta name="DC.Description" content="%TITEL%" /^> >> %FILE2%
echo     ^<meta name="DC.Date" content="%DATE%" /^> >> %FILE2%
echo     ^<meta name="DC.Type" content="Text" /^> >> %FILE2%
echo     ^<meta name="DC.Format" content="text/html" /^> >> %FILE2%
echo     ^<meta name="DC.Identifier" content="%AUTHOR%" /^> >> %FILE2%
echo     ^<meta name="DC.Source" content="%TITEL%" /^> >> %FILE2%
echo     ^<meta name="DC.Language" content="de" /^> >> %FILE2%
echo     ^<link rel="stylesheet" type="text/css" href="%SCRIPTSDIR%css/font-awesome.css" /^>   ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<link rel="stylesheet" type="text/css" href="%SCRIPTSDIR%css/slideshow.css" /^>      ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/strings.js"^>^</script^>            ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/exif.js"^>^</script^>               ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/metatags.js"^>^</script^>           ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/hammer.js"^>^</script^>             ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript" src="%SCRIPTSDIR%js/slideshow.js"^>^</script^>          ^<!-- evtl. modify path --^> >> %FILE2%
echo     ^<script type="text/javascript"^> >> %FILE2%
echo       var opts = {                    // ----------------- the slideshow options (evtl. modify)---------------------- >> %FILE2%
echo         scriptDir: "%SCRIPTSDIR%",              // path to script directory, p.e. "./" or "../slideShow/" >> %FILE2%
if %ORIPICDIR% NEQ false (
  echo         oriPicDir: "%ORIPICDIR%/",        // directory with the pics in original size for download >> %FILE2%
) else (
  echo         oriPicDir: false,             // directory with the pics in original size for download >> %FILE2%
)
echo         picDir: "%SLIDES%/",            // directory with the slides >> %FILE2%
echo         thumbDir: "%THUMBNAILS%/",      // directory with the thumbnails >> %FILE2%
echo         enlarge: %ENLARGE%,                // enlarge slides on big displays >> %FILE2%
echo         startNr: 0,                   // start slideshow with image nr. >> %FILE2%
echo         playPauseBut: %PLAYPAUSEBUT%,           // show play/pause button >> %FILE2%
echo         speed: %AUTOSPEED%,                     // auto play slides at seconds, minimum 2 seconds >> %FILE2%
echo         playMod: %PLAYMODUS%,                   // 0: forward, 1: backward, 2: random, 3: askMe >> %FILE2%
echo         wrapAround: %WRAPAROUND%,            // allow wrap-around on the show-limits >> %FILE2%
echo         transition: %TRANSITION%,                // opacity transition time in seconds, 0 or false is off, max. 5 >> %FILE2%
echo         waitProceed: %WAITPROCEED%,             // waiting time for proceeding manually, 0.2 - 2 sec >> %FILE2%
if %ADDTITLE% EQU false (
  echo         addTitle: false,              // false: no image title above the image, evtl. pageTitle instead >> %FILE2%
) else (
  echo         addTitle: {                   // add ^<div class="%FIGTITLED%"^> with image title above the image >> %FILE2%
  echo           TitLeft1: "%TITEL_LI_1%",          //   one of these image meta-tags [*]: >> %FILE2%
  echo           TitLeft2: "%TITEL_LI_2%",          //       title, headline, desc, rights, date, make, model, artist, focalLen, fNumber, >> %FILE2%
  echo           TitRight1: "%TITEL_RE_1%",         //       subjDist, expTime, expBias, ISOSpeed, pixelX, pixelY, latGrad, lonGrad, ele, >> %FILE2%
  echo           TitRight2: "%TITEL_RE_2%"          //       country, province, city, rating, label, exifVers, creaTool, userComment >> %FILE2%
  echo         },                            //   or special case: name: ^<img alt= attribut or src= attribut, only filename >> %FILE2%
)
if %ADDCAPTION% EQU false (
  echo         addCaption: false,            // false: use ^<figcaption^> in ^<figure^> >> %FILE2%
) else (
  echo         addCaption: {                 // add ^<figcaption^> below the image: >> %FILE2%
  echo           CapLeft1: "%CAPTION_LI_1%",           //    same tags as addTitle >> %FILE2%
  echo           CapLeft2: "%CAPTION_LI_2%",          // >> %FILE2%
  echo           CapRight1: "%CAPTION_RE_1%",          // [*] tested with Adobe Lightroom images  >> %FILE2%
  echo           CapRight2: "%CAPTION_RE_2%"          // [*] local test not possible with some browsers because of "cross-side-scripting-error"  >> %FILE2%
  echo         },                            //  >> %FILE2%
)
echo         swipe: true,                  // support swiping on touch devices, requires hammer.js >> %FILE2%
echo         downloadBut: %DOWNLOADBUT%,            // show download button >> %FILE2%
echo         printBut: %PRINTBUT%,               // show print button >> %FILE2%
echo         fullScreenBut: %FULLSCREENBUT%,          // show fullscreen button >> %FILE2%
echo         exitBut: %EXITBUT%,                // show exit button >> %FILE2%
echo         exitURL: "",                  // exit URL with "window.location.replace (exitURL)", else with "window.close ()" >> %FILE2%
echo         metaDataBut: %METABUT%,            // show metadata button >> %FILE2%
echo         googleMapsBut: %GOOGLEMAPSBUT%,          // show GoogleMaps button  >> %FILE2%
echo         googleMapsMap: "%GOOGLEMAPSMAP%",      // GoogleMaps maptype  >> %FILE2%
echo         googleMapsKey: %GOOGLEMAPSKEY%,  // GoogleStaticMaps key  >> %FILE2%
echo         helpBut: %HELPBUT%                 // show help button >> %FILE2%
echo       }; >> %FILE2%
echo       var classNam = {                // ----------------- the class names (also in slideshow.css !!!) -------------- >> %FILE2%
echo         mainDiv: "%SLIDESHOWD%",         // class of main div, mainly for fullscreen mode >> %FILE2%
echo         slidesDiv: "%SLIDESD%",          // class of slides div >> %FILE2%
echo         pageTitle: "%PAGETITLED%",       // class of otional page title >> %FILE2%
echo         figTitle: "%FIGTITLED%",         // class of otional picture title >> %FILE2%
echo         helpMeta: "%HELP_METAD%"          // class of otional picture title >> %FILE2%
echo        }; >> %FILE2%
echo       function _show () { >> %FILE2%
echo         var p = "%STARTNR%=";           // evtl. start show with image nr., p.e. "%FILE2%?%STARTNR%=5" >> %FILE2%
echo         var nr = 0; >> %FILE2%
echo         var s = location.search; >> %FILE2%
echo         var i = s.indexOf (p); >> %FILE2%
echo         if (i ^>= 0) { >> %FILE2%
echo           s = s.substring (i + p.length); >> %FILE2%
echo           nr = parseInt (s); >> %FILE2%
echo           if (isNaN (nr))     nr = 0; >> %FILE2%
echo           if (nr ^> 0)         --nr; >> %FILE2%
echo         } >> %FILE2%
echo         opts.startNr = nr; >> %FILE2%
echo         slideShow.makeShow (classNam, opts); >> %FILE2%
echo       } >> %FILE2%
echo       function _resize () { >> %FILE2%
echo         slideShow.resizeShow (classNam, true); >> %FILE2%
echo       } >> %FILE2%
echo     ^</script^> >> %FILE2%
echo   ^</head^> >> %FILE2%
echo   ^<body onload="_show()" onresize="_resize()"^> >> %FILE2%
echo     ^<div class="%SLIDESHOWD%"^> >> %FILE2%
if /I %MAKE_PAGETITLE%==true (
  echo       ^<p class="%PAGETITLED%"^>              ^<!-- optional --^> >> %FILE2%
  echo         %TITEL% >> %FILE2%
rem   echo         ^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp;^&nbsp; >> %FILE2%
rem   echo         ^<a href="mailto:%EMAIL%"^>%EMAIL%^</a^> >> %FILE2%
  echo       ^</p^> >> %FILE2%
)
echo       ^<div class="%SLIDESD%"^> >> %FILE2%

echo         ^<!-- we use alt to prevent that browsers try to preload all the images --^> >> %FILE2%
if %EMPTYCAPTION%==false (
  if %EMPTYTITLE%==false (
    for /L %%G in (001,1,%BILDANZ%) do (
      if %%G LSS 10 (
        echo         ^<figure^>^<img alt="%BILDNAME%00%%G.jpg" /^>^</figure^> >> %FILE2%
      ) else if %%G LSS 100 (
        echo         ^<figure^>^<img alt="%BILDNAME%0%%G.jpg" /^>^</figure^> >> %FILE2%
      ) else (
        echo         ^<figure^>^<img alt="%BILDNAME%%%G.jpg" /^>^</figure^> >> %FILE2%
      )
    )
    goto :noempty
  )
)

for /L %%G in (001,1,%BILDANZ%) do (
  echo         ^<figure^> >> %FILE2%
  if %EMPTYTITLE%==true (
    echo           ^<div class="%FIGTITLED%"^>edit title^</div^>           ^<!-- your title text --^> >> %FILE2%
  )
  if %%G LSS 10 (
    echo           ^<img alt="%BILDNAME%00%%G.jpg" /^> >> %FILE2%
  ) else if %%G LSS 100 (
    echo           ^<img alt="%BILDNAME%0%%G.jpg" /^>^ >> %FILE2%
  ) else (
    echo           ^<img alt="%BILDNAME%%%G.jpg" /^>^ >> %FILE2%
  )
  if %EMPTYCAPTION%==true (
    echo           ^<figcaption^>edit caption^</figcaption^>            ^<!-- your caption text --^> >> %FILE2%
  )
  echo         ^</figure^> >> %FILE2%
)

:noempty

echo       ^</div^> ^<!-- end of %SLIDESD% --^> >> %FILE2%
echo       ^<div class="%HELP_METAD%"^>^</div^> >> %FILE2%
echo     ^</div^> ^<!-- end of %SLIDESHOWD% --^> >> %FILE2%
echo   ^</body^> >> %FILE2%
echo ^</html^> >> %FILE2%

color 0A
echo evaluate and evtl. tune following files:
echo.
echo     %FILE1%: thumbnailshow
echo.
echo     %FILE2%: tlideshow
echo.
pause

rem ENDE
