local fwrite = function(s,f) s = s or "" local h,x = io.open(f,"wb") if h then x=h:write(s) io.close(h) end return x end local GetPage = function(x) local s0="" panel.GetUserScreen() s0=io.popen("curl.exe -k "..x,"rb"):read("*all") panel.SetUserScreen() return s0 end local F = far.Flags local guid = "0EEE33E2-1E95-4753-982C-B2BD1E63C3C4" local uGuid = win.Uuid(guid) local items = { --[[01]] {F.DI_DOUBLEBOX, 3,1, 37,6, 0, 0,0, 0, "Загрузить файл?"}, --[[02]] {F.DI_CHECKBOX, 5,2, 12,2, 0, 0,0, 0, "x86"}, --[[03]] {F.DI_CHECKBOX, 13,2, 20,2, 0, 0,0, 0, "x64"}, --[[04]] {F.DI_CHECKBOX, 22,2, 28,2, 0, 0,0, 0, "7z"}, --[[05]] {F.DI_CHECKBOX, 29,2, 36,2, 0, 0,0, 0, "msi"}, --[[06]] {F.DI_COMBOBOX, 5,3, 35,3,{}, 0,0, 0, ""}, --[[07]] {F.DI_TEXT, -1,4, 0,0, 0, 0,0, F.DIF_SEPARATOR,""}, --[[08]] {F.DI_BUTTON, 0,5, 0,0, 0, 0,0, F.DIF_DEFAULTBUTTON+F.DIF_CENTERGROUP,"&Ok"}, --[[09]] {F.DI_BUTTON, 0,5, 0,0, 0, 0,0, F.DIF_CENTERGROUP,"Ca&ncel"} } local tmp=win.GetEnv("TEMP").."\\" local box,flist,RealPos,fname = {true,false,true,false},{},1 local DlgProc=function(hDlg,Msg,Param1,Param2) if Msg==F.DN_INITDIALOG then for i=1,#box do hDlg:send(F.DM_SETCHECK,i+1,box[i] and F.BSTATE_CHECKED or F.BSTATE_UNCHECKED) end for i=1,#flist do hDlg:send(F.DM_LISTADD,6,{{Text=flist[i]}}) end RealPos=far.SendDlgMessage(hDlg,F.DM_LISTSETCURPOS,6,{SelectPos=RealPos}) fname=tostring(hDlg:send(F.DM_GETTEXT,6)) hDlg:send(F.DM_SETFOCUS,6,0) elseif (Msg==F.DN_EDITCHANGE or Msg==F.DN_LISTCHANGE) and Param1==6 then local ListInfo=far.SendDlgMessage(hDlg,F.DM_LISTINFO,6) RealPos=ListInfo.SelectPos fname=tostring(hDlg:send(F.DM_GETTEXT,6)) elseif Msg==F.DN_BTNCLICK and Param1>=2 and Param1<=5 then -- [x] x86 .. [ ] msi box[Param1-1]=Param2~=0 end end Macro { area="Common"; flags=""; description="! Far.changelog"; action=function() local f=tmp.."Far.changelog" if #flist==0 then --fwrite(GetPage('-L https://github.com/FarGroup/FarManager/raw/master/far/changelog'),f) fwrite(GetPage('https://raw.githubusercontent.com/FarGroup/FarManager/master/far/changelog'),f) local text=GetPage('https://farmanager.com/nightly.php') for build,year,month,day in string.gmatch(text,'nightly%/(Far30b%d-)%.x86%.(%d%d%d%d)(%d%d)(%d%d)%.7z') do table.insert(flist,build.." "..day.."-"..month.."-"..year) end end editor.Editor(f,nil,0,0,-1,-1,bit64.bor(F.EF_NONMODAL,F.EF_IMMEDIATERETURN,F.EF_OPENMODE_USEEXISTING),1,1,nil) --fname=far.InputBox(nil,'Загрузить файл?','Имя файла:',nil,fname,nil,nil,FIB_BUTTONS) local hDlg=far.DialogInit(uGuid,-1,-1,41,8,nil,items,0,DlgProc) if far.DialogRun(hDlg)==#items-1 then if fname then local build,day,month,year = string.match(fname,'^(Far30b%d-) (%d%d)%-(%d%d)%-(%d%d%d%d)$') local function Download(tmp,fname) fwrite(GetPage('https://farmanager.com/nightly/'..fname),tmp..fname) end if build and day and month and year then local fdata=year..month..day if box[1] and box[3] then local fname=build..".x86."..fdata..".7z" Download(tmp,fname) end if box[2] and box[3] then local fname=build..".x64."..fdata..".7z" Download(tmp,fname) end if box[1] and box[4] then local fname=build..".x86."..fdata..".msi" Download(tmp,fname) end if box[2] and box[4] then local fname=build..".x64."..fdata..".msi" Download(tmp,fname) end else Download(tmp,fname) end end end far.DialogFree(hDlg) end; } |