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 >
Wrap
Text File
|
2007-09-06
|
5KB
|
204 lines
LoadLib("flvdll.dll");
function geturl(args)
{
var geturl = newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
return geturl;
}
function setupodfile()
{
if(newtask.newtaskpanelinfo.checkrename.GetCheck())
{
newtask.newtaskpanelinfo.newtaskfilename.SetText("");
newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
newtask.newtaskpanelinfo.rename.SetEnable(false);
}
else
{
newtask.newtaskpanelinfo.newtaskfilename.SetEnable(true);
newtask.newtaskpanelinfo.newtaskfilename.SetEnable(true);
newtask.newtaskpanelinfo.rename.SetEnable(true);
}
return;
}
function setnewtaskfilename()
{
if(newtask.newtaskpanelinfo.checkrename.GetCheck())
{
newtask.newtaskpanelinfo.newtaskfilename.SetText("");
newtask.newtaskpanelinfo.newtaskfilename.SetEnable(false);
}else
{
var geturl=newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
setfilename(geturl);
}
//newtask.newtaskpanelinfo.newtaskfilename.SetText(geturl);
}
function setfilename(filename)
{
//http://www.youtube.com/watch?v=Ee_8IMx0uMo
var first=filename.lastIndexOf("=");
if(first==-1)
{
first=filename.lastIndexOf("\\")+1;
var end=filename.lastIndexOf(".");
newtask.newtaskpanelinfo.newtaskfilename.SetText(filename.substring(first,end));
}
else
{
newtask.newtaskpanelinfo.newtaskfilename.SetText(getsuburl(filename));
}
}
var pathdlg = new JSPathDialog();
pathdlg.SetDirBkColor(236,235,241);
function getnewtaskpath(args)
{
var path = pathdlg.ShowDirDialog(GetDefaultOutputFolder());
// ???
if (path!="")
newtask.newtaskpanelinfo.newtasksaveto.SetText(path);
}
function getpath()
{
if(path.length<5)
filepath = path;
else
var filepath = path + "\\";
return filepath;
}
function getcomboxtext(args)
{
var index=newtask.newtaskpanelinfo.combox.GetCurSel();
var comboxtext=newtask.newtaskpanelinfo.combox.GetString(index);
return comboxtext;
}
var string1="";
function getsubstring(str,indexstart,indexend)
{
return str.substring(indexstart,indexend);
}
function setdefaultpath()
{
var targetpath=newtask.newtaskpanelinfo.newtasksaveto.GetText();
if(targetpath=="")
{
newtask.ShowMessageBox(LanguageStr("_invalid_path"), GetProductName(), 1);
return 1;
}
if(targetpath!="")
{
path = targetpath;
defaultpath = targetpath;
cfgSetString("general", "defaultfolder", defaultpath);
if(newtask.newtaskpanelinfo.checkrename.GetCheck())
cfgSetInt("general","rename",1);
else
cfgSetInt("general","rename",0);
GetDefaultOutputFolder();
}
}
function newtaskok(args)
{
if(newtask.newtaskpanelinfo.newtaskurlvalue.GetText()=="")
{
newtask.ShowMessageBox(LanguageStr("_newtask_msg_urlempty"), GetProductName(), 1);
return 1;
}
if(newtask.newtaskpanelinfo.newtaskfilename.GetText()==""&&newtask.newtaskpanelinfo.checkrename.GetCheck()==false)
{
newtask.ShowMessageBox(LanguageStr("_newtask_msg_nofilename"),GetProductName() , 1);
return 1;
}
var filename=newtask.newtaskpanelinfo.newtaskurlvalue.GetText();
var file1="http://www.youtube.com/watch?v=";
var file2="http://youtube.com/watch?v=";
if(filename.substr(0,31)!=file1&&filename.substr(0,27)!=file2)
{
newtask.ShowMessageBox(LanguageStr("_invalid_file_path"),GetProductName(),1);
return 1;
}
var targetpath=newtask.newtaskpanelinfo.newtasksaveto.GetText();
if(targetpath=="")
{
newtask.ShowMessageBox(LanguageStr("_newtask_msg_temploc_notvalid"),GetProductName(),1);
return ;
}
if (!g_upodutil.CreateDirectory(targetpath))
{
newtask.ShowMessageBox(LanguageStr("_newtask_msg_temploc_notvalid"), GetProductName(),1);
return ;
}
cfgSetString("general", "defaultfolder", targetpath);
var bjrename = 0;
if(!newtask.newtaskpanelinfo.checkrename.GetCheck())
bjrename = 1;
if(newtask.newtaskpanelinfo.newtaskfilename.GetText()=="")
{
var p2=getsuburl(geturl());
}
else
{
var p2=newtask.newtaskpanelinfo.newtaskfilename.GetText();
bjrename = 1;
}
var p3="unknown";
var p4="0";
var p6=newtask.newtaskpanelinfo.newtasksaveto.GetText();
if(p6.length>4)
p6=p6+"\\";
newtask.Close();
MainWindow.listctrlfiles.height=332;
MainWindow.pel.height=0;
Addtolistctrl(p2, p3, p4, p6, 0, 0, 0, "", "", geturl(), bjrename);
newtask.newtaskpanelinfo.newtaskfilename.SetText("");
b_newtaskok=1;
}
function newtaskcancel(args)
{
newtask.Close();
b_newtaskok=0;
}