home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / temacd / zps / zps7_cz_trial.exe / plain.ZHT / main.js < prev    next >
Encoding:
Text File  |  2004-09-21  |  3.0 KB  |  109 lines

  1. function GeneratePreview(cSourcePath, cDestPath, cID)
  2. {
  3.   //MessageBox("cSourcePath = " + cSourcePath + "\ncDestPath = " + cDestPath + "\ncID = " + cID, "Preview", MB_OK);
  4. }
  5.  
  6. function GetImagePageFileName(iImg) {
  7.   return "img" + IntToStr(iImg, 5) + ".htm";
  8. }
  9.  
  10. function GenerateAlbum(cSourcePath, cDestPath)
  11. {
  12.   var iFilesCount = lSelectedFiles.GetCount();
  13.   var iRows = Math.ceil(iFilesCount/iCols);
  14.  
  15.   var tAlbum = new CTemplate();
  16.   tAlbum.Load(cSourcePath + "album.tpl", 0);
  17.  
  18.   tAlbum.SetReplace("${TITLE}", cTitle);
  19.   tAlbum.SetReplace("${BGCOLOR}", iBgColor);
  20.   tAlbum.SetReplace("${FOOTER}", ReplaceExifStrings(cFooter, "", ""));
  21.   tAlbum.SetReplace("${ALBUM_NAME}", cAlbumName);
  22.   tAlbum.SetReplace("${FONT_SIZE}", cFontSize);
  23.  
  24.   var tRow = new CTemplate();
  25.   tRow.Load(cSourcePath + "row.tpl", 0);
  26.  
  27.   var tCol = new CTemplate();
  28.   tCol.Load(cSourcePath + "col.tpl", 0);
  29.  
  30.   var cRows = "";
  31.   var cCols = "";
  32.  
  33.   var iMaxWidth = 0;
  34.  
  35.   var iImgs = 1;
  36.   for (var iRow = 0; iRow < iRows; iRow++) {
  37.     cCols = "";
  38.     for (var iCol = 0; iCol < iCols; iCol++) {
  39.         if (iImgs <= iFilesCount) {
  40.         cFileName = lSelectedFiles.GetAt(iImgs-1);
  41.         if (bUseOriginalFileNames)
  42.         {
  43.           cGetFileName = GetFileName(cFileName);
  44.  
  45.           cTNFileName = "tn_" + cGetFileName + ".jpg";
  46.           cImgFileName = cGetFileName + "." + GetFileExt(cFileName);
  47.         }
  48.         else
  49.         {
  50.           cNumFileName = IntToStr(iImgs, 5);
  51.  
  52.           cTNFileName = "tn" + cNumFileName + ".jpg";
  53.           cImgFileName = "img" + cNumFileName + "." + GetFileExt(cFileName).toLowerCase();
  54.         }
  55.  
  56.         var pImg = new CImage();
  57.         pImg.Load(cFileName, 0);
  58.  
  59. //        if (pImg.GetImageFormat() != JPGformat) {
  60. //          pImg.SaveAs(cDestPath + cImgFileName, JPGformat, 80, 0);
  61. //        } else {
  62.           CopyFile(cFileName, cDestPath + cImgFileName, FIL_OM_OVERWRITE);
  63. //        }
  64.  
  65.         pImg.Resize(iTNWidth, iTNHeight, GFX_KEEP_ASPECT | GFX_INTERPOLATE);
  66.         pImg.SaveAs(cDestPath + cTNFileName, JPGformat, iTNJPEG, 0);
  67.  
  68.         tCol.SetReplace("${IMG_FILENAME}", cImgFileName);
  69.         tCol.SetReplace("${TN_FILENAME}", cTNFileName);
  70.         tCol.SetReplace("${TN_WIDTH}", pImg.GetWidth());
  71.         tCol.SetReplace("${TN_HEIGHT}", pImg.GetHeight());
  72.  
  73.         cCols += tCol.Replace();
  74.  
  75.         if (pImg.GetWidth() > iMaxWidth) {
  76.           iMaxWidth = pImg.GetWidth();
  77.         }
  78.  
  79.         pImg.Close();
  80.  
  81.       } else {
  82.         cCols += "<td></td>";
  83.       }
  84.  
  85.       iImgs++;
  86.     }   
  87.  
  88.     tRow.SetReplace("${COLS}", cCols);
  89.     cRows += tRow.Replace();
  90.  
  91.   }
  92.  
  93.   cCols = "";
  94.   for (var iCol = 0; iCol < iCols; iCol++) {
  95.     cCols += "<td width=\""+iMaxWidth+"\"></td>";
  96.   }
  97.   tRow.SetReplace("${COLS}", cCols+"\n");
  98.   cRows += tRow.Replace();
  99.  
  100.   tAlbum.SetReplace("${ROWS}", cRows);
  101.  
  102.   SaveString(cDestPath + "index.htm", tAlbum.Replace(), 0);
  103.  
  104.   return cDestPath + "index.htm";
  105.   
  106. }
  107.  
  108. INIT_OK;
  109.