home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 January / PCWorld_2003-01_cd.bin / Software / Topware / zme / zme5-trcz.exe / plain.ZHT / main.js < prev    next >
Encoding:
Text File  |  2002-11-21  |  2.6 KB  |  97 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.         cTNFileName = "tn" + IntToStr(iImgs, 5) + ".jpg";
  42.         cImgFileName = "img" + IntToStr(iImgs, 5) + ".jpg";
  43.  
  44.         var pImg = new CImage();
  45.         pImg.Load(cFileName, 0);
  46.  
  47. //        if (pImg.GetImageFormat() != JPGformat) {
  48. //          pImg.SaveAs(cDestPath + cImgFileName, JPGformat, 80, 0);
  49. //        } else {
  50.           CopyFile(cFileName, cDestPath + cImgFileName, FIL_OM_OVERWRITE);
  51. //        }
  52.  
  53.         pImg.Resize(iTNWidth, iTNHeight, GFX_KEEP_ASPECT | GFX_INTERPOLATE);
  54.         pImg.SaveAs(cDestPath + cTNFileName, JPGformat, iTNJPEG, 0);
  55.  
  56.         tCol.SetReplace("${IMG_FILENAME}", cImgFileName);
  57.         tCol.SetReplace("${TN_FILENAME}", cTNFileName);
  58.         tCol.SetReplace("${TN_WIDTH}", pImg.GetWidth());
  59.         tCol.SetReplace("${TN_HEIGHT}", pImg.GetHeight());
  60.  
  61.         cCols += tCol.Replace();
  62.  
  63.         if (pImg.GetWidth() > iMaxWidth) {
  64.           iMaxWidth = pImg.GetWidth();
  65.         }
  66.  
  67.         pImg.Close();
  68.  
  69.       } else {
  70.         cCols += "<td></td>";
  71.       }
  72.  
  73.       iImgs++;
  74.     }   
  75.  
  76.     tRow.SetReplace("${COLS}", cCols);
  77.     cRows += tRow.Replace();
  78.  
  79.   }
  80.  
  81.   cCols = "";
  82.   for (var iCol = 0; iCol < iCols; iCol++) {
  83.     cCols += "<td width=\""+iMaxWidth+"\"></td>";
  84.   }
  85.   tRow.SetReplace("${COLS}", cCols+"\n");
  86.   cRows += tRow.Replace();
  87.  
  88.   tAlbum.SetReplace("${ROWS}", cRows);
  89.  
  90.   SaveString(cDestPath + "index.htm", tAlbum.Replace(), 0);
  91.  
  92.   return cDestPath + "index.htm";
  93.   
  94. }
  95.  
  96. INIT_OK;
  97.