-- vim:set ft=lua: dofile(mg.script_name:gsub('[^\\/]*$','')..'epg.lua') show=mg.get_var(mg.request_info.query_string,'show') tab=GetVarInt(mg.request_info.query_string,'tab',0,#NetworkIndex()) or 0 date=GetVarInt(mg.request_info.query_string,'date',-10000,1000) or 0 hour=GetVarInt(mg.request_info.query_string,'hour',-1,27) or -1 --hour=-1で現在時刻-MARGIN_HOUR時間を基準 interval=GetVarInt(mg.request_info.query_string,'interval',0,100) or DEF_interval CH_COUNT=GetVarInt(mg.request_info.query_string,'chcount') or DEF_CH_COUNT pageIndex=GetVarInt(mg.request_info.query_string,'page',0,100000) or 0 --UTC+9の今日の始まりの日付。現在時刻が深夜4時までは前日になることに注意 baseDate=math.floor((utc9Now-4*3600)/24/3600) if date==0 then m={(mg.get_var(mg.request_info.query_string,'date') or ''):match('^(%d%d%d%d)%-(%d?%d)%-(%d?%d)$')} if #m==3 then date=math.floor(TimeWithZone({year=m[1],month=m[2],day=m[3]})/24/3600)-baseDate end end Hour=hour<0 and math.floor(((utc9Now%(24*3600))/3600)-MARGIN_HOUR)%24 or hour if Hour<4-(hour<0 and MARGIN_HOUR or 0) then Hour=Hour+24 end pageDate=baseDate+date pageTime=(pageDate*24+Hour)*3600 Date=os.date('!*t', pageDate*24*3600) NOW=pageTimediv>div:first-child").each(function(){'..(date==0 and 'end($(this), true);});jump();' or 'end($(this));});')..'setInterval("line()", 1000);});' or ''),(NOW and pageTime+(interval-9)*3600 or false)), menu=epgMenuTemplate(true), progres=true, macro=sidePanel, searchlinks=true } ct.subheader='
\n' ..'
\n' ..'
\n' ..'
\n' table.insert(main, '
\n
\n') end ct.subheader=ct.subheader ..'
\n' ..'\n\n' ct.side='\n' ..'サービス\n' ..'

\n' WIDE={ --少し拡幅する ['32391-32391-23608']=true, --MX } ctt,Head={},{} n=0 pagemin=pageIndex*CH_COUNT+1 pagemax=(pageIndex+1)*CH_COUNT SubChConcat=tonumber(edcb.GetPrivateProfile('GUIDE','subChConcat',true,ini))~=0 for i,v in ipairs(st) do if not v.subCh then n=n+1 end if CH_COUNT==0 or pagemin<=n and n<=pagemax then op={service_name=v.service_name} if not v.subCh then left=0 for j=i,#st+1 do if j>#st or j>i and not st[j].subCh then column=j-i id=v.onid..'-'..v.tsid..'-'..v.sid ct.side=ct.side..'
- '..v.service_name..'
\n' table.insert(Head, ''..v.service_name..'\n') table.insert(ctt, '
\n') break end end else left=left+1 end lastPx=0 total=0 table.insert(ctt, '
') for j,w in ipairs(v.et) do startTime=TimeWithZone(w.startTime) startPx=math.min(math.floor((startTime-pageTime)/60)*ONE_MIN_PX, ONE_MIN_PX*60*interval) endTime=w.durationSecond and startTime+w.durationSecond or (j<#v.et and TimeWithZone(v.et[j+1].startTime) or startTime) --終了時間未定 endPx=math.min(math.floor((endTime-pageTime)/60)*ONE_MIN_PX, ONE_MIN_PX*60*interval) if startPx-lastPx>0 then if not v.subCh then table.insert(ctt, '
\n') end total=total+startPx-lastPx lastPx=startPx end if endPx-lastPx>2 then --イベントグループのサブでないか if not w.eventGroupInfo or #w.eventGroupInfo.eventDataList~=1 or w.eventGroupInfo.eventDataList[1].onid==w.onid and w.eventGroupInfo.eventDataList[1].tsid==w.tsid and w.eventGroupInfo.eventDataList[1].sid==w.sid and w.eventGroupInfo.eventDataList[1].eid==w.eid then --サブチャンネル何個分か width=1 for k=i+1,#st do span=false if st[k].subCh and w.eventGroupInfo then for l,x in ipairs(w.eventGroupInfo.eventDataList) do if v.onid==x.onid and v.tsid==x.tsid and st[k].sid==x.sid then width=width+1 span=true break end end end if not span then break end end op.url='epginfo.html'..hrefGene()..'&onid='..w.onid..'&tsid='..w.tsid..'&sid='..w.sid..(w.past and '&startTime='..startTime or '&eid='..w.eid) table.insert(ctt, epgcell(w, op)) total=total+endPx-lastPx lastPx=endPx end end end if not v.subCh and total
\n') end table.insert(ctt, '
') if i==#st or not st[i+1].subCh then table.insert(ctt, '\n') end elseif n>pagemax then break end end ct.side=ct.side..'

\n' ..'\n' ..'ジャンル\n' ..'

\n
- すべて
\n' for i=0,15 do nibble1=edcb.GetGenreName(i*256+255) if nibble1~='' then ct.side=ct.side..'
- '..nibble1..'
\n' end end ct.side=ct.side..'

\n
\n' table.insert(main, '
\n' ..(sidePanel and sidePanelTemplate() or '') ..'
' ..'
\n
\n'..table.concat(Head)..'
\n' ..'
\n' ..'
\n') for i=Hour,Hour+interval-1 do j=i%24 d=os.date('!*t', ((pageDate*24)+i)*3600) table.insert(main, '
`'..(j==4 and Date.day~=d.day and d.day..'日' or '')..(j<4 and j+24 or j)..'時`
\n') end ct.main=table.concat(main)..(NOW and '
' or '') ..'
\n' ..table.concat(ctt) ..'
\n
\n' ..'\n' ..'\n' ..'\n' ..'\n' ..'\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'))