home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 November / PCWorld_2007-11_cd.bin / temacd / imtoodownyoutube / download-youtube-video.exe / script / newtask.js < prev    next >
Text File  |  2007-09-06  |  5KB  |  204 lines

  1. LoadLib("flvdll.dll");
  2.  
  3. function geturl(args)
  4. {
  5.     var geturl = newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
  6.     return geturl;
  7. }
  8.  
  9.  
  10. function setupodfile()
  11. {
  12.     if(newtask.newtaskpanelinfo.checkrename.GetCheck())
  13.     { 
  14.         newtask.newtaskpanelinfo.newtaskfilename.SetText("");
  15.         newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
  16.         newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
  17.         newtask.newtaskpanelinfo.rename.SetEnable(false);
  18.         
  19.     }
  20.     else
  21.     {
  22.         newtask.newtaskpanelinfo.newtaskfilename.SetEnable(true);    
  23.         newtask.newtaskpanelinfo.newtaskfilename.SetEnable(true);
  24.         newtask.newtaskpanelinfo.rename.SetEnable(true);
  25.     }
  26.     return;
  27.     
  28. }
  29.  
  30.  
  31. function setnewtaskfilename()
  32. {
  33.     if(newtask.newtaskpanelinfo.checkrename.GetCheck())
  34.     {
  35.         newtask.newtaskpanelinfo.newtaskfilename.SetText("");
  36.         newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
  37.     }else
  38.     {
  39.         var geturl=newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
  40.         setfilename(geturl);
  41.     }
  42.     //newtask.newtaskpanelinfo.newtaskfilename.SetText(geturl);
  43. }
  44.  
  45. function setfilename(filename)
  46. {
  47.     //http://www.youtube.com/watch?v=Ee_8IMx0uMo
  48.     var first=filename.lastIndexOf("=");
  49.     if(first==-1)
  50.     {
  51.         first=filename.lastIndexOf("\\")+1;
  52.         var end=filename.lastIndexOf(".");
  53.         newtask.newtaskpanelinfo.newtaskfilename.SetText(filename.substring(first,end));
  54.     }
  55.     else
  56.     {    
  57.         newtask.newtaskpanelinfo.newtaskfilename.SetText(getsuburl(filename));
  58.     }
  59. }
  60.  
  61.  
  62.  
  63. var pathdlg = new JSPathDialog();
  64. pathdlg.SetDirBkColor(236,235,241);
  65.  
  66. function getnewtaskpath(args)
  67. {
  68.     var path = pathdlg.ShowDirDialog(GetDefaultOutputFolder());
  69.     
  70.     //    ???
  71.     if (path!="")
  72.         newtask.newtaskpanelinfo.newtasksaveto.SetText(path);
  73. }
  74.  
  75. function getpath()
  76. {
  77.     if(path.length<5)
  78.         filepath = path;
  79.     else
  80.         var filepath = path + "\\";
  81.     
  82.     return  filepath;
  83. }
  84.  
  85. function getcomboxtext(args)
  86. {
  87.     var index=newtask.newtaskpanelinfo.combox.GetCurSel();
  88.     var comboxtext=newtask.newtaskpanelinfo.combox.GetString(index);
  89.     return comboxtext;
  90. }
  91.  
  92. var string1="";
  93. function getsubstring(str,indexstart,indexend)
  94. {
  95.     return str.substring(indexstart,indexend);
  96. }
  97.  
  98. function setdefaultpath()
  99. {
  100.     var targetpath=newtask.newtaskpanelinfo.newtasksaveto.GetText();
  101.     if(targetpath=="")
  102.     {
  103.          newtask.ShowMessageBox(LanguageStr("_invalid_path"), GetProductName(), 1);
  104.             return 1;
  105.     }
  106.  
  107.     if(targetpath!="")
  108.     {
  109.         path = targetpath;
  110.         defaultpath = targetpath;
  111.         cfgSetString("general", "defaultfolder", defaultpath);
  112.         if(newtask.newtaskpanelinfo.checkrename.GetCheck())
  113.         cfgSetInt("general","rename",1);
  114.         else
  115.         cfgSetInt("general","rename",0);
  116.  
  117.         GetDefaultOutputFolder();
  118.     }
  119. }
  120.  
  121. function newtaskok(args)
  122. {     
  123.     if(newtask.newtaskpanelinfo.newtaskurlvalue.GetText()=="")
  124.     {
  125.         newtask.ShowMessageBox(LanguageStr("_newtask_msg_urlempty"), GetProductName(), 1);    
  126.         return 1;
  127.     }
  128.  
  129.     if(newtask.newtaskpanelinfo.newtaskfilename.GetText()==""&&newtask.newtaskpanelinfo.checkrename.GetCheck()==false)
  130.     {
  131.         newtask.ShowMessageBox(LanguageStr("_newtask_msg_nofilename"),GetProductName() , 1);        
  132.         return 1;
  133.     }
  134.     
  135.     var filename=newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
  136.     
  137.     var file1="http://www.youtube.com/watch?v=";
  138.     var file2="http://youtube.com/watch?v=";
  139.     if(filename.substr(0,31)!=file1&&filename.substr(0,27)!=file2)
  140.     
  141.     {
  142.         newtask.ShowMessageBox(LanguageStr("_invalid_file_path"),GetProductName(),1);
  143.     
  144.                 return 1;
  145.     }
  146.    
  147.     
  148.         var targetpath=newtask.newtaskpanelinfo.newtasksaveto.GetText();
  149.         if(targetpath=="")
  150.         {
  151.             newtask.ShowMessageBox(LanguageStr("_newtask_msg_temploc_notvalid"),GetProductName(),1);
  152.                 return ;
  153.         }
  154.         
  155.         if (!g_upodutil.CreateDirectory(targetpath))
  156.         {
  157.             newtask.ShowMessageBox(LanguageStr("_newtask_msg_temploc_notvalid"), GetProductName(),1);
  158.                 return ;
  159.         }
  160.         cfgSetString("general", "defaultfolder", targetpath);
  161.  
  162.         var bjrename = 0;
  163.         if(!newtask.newtaskpanelinfo.checkrename.GetCheck())
  164.             bjrename = 1;
  165.  
  166.                 
  167.         if(newtask.newtaskpanelinfo.newtaskfilename.GetText()=="")
  168.         {
  169.             var p2=getsuburl(geturl());
  170.         }
  171.         else 
  172.         { 
  173.             var p2=newtask.newtaskpanelinfo.newtaskfilename.GetText();
  174.             bjrename = 1;
  175.         }
  176.     
  177.         
  178.         var p3="unknown";
  179.         var p4="0";
  180.     
  181.         
  182.         var p6=newtask.newtaskpanelinfo.newtasksaveto.GetText();
  183.         
  184.         if(p6.length>4)
  185.             p6=p6+"\\";
  186.             
  187.         newtask.Close();
  188.         MainWindow.listctrlfiles.height=332;
  189.         MainWindow.pel.height=0;
  190.     
  191.         
  192.         Addtolistctrl(p2, p3, p4, p6, 0, 0, 0, "", "", geturl(), bjrename);  
  193.     
  194.     
  195.     newtask.newtaskpanelinfo.newtaskfilename.SetText("");
  196.     b_newtaskok=1;
  197. }
  198.  
  199. function newtaskcancel(args)
  200. {
  201.     newtask.Close();
  202.     b_newtaskok=0;
  203. }
  204.