-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'util.lua') post=AssertPost() dataID=GetVarInt(mg.request_info.query_string, 'id') or 0 if dataID~=0 then for i,v in ipairs(edcb.EnumAutoAdd()) do if v.dataID==dataID then key=v.searchInfo break end end end preset=mg.get_var(mg.request_info.query_string, 'preset') presetList={} for v in edcb.GetPrivateProfile('search','list','',ini):gmatch('[^,]+') do presetList[#presetList+1]=v end if preset then --区切り文字と空文字列は使えない preset=preset:gsub(',', '_'):match('.+') or '_' for i,v in ipairs(presetList) do if v==preset then presetIndex=i break end end _preset=preset..'_Search' if GetVarInt(post, 'save')==1 then if presetIndex then --上書き edcb.WritePrivateProfile(_preset, nil, '', ini) else --追加 presetList[#presetList+1]=preset edcb.WritePrivateProfile('search', 'list', table.concat(presetList, ',')..',', ini) end edcb.WritePrivateProfile(_preset, 'andKey', (GetVarInt(post,'caseFlag') and 'C!{999}' or '')..mg.get_var(post,'andKey'),ini) edcb.WritePrivateProfile(_preset, 'notKey', mg.get_var(post,'notKey'),ini) edcb.WritePrivateProfile(_preset, 'regExpFlag', GetVarInt(post,'regExpFlag'),ini) edcb.WritePrivateProfile(_preset, 'titleOnlyFlag', GetVarInt(post,'titleOnlyFlag'),ini) edcb.WritePrivateProfile(_preset, 'aimaiFlag', GetVarInt(post,'aimaiFlag'),ini) edcb.WritePrivateProfile(_preset, 'notContetFlag', GetVarInt(post,'notContetFlag'),ini) edcb.WritePrivateProfile(_preset, 'notDateFlag', GetVarInt(post,'notDateFlag'),ini) edcb.WritePrivateProfile(_preset, 'freeCAFlag', GetVarInt(post,'freeCAFlag'),ini) edcb.WritePrivateProfile(_preset, 'chkRecEnd', GetVarInt(post,'chkRecEnd'),ini) edcb.WritePrivateProfile(_preset, 'chkRecDay', GetVarInt(post,'chkRecDay'),ini) edcb.WritePrivateProfile(_preset, 'chkRecNoService', GetVarInt(post,'chkRecNoService'),ini) edcb.WritePrivateProfile(_preset, 'chkDurationMin', GetVarInt(post,'chkDurationMin'),ini) edcb.WritePrivateProfile(_preset, 'chkDurationMax', GetVarInt(post,'chkDurationMax'),ini) edcb.WritePrivateProfile(_preset, 'days', GetVarInt(post,'days'),ini) edcb.WritePrivateProfile(_preset, 'dateList', mg.get_var(post,'dateList'),ini) edcb.WritePrivateProfile(_preset, 'lock', GetVarInt(post,'lock'),ini) for i=0,10000 do v=mg.get_var(post, 'contentList', i) if not v then break end edcb.WritePrivateProfile(_preset, 'contentList'..i, v,ini) end for i=1,10000 do v=mg.get_var(post, 'serviceList', i) if not v then break end edcb.WritePrivateProfile(_preset, 'serviceList'..i, v,ini) end elseif GetVarInt(post, 'del')==1 then if presetIndex then table.remove(presetList, presetIndex) edcb.WritePrivateProfile(_preset, nil, '', ini) edcb.WritePrivateProfile('search', 'list', #presetList~=0 and table.concat(presetList, ',')..',' or '', ini) end else key={ andKey=edcb.GetPrivateProfile(_preset,'andKey','',ini), notKey=edcb.GetPrivateProfile(_preset,'notKey','',ini), regExpFlag=tonumber(edcb.GetPrivateProfile(_preset,'regExpFlag',false,ini))~=0, titleOnlyFlag=tonumber(edcb.GetPrivateProfile(_preset,'titleOnlyFlag',false,ini))~=0, aimaiFlag=tonumber(edcb.GetPrivateProfile(_preset,'aimaiFlag',false,ini))~=0, notContetFlag=tonumber(edcb.GetPrivateProfile(_preset,'notContetFlag',false,ini))~=0, notDateFlag=tonumber(edcb.GetPrivateProfile(_preset,'notDateFlag',false,ini))~=0, freeCAFlag=tonumber(edcb.GetPrivateProfile(_preset,'freeCAFlag',0,ini)), chkRecEnd=tonumber(edcb.GetPrivateProfile(_preset,'chkRecEnd',false,ini))~=0, chkRecDay=tonumber(edcb.GetPrivateProfile(_preset,'chkRecDay',0,ini)), chkRecNoService=tonumber(edcb.GetPrivateProfile(_preset,'chkRecNoService',false,ini))~=0, chkDurationMin=tonumber(edcb.GetPrivateProfile(_preset,'chkDurationMin',0,ini)), chkDurationMax=tonumber(edcb.GetPrivateProfile(_preset,'chkDurationMax',0,ini)), days=tonumber(edcb.GetPrivateProfile(_preset,'days',0,ini)), contentList={}, serviceList={}, dateList={}, lock=tonumber(edcb.GetPrivateProfile(_preset,'lock',false,ini))~=0, } for i=0,1000 do v=tonumber(edcb.GetPrivateProfile(_preset,'contentList'..i,0,ini)) if v==0 then break end table.insert(key.contentList, {content_nibble=v}) end for i=0,1000 do v=edcb.GetPrivateProfile(_preset,'serviceList'..i,0,ini) if v==0 then break end m={string.match(v, '^(%d+)%-(%d+)%-(%d+)$')} if #m==3 then table.insert(key.serviceList, {onid=0+m[1], tsid=0+m[2], sid=0+m[3]}) end end for v in string.gmatch(edcb.GetPrivateProfile(_preset,'dateList','',ini), '[^,]+') do m={string.match(v, '^(.-)%-(%d+):(%d+)%-(.-)%-(%d+):(%d+)$')} if #m==6 then dateInfo={ startDayOfWeek=({['日']=0,['月']=1,['火']=2,['水']=3,['木']=4,['金']=5,['土']=6})[m[1]], endDayOfWeek=({['日']=0,['月']=1,['火']=2,['水']=3,['木']=4,['金']=5,['土']=6})[m[4]] } if dateInfo.startDayOfWeek and dateInfo.endDayOfWeek then dateInfo.startHour=0+m[2] dateInfo.startMin=0+m[3] dateInfo.endHour=0+m[5] dateInfo.endMin=0+m[6] table.insert(key.dateList, dateInfo) end end end end end if not key then key=post and getSearchKey(post) or getSearchKeyKeyword(mg.request_info.query_string) end key.search=dataID==0 and not mg.get_var(post, 'id') edcb.htmlEscape=15 ct={ title='検索', js='
\n', progres=true, macro=sidePanel } ct.subheader='
\n' ct.main='
\n' ..(sidePanel and sidePanelTemplate(true) or '') ..'
' if key.search then ct.dialog={{ id='dialog_preset', content='lock' ..'登録名
' ..'※同じ名前がある場合上書きします', button='
' }} ct.main=ct.main..'
' for i,v in ipairs(presetList) do lock=tonumber(edcb.GetPrivateProfile(v..'_Search','lock',false,ini))~=0 ct.main=ct.main..'' ..''..EdcbHtmlEscape(v:sub(1,(v:match('^[%w%p]') and 1 or 3)))..'' ..''..EdcbHtmlEscape(v)..'' ..(lock and '' or '
') ..'\n' ..'\n' ..'\n' ..'' end ct.main=ct.main..'
\n' end b=(post or preset or dataID~=0 or mg.get_var(mg.request_info.query_string, 'andKey')) and edcb.SearchEpg(key) or {} --ここからkeyはHTML出力用 key.andKey=EdcbHtmlEscape(key.andKey) key.notKey=EdcbHtmlEscape(key.notKey) ct.main=ct.main..'
\n\n' ..'
\n' ..'
\n' ..(key.search and '
\n
詳細検索
\n' ..'
\n' ..'
\n' or '') ..'\n' ..'\n' ..SerchTemplate(key) ..(not key.search and '\n' or '') ..(parseAndKey(key.andKey).disableFlag and '\n' or '') ..'
\n' ..'
' ..(key.search and '
\n' or '') ..'
\n' ..'
\n' ..'
\n' ..'
\n
\n' table.sort(b, function(a,b) return os.time(a.startTime) < os.time(b.startTime) end) a={} for i,v in ipairs(b) do if v.startTime then startTime=os.time(v.startTime) endTime=v.durationSecond and startTime+v.durationSecond or startTime if os.time()<=endTime then table.insert(a, v) end end end pageIndex=GetVarInt(mg.request_info.query_string,'page',0,100000) or 0 autopage=GetVarInt(mg.request_info.query_string,'autopage',0,100000) or 0 PAGE_COUNT=tonumber(edcb.GetPrivateProfile('SET','PAGE_COUNT','30',ini)) if PAGE_COUNT==0 then PAGE_COUNT=#a end if #a>0 then if math.ceil((#a/PAGE_COUNT)-1)>0 then pg='
\n' ..'
\n' n=pageIndex>(#a/PAGE_COUNT-2) and math.floor(#a/PAGE_COUNT)-4 or math.max(0,pageIndex-2) for i=n, n+4 do pg=pg..(i>=0 and i<#a/PAGE_COUNT and '
\n' or '') end pg=pg..'
\n' ..'
\n' pg='
\n'..pg..'
\n' end ct.main=ct.main..(pg or '')..'
' ..'

\n' ..'
'..#a..' 件中 '..math.min(#a,pageIndex*PAGE_COUNT+1)..' － '..math.min(#a,(pageIndex+1)*PAGE_COUNT)..' 件
\n' ..'
\n
\n' ..' 録画\n' ..' | 日付\n' ..' | 番組名\n' ..' | サービス\n' ..' | 番組内容\n' ..'
--- | --- | --- | --- | ---
\n' rt={} for i,v in ipairs(edcb.GetReserveData()) do rt[v.onid..'-'..v.tsid..'-'..v.sid..'-'..v.eid]=v.reserveID end ctt={} for i=math.max(1,pageIndex*PAGE_COUNT+1),math.min(#a,(pageIndex+1)*PAGE_COUNT) do v=a[i] for j,w in ipairs(edcb.GetServiceList() or {}) do if w.onid==v.onid and w.tsid==v.tsid and w.sid==v.sid then service_name=w.service_name break end end r=nil id=rt[v.onid..'-'..v.tsid..'-'..v.sid..'-'..v.eid] or nil if id then r=edcb.GetReserveData(id) rs=r.recSetting end table.insert(ctt, '
\n' ..' os.time() and '>' or ' class="search '..(r and 'recmark">' or 'add mdl-button mdl-js-button mdl-button--fab mdl-button--colored">add')) ..'\n | '..FormatTimeAndDuration(v.startTime) ..'\n | '..(v.shortInfo and ConvertTitle(v.shortInfo.event_name) or '') ..'\n | '..service_name ..'\n | '..(v.shortInfo and v.shortInfo.text_char or '') ..'\n') end ct.main=ct.main..table.concat(ctt)..'

\n
\n'..(pg or '') end ct.main=ct.main..'\n
\n' if dataID>0 or post or preset or mg.get_var(mg.request_info.query_string, 'andKey') then ct.main=ct.main..'\n' ..(not key.search and '\n' or '') ..'\n' ..'\n' ..'\n' ..'\n' ..(key.regExpFlag and '\n' or '') ..(key.titleOnlyFlag and '\n' or '') ..(key.aimaiFlag and '\n' or '') ..(key.notContetFlag and '\n' or '') ..(key.notDateFlag and '\n' or '') ..(key.freeCAFlag and '\n' or '') ..(key.days and '\n' or '') ..(key.chkRecNoService and '\n' or '') ..(key.chkDurationMin and '\n' or '') ..(key.chkDurationMax and '\n' or '') ..(key.chkRecEnd and '\n' or '') ..(key.chkRecDay and '\n' or '') ..(parseAndKey(key.andKey).disableFlag and '\n' or '') ..(parseAndKey(key.andKey).caseFlag and '\n' or '') if key.contentList then for i,v in ipairs(key.contentList) do ct.main=ct.main..'\n' end end if key.serviceList then for i,v in ipairs(key.serviceList) do ct.main=ct.main..'\n' end end if key.dateList then ct.main=ct.main..'\n' end ct.main=ct.main..'\n' end ct.main=ct.main..'
\n' ct=template(ct) mg.write(ct:Pop(Response(200,'text/html','utf-8',ct.len)..(ct.gzip and 'Content-Encoding: gzip\r\n' or '')..'\r\n'))