
var DEBUG_LOG=false;
try{
ACTIVE_ZAPPING;}catch(e){
ACTIVE_ZAPPING=null;}
var ENABLE_TOUCHPEN=(system.mdl_cfg.with_pen_support_startup_ui)?1:0;
var ENABLE_FAST_ANIM=(system.mdl_cfg.apps_context)?1:0;
var IS_1TUNER=(system.mdl_cfg.is_1tuner)?1:0;
var NUM_OF_CHANNEL=8;
var SERVICE_FONT_SIZE=44-2*ENABLE_TOUCHPEN;
var CHANNEL_HEIGHT=160-16*ENABLE_TOUCHPEN;
var CHANNEL_TOP_MARGIN=0+8*ENABLE_TOUCHPEN;
var VIDEOBOX_YPOS=-54+11*ENABLE_TOUCHPEN;
var SUMMARY_FONT_SIZE=28-2*ENABLE_TOUCHPEN;
var SUMMARY_YPOS=-2+7*ENABLE_TOUCHPEN;
var TIMEBAR_YPOS=-72+4*ENABLE_TOUCHPEN;
var MASK_THRESHOLD=410-40*ENABLE_TOUCHPEN;
var MASK_UPPER_HEIGHT=80+42*ENABLE_TOUCHPEN+8;
var MASK_UPPER_YPOS=(1080-78+62)/2-28*ENABLE_TOUCHPEN+4;
var MASK_LOWER_HEIGHT=18*2+36*ENABLE_TOUCHPEN+2;
var MASK_LOWER_YPOS=(-1080+62-6)/2+32*ENABLE_TOUCHPEN+1;
var DEFAULT_LIST_INDEX=2;var LIST_BG_UPPER="zapping_bg_upper.png";
var LIST_BG_MIDDLE="zapping_bg_middle.png";
var LIST_BG_BOTTOM="zapping_bg_bottom.png";
var TAB_ARROW="zapping_tab_arrow.png";
var TAB_NORMAL="zapping_tab_normal.png";
var TAB_FOCUS="zapping_tab_focus.png";
var MY_PATH;
var app_name="0387878700000030";
var path=APPLI_PATH+app_name+"/gadget/";
var MSG=load_pkg_lang(path+"lang",app_name);
var getNetworkNum=function(){
var lang=system.locale.language;
var country=system.locale.country;
if(lang=="ja-JP")return 4;
if(country=="IE")return 2;
if(country.match("^(UK|HK|TW|AU)$"))return 3;
return 4;};
var translation={
"ja-JP":{
"BROADCAST_0":"地上Ｄ",
"BROADCAST_1":"BS",
"BROADCAST_2":"CS1",
"BROADCAST_3":"CS2",
"NO_CONTENTS":MSG("LT_ZP_NO_PROGRAM"),
"VOICE_BROADCAST_0":"地上デジタル",
"VOICE_BROADCAST_1":"BS",
"VOICE_BROADCAST_2":"CS1",
"VOICE_BROADCAST_3":"CS2",
"VOICE_NO_CONTENTS":MSG("LT_ZP_NO_PROGRAM"),
},
"en-GB":{
"BROADCAST_0":(
function(){
switch(system.locale.country){
case "UK":
return "Freesat";
case "IE":
return "DVB";
case "HK":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數碼廣播";
case "TW":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數位電視";
case "AU":
return "Digital TV";
default:
return "DVB-S";}
return "";})(),
"BROADCAST_1":(
function(){
switch(system.locale.country){
case "UK":
return "DVB";
case "IE":
return "Satellite";
case "HK":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數碼廣播";
case "TW":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數位電視";
case "AU":
return "Digital TV";
default:
return "DVB-C";}
return "";})(),
"BROADCAST_2":(
function(){
switch(system.locale.country){
case "UK":
return "Other Sat.";
case "IE":
return "";
case "HK":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數碼廣播";
case "TW":
var lang=system.locale.language.substr(0,2);
return (lang=="en")?"Digital TV":"數位電視";
case "AU":
return "Digital TV";
default:
return "DVB-T";}
return "";})(),
"BROADCAST_3":(
function(){
switch(system.locale.country){
case "UK":
return "";
case "IE":
return "";
case "HK":
return "";
case "TW":
return "";
case "AU":
return "";
default:
return "DVB-via-IP";}
return "";})(),
"NO_CONTENTS":MSG("LT_ZP_NO_PROGRAM"),
},
};
var LANG=function(sym){
try{
var lang=system.locale.language.substr(0,5);
return translation[lang][sym]||"";}catch(e){
return translation["en-GB"][sym]||"";}
};
var gimageResource=function(target,bool){
if(bool){
target.org_src=target.src;
target.src="";}else{
if(target.org_src){
target.src=target.org_src;
delete target.org_src;}
}
};
var gtextResource=function(target,bool){
if(bool){
target.org_text=target.text;
setf_text(target,"");}else{
if(isString(target.org_text)){
setf_text(target,target.org_text);
delete target.org_text;}
}
};
var tab_gui=new container({});
tab_gui.init=function(){
this.tab_list=[];
this.cache=new gimage({"width":60,"height":206,src:MY_PATH+TAB_FOCUS});
for(var i=0;i<4;i++)
{
var item=new Tab();
item.init();
this.tab_list.push(item);
this.components.push(item);};

this.tab_up=new gimage({translate:[232,0,0],visible_p:false,
width:20,height:15,
src:MY_PATH+TAB_ARROW});
this.tab_down=new gimage({translate:[232,0,0],visible_p:false,
width:20,height:15,
src:MY_PATH+TAB_ARROW,flip:FLIP_VERTICAL});
this.components.push(this.tab_up,this.tab_down);
this.info={};};
tab_gui.update_service_list=function(){
var clist=zapping_api.get_epg_info();
if(!clist){
this.components=[];
return;}
if(this.info.sub_nw==clist.sub_nw&&
this.info&&this.info.useflg&&
this.info.useflg.join("")==clist.useflg.join(""))
return;
this.info={sub_nw:clist.sub_nw,useflg:clist.useflg};
this.components=[];
gadget.tab_fg.components=[];
var len=getNetworkNum();
var total_nw=clist.total_nw;
var pos=0;
for(var i=0;i<len;i++)
{
var name=LANG("BROADCAST_"+i);
var item=this.tab_list[i];
item.set_name(name);
item.set_nw(i);
item.visible_p=true;
if(!clist.useflg||clist.useflg[i]==-1)
continue;
if(i==clist.sub_nw){
item.suspend(false);
item.activate(true);
item.translate[1]=(88*total_nw-88)+ -173*pos;
this.components.push(item);
this.tab_up.translate[1]=(88*total_nw-88)+210/2-173*pos;
this.tab_down.translate[1]=(88*total_nw-88)-210/2-173*pos+4;
this.components.push(this.tab_up,this.tab_down);
gadget.tab_fg.components=[item];
pos++;}else{
if(clist.useflg&&clist.useflg[i]==1){
item.suspend(false);
item.activate(false);}else {
item.activate(false);
item.suspend(true);}
item.translate[1]=(88*total_nw-88)+ -173*pos;
this.components.unshift(item);
pos++;}
}
};
tab_gui.nextTab=function(){
return this.changeTab(+1);};
tab_gui.prevTab=function(){
return this.changeTab(-1);};
tab_gui.changeTab=function(diff){
var clist=zapping_api.get_epg_info();
var len=getNetworkNum();
var index=clist.sub_nw;
for(var i=0;i<4;i++){
index=(index+len+diff)%len;
if(clist.useflg&&clist.useflg[index]==1)break;}
if(DEBUG_LOG)console.log("[zapping] call nw_change (",index,")");
gadget.list_gui.last_info=null;
zapping.nw_change(index);
if(clist.sub_nw!=index)
HOME_SOUND_PLAY(0);
return true;};
tab_gui.freeResource=function(bool){
for(var i=0;i<this.tab_list.length;i++)
this.tab_list[i].freeResource(bool);
gimageResource(this.cache,bool);
gimageResource(this.tab_up,bool);
gimageResource(this.tab_down,bool);};
tab_gui.VoicePlay=function(){
if(gadget.cursor!=this)return;
var clist=zapping_api.get_epg_info();
var index=clist.sub_nw;
var msg=MSG("LT_VG_SOURCE_SELECTOR")+"\n";
var tmp=LANG("VOICE_BROADCAST_"+index);
if(tmp=="")
tmp=LANG("BROADCAST_"+index);
msg+=tmp+"\n";
if(!isNumber(list_gui.cindex)){
msg+=LANG("NO_CONTENTS");
VoicePlay(msg);
return;}
var info=clist["service_list"][list_gui.cindex];
if(!info){
msg+=LANG("NO_CONTENTS");
VoicePlay(msg);
return;}
if(system.locale.language!="ja-JP")
msg+="\n"+(info.service||"");
msg+="\n"+(info.name||"");
msg+="\n"+(info.summary||"");
VoicePlay(msg);};

var list_gui=new container({});
list_gui.init=function(){
this.clist=[];
this.translate=[0,0,-0.1];
for(var i=0;i<NUM_OF_CHANNEL;i++)
{
var item=new List();
item.init();
this.clist.push(item);};
this.cindex=DEFAULT_LIST_INDEX;};
list_gui.setVideoFunc=function (video_func){
this.video_func=video_func;};
list_gui.setVideoFunc2=function (video_func){
this.video_func2=video_func;};
list_gui.setVideoFunc3=function (video_func){
this.video_func3=video_func;};
list_gui.activate_video=function (bool){
return this.video_func(bool);};
list_gui.activate_video2=function (bool){
return this.video_func2(bool);};
list_gui.activate_video3=function (bool){
return this.video_func3(bool);};
list_gui.update_service_list=function(){
var clist=zapping_api.get_epg_info();
var index=isNumber(this.cindex)?this.cindex:DEFAULT_LIST_INDEX;
if(clist){
var cur_service=null;
if(this.last_info&&this.last_info.sub_nw==clist.sub_nw){
cur_service=this.last_info.service;}else{
cur_service=zapping_api.get_current_service();}
for(var i=0;i<clist["service_list"].length;i++){
var info=clist["service_list"][i];
if(info.service==cur_service){
index=i;
break;}
}
}
if(clist){
if(clist.videobox){
this.activate_video(true)
this.activate_video2(true)
}else{
this.activate_video(false)
this.activate_video2(false)
}
}

var size;
if(clist&&clist["service_list"]&&clist["service_list"].length){
size=clist["service_list"].length;}else {
size=1;}
if(size<=index){
index=size-1;}
var offset=-3+index;
this.components=[];
this.expand(false);
var gui_offset=0;
if(this.last_info){
for(var i=0;i<NUM_OF_CHANNEL;i++){
var cur_service=this.last_info.service;
if(!this.clist[i])continue;
if(this.last_info.service!=this.clist[i].get_service())continue;
gui_offset=i-3;
break;}
}
for(var i=0;i<NUM_OF_CHANNEL;i++)
{
var service=this.clist[(gui_offset+i+NUM_OF_CHANNEL)%NUM_OF_CHANNEL];
this.components.push(service);
service.visible_p=false;
service.is_active=false;
service.translate[1]=(CHANNEL_HEIGHT+4)*3-82-(offset+i)*(CHANNEL_HEIGHT+4);
service.translate[1]+=CHANNEL_TOP_MARGIN;
service.translate[1]+=(i>=4)?-(CHANNEL_HEIGHT+4):0;
var info=null;
if(clist&&
clist["service_list"]&&clist["service_list"].length){
info=clist["service_list"][offset+i];}else{
if(offset+i==0){
info={"summary":LANG("NO_CONTENTS")};}
}
if(info){
var diff=(i==3)?(CHANNEL_HEIGHT+4):0;
service.set_service(info.service);
service.set_name(info.name);
service.set_summary(info.summary);
service.set_description(info.description);
service.set_timeinfo(info.start_time,info.end_time,info.timezoneOffset);
service.timebar_bg.translate[1]=TIMEBAR_YPOS-diff;
service.timebar.translate[1]=TIMEBAR_YPOS-diff;
service.line2.translate[1]=-CHANNEL_HEIGHT/2-2-diff;
service.update_timeinfo();
this.activate_video(false)
service.description_gui.visible_p=false;
service.visible_p=true;
service.is_active=true;
var posy=(offset+1)*(CHANNEL_HEIGHT+4)+service.translate[1];
var need_mask=(posy>=MASK_THRESHOLD||posy<=-MASK_THRESHOLD);
service.depth_test(need_mask);
service.set_height(CHANNEL_HEIGHT/2,CHANNEL_HEIGHT/2+diff);}
};
this.cindex=index;
this.translate[1]=(offset+1)*(CHANNEL_HEIGHT+4);
this.target=this.translate[1];
this.expand(true);
if(clist&&clist["service_list"]){
var upper=!!(clist["service_list"][index-1]);
var lower=!!(clist["service_list"][index+1]);
gadget.touch_guide1.setShow(upper);
gadget.touch_guide2.setShow(lower);}else{
gadget.touch_guide1.setShow(false);
gadget.touch_guide2.setShow(false);}
force_redraw();};
list_gui.VoicePlay=function(){
var clist=zapping_api.get_epg_info();
var index=clist.sub_nw;
var msg="";
var tmp=LANG("VOICE_BROADCAST_"+index);
if(tmp=="")
tmp=LANG("BROADCAST_"+index);
msg+=tmp+"\n";
msg+=MSG("LT_VG_CH_SELECTOR")+", ";
if(!isNumber(this.cindex)){
msg+=LANG("NO_CONTENTS");
VoicePlay(msg);
return;}
var info=clist["service_list"][this.cindex];
if(!info){
msg+=LANG("NO_CONTENTS");
VoicePlay(msg);
return;}
if(system.locale.language!="ja-JP")
msg+="\n"+(info.service||"");
msg+="\n"+(info.name||"");
msg+="\n"+(info.summary||"");
VoicePlay(msg);};
list_gui.animation=function(count){
if(count%30==0){
var clist=this.clist;
var len=clist.length;
for(var i=0;i<len;i++)
{
if(!clist[i].is_active)continue;
clist[i].update_timeinfo();}
return true;}
return false;};
list_gui.auto_up_key=function(owner,keysym){
var me=owner.list_gui;
var clist=zapping_api.get_epg_info();
if(!(clist&&clist["service_list"]&&clist["service_list"].length))
return true;
if(me.cindex==0&&clist.current_service_index==1)
return false;
if(!clist["service_list"][me.cindex-1])
return true;
if(me.auto_key_flag){
me.complete_auto_key(me);
me.auto_key_flag=false;
return this.auto_up_key(owner,keysym);}
me.cindex--;
me.target-=(CHANNEL_HEIGHT+4);
me.auto_key(owner,keysym);
var bool=!!(clist["service_list"][me.cindex-1]);
owner.touch_guide1.setShow(bool);
owner.touch_guide2.setShow(true);
var service=me.components.pop();
var top=me.components[0].translate[1];
service.visible_p=false;
service.is_active=false;
service.translate[1]=top+(CHANNEL_HEIGHT+4);
service.timebar_bg.translate[1]=TIMEBAR_YPOS;
service.timebar.translate[1]=TIMEBAR_YPOS;
service.line2.translate[1]=-CHANNEL_HEIGHT/2-2;
me.components.unshift(service);
var info=clist["service_list"][me.cindex-3];
if(info){
service.set_service(info.service);
service.set_name(info.name);
service.set_summary(info.summary);
service.set_description(info.description);
service.set_timeinfo(info.start_time,info.end_time,info.timezoneOffset);
service.update_timeinfo();
this.activate_video(false);
service.description_gui.visible_p=false;
service.visible_p=true;
service.is_active=true;
service.depth_test(true);
service.set_height(CHANNEL_HEIGHT/2,CHANNEL_HEIGHT/2);}
return true;};
list_gui.auto_down_key=function(owner,keysym){
var me=owner.list_gui;
var clist=zapping_api.get_epg_info();
if(!(clist&&clist["service_list"]&&clist["service_list"].length))
return true;
if(!clist["service_list"][me.cindex+1])
return true;
if(me.auto_key_flag){
me.complete_auto_key(me);
me.auto_key_flag=false;
return this.auto_down_key(owner,keysym);}
me.cindex++;
me.target+=(CHANNEL_HEIGHT+4);
me.auto_key(owner,keysym);
var bool=!!(clist["service_list"][me.cindex+1]);
owner.touch_guide1.setShow(true);
owner.touch_guide2.setShow(bool);
var service=me.components.shift();
var last=me.components.length-1;
var bottom=me.components[last].translate[1];
service.visible_p=false;
service.is_active=false;
service.translate[1]=bottom-(CHANNEL_HEIGHT+4);
service.timebar_bg.translate[1]=TIMEBAR_YPOS;
service.timebar.translate[1]=TIMEBAR_YPOS;
service.line2.translate[1]=-CHANNEL_HEIGHT/2-2;
me.components.push(service);
var info=clist["service_list"][me.cindex+4];
if(info){
service.set_service(info.service);
service.set_name(info.name);
service.set_summary(info.summary);
service.set_description(info.description);
service.set_timeinfo(info.start_time,info.end_time,info.timezoneOffset);
service.update_timeinfo();
this.activate_video(false);
service.description_gui.visible_p=false;
service.visible_p=true;
service.is_active=true;
service.depth_test(true);
service.set_height(CHANNEL_HEIGHT/2,CHANNEL_HEIGHT/2);}
return true;};
list_gui.auto_key=function(owner,keysym){
var me=owner.list_gui;
me.expand(false);
var diff=(me.target-me.translate[1]);
var center=3;
var nearest=(diff>0)?2:4;
me.auto_key_diff=diff;
me.auto_key_flag=true;
me.select_channel(keysym);
var COUNT=(ENABLE_FAST_ANIM)?5*4:5;
var INTERVAL=(ENABLE_FAST_ANIM)?10:30;
var cnt=0;
for(var i=0;i<me.components.length;i++){
var posy=me.translate[1]+me.components[i].translate[1];
var need_mask=(posy>=MASK_THRESHOLD||posy<=-MASK_THRESHOLD);
me.components[i].depth_test(need_mask);}
var list_obj=list_gui.components;
if(list_obj&&list_obj.length>0){
for(var i=0;i<list_obj.length;i++){
list_obj[i].line1.visible_p=true;
list_obj[i].line2.visible_p=true;}
}
append_timer(me,INTERVAL,function(obj,cnt2){
if(cnt2<3)return;
cnt++;
if(cnt>COUNT){
obj.complete_auto_key(me);
return;}
obj.translate[1]+=diff/COUNT;
obj.components[center].translate[1]+=(diff<0)?0:diff/COUNT;
obj.components[nearest].translate[1]+=(diff>0)?0:diff/COUNT;
var ctarget=obj.components[center];
var ntarget=obj.components[nearest];
var ctarget_plus=obj.components[center+1];
if(ctarget_plus){
ctarget.line2.translate[1]=ctarget_plus.translate[1]-ctarget.translate[1]+CHANNEL_HEIGHT/2+2;}else{
ctarget.line2.translate[1]=-CHANNEL_HEIGHT/2-2-(CHANNEL_HEIGHT+COUNT-1)/COUNT*cnt;}
ctarget.timebar.translate[1]=ctarget.line2.translate[1]+(10-(TIMEBAR_YPOS+72));
ctarget.timebar_bg.translate[1]=ctarget.timebar.translate[1];
var ntarget_plus=obj.components[nearest+1];
if(ntarget_plus){
ntarget.line2.translate[1]=ntarget_plus.translate[1]-ntarget.translate[1]+CHANNEL_HEIGHT/2+2;}else{
ntarget.line2.translate[1]=-CHANNEL_HEIGHT/2-2-(CHANNEL_HEIGHT+COUNT-1)/COUNT*(COUNT-cnt);}
ntarget.timebar.translate[1]=ntarget.line2.translate[1]+(10-(TIMEBAR_YPOS+72));
ntarget.timebar_bg.translate[1]=ntarget.timebar.translate[1];
force_redraw();});};
list_gui.complete_auto_key=function(obj){
var diff=obj.auto_key_diff;
obj.auto_key_diff=0;
var center=3;
var nearest=(diff>0)?2:4;
var old=obj.last_service;
var clist=zapping_api.get_epg_info();
if(clist&&clist["service_list"][obj.cindex]){
if(clist["service_list"][obj.cindex].service!=old){
HOME_SOUND_PLAY(0)
this.VoicePlay();}
obj.last_service=clist["service_list"][obj.cindex].service;}
delete_timer(obj);
obj.auto_key_flag=false;
if(obj.need_to_update){
obj.need_to_update=false;
zapping_api.update();
var old=gadget.tab_gui.info.sub_nw;
gadget.tab_gui.update_service_list();
gadget.list_gui.update_service_list();
var clist=zapping_api.get_epg_info();
if(old!=clist.sub_nw)gadget.tab_gui.VoicePlay();
return;}
if(diff==0)return;
obj.translate[1]=obj.target;
obj.components[center].translate[1]=-obj.target+(CHANNEL_HEIGHT+4)/2;
obj.components[center+1].translate[1]=-obj.target-(CHANNEL_HEIGHT+4)*1.5;
var target=obj.components[center];
target.timebar_bg.translate[1]=TIMEBAR_YPOS-(CHANNEL_HEIGHT+4);
target.timebar.translate[1]=TIMEBAR_YPOS-(CHANNEL_HEIGHT+4);
target.line2.translate[1]=-CHANNEL_HEIGHT/2-2-(CHANNEL_HEIGHT+4);
target.set_height(CHANNEL_HEIGHT/2,CHANNEL_HEIGHT/2+(CHANNEL_HEIGHT+4));
var target=obj.components[nearest];
target.timebar_bg.translate[1]=TIMEBAR_YPOS;
target.timebar.translate[1]=TIMEBAR_YPOS;
target.line2.translate[1]=-CHANNEL_HEIGHT/2-2;
target.set_height(CHANNEL_HEIGHT/2,CHANNEL_HEIGHT/2);
obj.expand(true);
force_redraw();};
list_gui.select_channel=function (keysym){
var clist=zapping_api.get_epg_info();
if(!(clist&&clist["service_list"]))return;
var info=clist["service_list"][this.cindex];
if(this.onid==info.onid&&this.tsid==info.tsid
&&this.sid==info.sid&&this.major_ch==info.major_ch){
return;}
var me=this;
if(!info)return;
if(DEBUG_LOG)console.log("[zapping] call updown (",info.onid,info.tsid,info.sid,info.major_ch,0,")");
var update=0;
if(DEBUG_LOG)console.log("total:"+clist.total+", result:"+clist.result+", index="+me.cindex)
if(clist.total>clist.result){
if(clist.result<10)update=1;
if(keysym==TXK_UP&&me.cindex==10)update=2;
if(keysym==TXK_DOWN&&me.cindex==clist.result-10)update=3;}
if(keysym==TXK_UP&&me.cindex==0)update=4;
if(keysym==TXK_DOWN&&me.cindex==clist.result-1)update=5;
zapping_api.updown(info,(update>0)?1:0);
this.last_info=info;};
list_gui.expand=function (bool){
var list_obj=list_gui.components;
var clist=zapping_api.get_epg_info();
if(!list_obj[0])return;
var target=list_obj[3];
if(bool&&clist&&clist.videobox){
list_gui.activate_video(true);
target.description_gui.visible_p=false;}else{
list_gui.activate_video(false);
target.description_gui.visible_p=bool;};
if(bool){
try{
var list_obj=list_gui.components;
var upper1=list_obj[3-3];
var upper0=list_obj[3-2];
var lower0=list_obj[3+2];
var lower1=list_obj[3+3];
if(upper1)upper1.line2.visible_p=false;
if(upper0)upper0.line1.visible_p=false;
if(lower0)lower0.line2.visible_p=false;
if(lower1)lower1.line1.visible_p=false;}catch(e){}
}
};
list_gui.freeResource=function(bool){
for(var i=0;i<this.clist.length;i++)
this.clist[i].freeResource(bool);};
var gadget=new Gadget();
gadget.init=function(){
this.tab_gui=tab_gui;
this.list_gui=list_gui;
this.tab_fg=new container({});
this.list_bg=new container({
translate:[25,-1,-0.4],
components:[
new gimage({translate:[0,495,0],
src:MY_PATH+LIST_BG_UPPER,width:481,height:7,draw_type:DIRECT}),
new gimage({translate:[0,0,0],
src:MY_PATH+LIST_BG_MIDDLE,width:481,height:983,draw_type:DIRECT}),
new gimage({translate:[0,-497,0],
src:MY_PATH+LIST_BG_BOTTOM,width:481,height:12,draw_type:DIRECT}),
]});
this.list_bg.freeResource=function(bool){
for(var i=0;i<this.components.length;i++)
gimageResource(this.components[i],bool);};
this.mask_upper=new gbox({translate:[0,MASK_UPPER_YPOS,0],depth_test:true,
width:420,height:MASK_UPPER_HEIGHT,color:[0,0,0,0]});
this.mask_lower=new gbox({translate:[0,MASK_LOWER_YPOS,0],depth_test:true,
width:420,height:MASK_LOWER_HEIGHT,color:[0,0,0,0]});
this.touch_guide1=new container({translate:[0,469,0]});
this.touch_guide2=new container({translate:[0,-470,0]});
this.bg=new gbox({width:410,height:44,
round_enable:true,round_width:8,round_height:8,
color:[0,0,0,160]});
this.arrow1=new gimage({rotation:[-90,0,0,1],
width:41,height:87,
src:IMG_PATH+"apps_arrow_l.png"});
this.arrow1_h=new gimage({visible_p:false,rotation:[-90,0,0,1],
width:47,height:93,
src:IMG_PATH+"apps_arrow_l_fcs.png"});
this.arrow2=new gimage({rotation:[-90,0,0,1],
width:42,height:88,
src:IMG_PATH+"apps_arrow_r.png"});
this.arrow2_h=new gimage({visible_p:false,rotation:[-90,0,0,1],
width:47,height:93,
src:IMG_PATH+"apps_arrow_r_fcs.png"});
this.touch_guide1.components.push(this.bg,this.arrow1,this.arrow1_h);
this.touch_guide2.components.push(this.bg,this.arrow2,this.arrow2_h);
this.components.push(this.mask_upper,this.mask_lower,
this.tab_gui,this.list_bg,
this.list_gui,this.tab_fg);
if(ENABLE_TOUCHPEN==1)
this.components.push(this.touch_guide1,this.touch_guide2);
this.videoframe=new container({visible_p:false,translate:[0,VIDEOBOX_YPOS,0]});
this.videoframe.core=new videobox({width:16*21,height:9*21,color:[0,0,0,0],
source:1,overscan:true});
this.videoframe.components.push(this.videoframe.core);
this.components.push(this.videoframe);
var me=this;
this.touch_guide1.setShow=function(bool){
var val=(bool)?255:110;
me.arrow1.color=[val,val,val,255];};
this.touch_guide1.onFocus=function(bool){
me.arrow1.visible_p=!bool;
me.arrow1_h.visible_p=bool;};
this.touch_guide2.setShow=function(bool){
var val=(bool)?255:110;
me.arrow2.color=[val,val,val,255];};
this.touch_guide2.onFocus=function(bool){
me.arrow2.visible_p=!bool;
me.arrow2_h.visible_p=bool;};
this.tab_gui.init();
this.list_gui.init();
var me=this;
this.list_gui.setVideoFunc(
function(bool){
var bool2=!!me.is_activate;
me.videoframe.core.translate[2]=(bool&&bool2)?0:-9999;
me.videoframe.core.color[3]=(bool&&bool2)?0:255;});
this.list_gui.setVideoFunc2(
function(bool){
var bool2=!!me.is_activate;
var clist=zapping_api.get_epg_info();
me.videoframe.core.visible_p=(clist&&clist.active_nw>0);
me.videoframe.core.translate[2]=(bool&&bool2)?0:-9999;
zapping.sub_visible((bool&&bool2)?1:0);});
this.list_gui.setVideoFunc3(
function(bool){
me.videoframe.translate[2]=bool?0:-20;});
this.status={};
this.status["onFocus"]=false;};
gadget.isUseFrame=function(){return false;};
gadget.setProductId=function(pid){
if(isString(pid)){
this._product_id=pid;
MY_PATH=APPLI_PATH+pid+"/gadget/";}
};
gadget.destroy=function(){
if(DEBUG_LOG)console.log("[zapping] call destroy");
if(ACTIVE_ZAPPING==this){
zapping.destroy();
delEventHook(zapping);
del_default_stage_event_hook(zapping);
ACTIVE_ZAPPING=null;}
};
gadget.onFocus=function(is_focused,key,point_env){
this.set_mask(is_focused);
this.status["onFocus"]=is_focused;
if(is_focused){
zapping_api.rec_control(true);
if(point_env){
if(point_env.x>412/2){
var ret=this.directFocus_for_tab(point_env);
if(ret)return;}else{
var ret=this.directFocus_for_touchguide("touchstart",point_env);
if(ret)return;
var ret=this.directFocus_for_list("touchstart",point_env);
if(ret)return;}
}
this.cursor=this.list_gui;
var y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
this.requestFocus([-1,y,0],[412,h],0,42,null);}else{
zapping_api.rec_control(false);}
};
gadget.voicePlay=function(){
this.cursor.VoicePlay();};
gadget.directFocus_for_tab=function (point_env){
var len=this.tab_gui.components.length;
var pos=0;
for(var i=0;i<len;i++){
var network=this.tab_gui.components[i];
if(!(network instanceof Tab))continue;
if(point_env.y<network.translate[1]-176/2
||network.translate[1]+176/2<point_env.y)continue;
this.cursor=this.tab_gui
if(DEBUG_LOG)console.log("[zapping] call nw_change (",network.get_nw(),")");
var index=network.get_nw();
zapping.nw_change(index);
var clist=zapping_api.get_epg_info();
if(clist.sub_nw!=index){
HOME_SOUND_PLAY(0);}else{
this.cursor.VoicePlay();}
var len=clist.total_nw;
var h=200*len;
this.requestFocus([241-10,0,0],[56-2,h],0,42,
function(){HOME_SOUND_PLAY(0);});
this.tab_gui.tab_up.visible_p=true;
this.tab_gui.tab_down.visible_p=true;
return true;}
};
gadget.directFocus_for_list=function (type,point_env){
var len=this.list_gui.components.length;
for(var i=0;i<len;i++){
var service=this.list_gui.components[i];
if(!service.visible_p)continue;
var posy=this.list_gui.translate[1]+service.translate[1];
var height=service.get_height();
if(point_env.y<posy-height[1]||posy+height[0]<point_env.y)continue;
var old=this.cursor;
this.cursor=this.list_gui;
this.cursor.VoicePlay();
var y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
if(type=="touchstart"){
this.requestFocus([-1,y,0],[412,h],0,42,null);
var index=i-3;
if(index<0){
for(var j=0;j<-index;j++)
this.list_gui.auto_up_key(this,TXK_UP);}else if(index>0){
for(var j=0;j<+index;j++)
this.list_gui.auto_down_key(this,TXK_DOWN);}
}
return true;}
return false;};
gadget.count_for_touchguide=0;
gadget.directFocus_for_touchguide=function (type,point_env){
var posy=this.touch_guide1.translate[1];
var height=this.bg.height;
if(type=="touchcancel"||type=="touchend"){
this.touch_guide1.onFocus(false);
this.touch_guide2.onFocus(false);
force_redraw();}
if(!(point_env.y<posy-height/2||posy+height/2<point_env.y)){
switch(type){
case "touchstart":
this.cursor=this.list_gui;
this.cursor.VoicePlay();
this.set_mask(true);
var y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
this.requestFocus([-1,y,0],[412,h],0,42,null);
this.touch_guide1.onFocus(true);
this.count_for_touchguide=0;
break;
case "touchmove":
if(this.count_for_touchguide++>2){
this.count_for_touchguide=0;
this.list_gui.auto_up_key(this,TXK_UP);}
break;
case "touchend":
this.list_gui.auto_up_key(this,TXK_UP);
this.touch_guide1.onFocus(false);
break;
case "touchcancel":
this.touch_guide1.onFocus(false);
break;}
force_redraw();
return true;}
var posy=this.touch_guide2.translate[1];
var height=this.bg.height;
if(!(point_env.y<posy-height/2||posy+height/2<point_env.y)){
switch(type){
case "touchstart":
this.cursor=this.list_gui;
this.cursor.VoicePlay();
this.set_mask(true);
var y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
this.requestFocus([-1,y,0],[412,h],0,42,null);
this.touch_guide2.onFocus(true);
this.count_for_touchguide=0;
break;
case "touchmove":
if(this.count_for_touchguide++>2){
this.count_for_touchguide=0;
this.list_gui.auto_down_key(this,TXK_DOWN);}
break;
case "touchend":
this.list_gui.auto_down_key(this,TXK_DOWN);
this.touch_guide2.onFocus(false);
break;
case "touchcancel":
this.touch_guide2.onFocus(false);
break;}
force_redraw();
return true;}
return false;};
gadget.animation=function(count){
if(this.need_update==true){
this.need_update=false;
this.zapping_hook_func(null,zapping,zapping.UPDATE);}else{
return this.list_gui.animation(count);}
};
gadget.set_mask=function(bool){
var list=this.list_gui.components;
if(bool){
this.mask_upper.visible_p=true;
this.mask_lower.visible_p=true;
if(list.length>0){
if(list[0].is_active)list[0].visible_p=true;
if(list[NUM_OF_CHANNEL-2].is_active)list[NUM_OF_CHANNEL-2].visible_p=true;
if(list[NUM_OF_CHANNEL-1].is_active)list[NUM_OF_CHANNEL-1].visible_p=true;}
}else{
this.mask_upper.visible_p=false;
this.mask_lower.visible_p=false;
if(list.length>0){
list[0].visible_p=false;
list[NUM_OF_CHANNEL-2].visible_p=false;
list[NUM_OF_CHANNEL-1].visible_p=false;}
}
};
gadget.key_hook=function(up_down,keysym){
switch(keysym){
case TXK_SCROLL_UP:
case TXK_UP:
if(this.cursor==this.tab_gui){
if(up_down!=KEY_DOWN)return true;
return this.tab_gui.prevTab();}else{
if(up_down!=KEY_PRESS)return true;
return this.list_gui.auto_up_key(this,keysym);}
return true;
case TXK_SCROLL_DOWN:
case TXK_DOWN:
if(this.cursor==this.tab_gui){
if(up_down!=KEY_DOWN)return true;
return this.tab_gui.nextTab();}else{
if(up_down!=KEY_PRESS)return true;
return this.list_gui.auto_down_key(this,keysym);}
return true;
case TXK_RIGHT:
if(up_down!=KEY_PRESS)return true;
if(this.cursor!=this.tab_gui){
var clist=zapping_api.get_epg_info();
if(clist.active_nw<=0)return true;
this.cursor=this.tab_gui;
this.cursor.VoicePlay();
var clist=zapping_api.get_epg_info();
var len=clist.total_nw;
var h=200*len;
this.requestFocus([241-10,0,0],[56-2,h],0,42,
function(){HOME_SOUND_PLAY(0);});
this.tab_gui.tab_up.visible_p=true;
this.tab_gui.tab_down.visible_p=true;
return true;}
break;
case TXK_LEFT:
if(up_down!=KEY_PRESS)return true;
if(this.cursor==this.tab_gui){
this.cursor=this.list_gui;
this.cursor.VoicePlay();
var y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
this.requestFocus([-1,y,0],[412,h],0,42,
function(){HOME_SOUND_PLAY(0);});
this.tab_gui.tab_up.visible_p=false;
this.tab_gui.tab_down.visible_p=false;
return true;}
break;
case TXK_ENTER:
if(up_down!=KEY_DOWN)return true;
if(this.cursor!=this.tab_gui){
var list_gui=this.list_gui;
var clist=zapping_api.get_epg_info();
if(!clist)return true;
this.list_gui.last_info=null;
if(clist.all_service_count==0){
zapping.enter(clist.main_nw,clist.sub_nw,0,0,0,0);
HOME_SOUND_PLAY("enter");
return true;}
if(!(clist&&clist["service_list"]&&clist["service_list"].length))return true;
var info=clist["service_list"][list_gui.cindex];
if(!info)return true;
if(DEBUG_LOG)console.log("[zapping] call enter (",clist.main_nw,clist.sub_nw,info.onid,info.tsid,info.sid,info.major_ch,")");
zapping.enter(clist.main_nw,clist.sub_nw,info.onid,info.tsid,info.sid,info.major_ch);
HOME_SOUND_PLAY("enter");}
return true;
case TXK_REC:
if(up_down!=KEY_DOWN)return true;
if(this.cursor!=this.tab_gui){
var list_gui=this.list_gui;
var clist=zapping_api.get_epg_info();
if(!clist)return true;
this.list_gui.last_info=null;
if(clist.all_service_count==0){
zapping.direct_rec(info.onid,info.tsid,info.sid,info.major_ch);
return true;}
if(!(clist&&clist["service_list"]&&clist["service_list"].length))return true;
var info=clist["service_list"][list_gui.cindex];
if(!info)return true;
if(DEBUG_LOG)console.log("[zapping] call direct_rec (",info.onid,info.tsid,info.sid,info.major_ch,")");
zapping.direct_rec(info.onid,info.tsid,info.sid,info.major_ch);}
return true;
default:
break;}

return false;};
gadget.point_hook=function (type,identifier,x,y,screenX,screenY){
var point_env={x:x,y:y};
if(x>412/2){
if(type=="touchstart")this.directFocus_for_tab(point_env);
return true;}
if(type=="touchstart"&&this.cursor==this.list_gui){
var pos_y=82-(CHANNEL_HEIGHT+4)/2-CHANNEL_TOP_MARGIN;
var h=CHANNEL_HEIGHT*2;
if(!(y<pos_y-h/2||pos_y+h/2<y)){
this.key_hook(KEY_DOWN,TXK_ENTER);
return true;}
}
var ret=this.directFocus_for_touchguide(type,point_env);
if(ret)return true;
var ret=this.directFocus_for_list(type,point_env);
if(ret)return true;
return true;};
gadget.zapping_create={};
gadget.setFullscreen=function(bool){
this.isFull=bool;};
gadget.cover={};
gadget.activate=function(bool){
this.set_mask(false);
if(this.is_activate==bool){
this.delay=5;}
this.is_activate=bool;
var clist=zapping_api.get_epg_info();
if(clist&&clist.videobox){
this.list_gui.activate_video2(true);}else{
this.list_gui.activate_video2(false);}
if(bool&&this.status["onFocus"]){
zapping_api.rec_control(true);}
var me=this;
if(bool){
if(!IS_1TUNER){
this.videoframe.visible_p=true;}
addEventHook(zapping,this.zapping_hook_func);
add_default_stage_event_hook(zapping,this.default_zapping_hook_func);
if(DEBUG_LOG)console.log("[zapping] call create");
var clist=zapping_api.get_epg_info();
var resume=null;
if(clist&&this.list_gui&&isNumber(this.list_gui.cindex)){
resume=clist;}
if(!ACTIVE_ZAPPING)
zapping.create();
ACTIVE_ZAPPING=this;}else{
if(DEBUG_LOG)console.log("[zapping] call destroy");
delete_timer(this);
delete_timer(this.cover);
this.list_gui.last_info=null;
this.touch_guide1.onFocus(false);
this.touch_guide2.onFocus(false);
if(ACTIVE_ZAPPING==this){
zapping.destroy();
delEventHook(zapping);
del_default_stage_event_hook(zapping);
ACTIVE_ZAPPING=null;
zapping_api.rec_control(false);}
};};
gadget.isOpenSubVideobox=function(){
return this.videoframe.visible_p;}
gadget.openSubVideobox=function(){
this.videoframe.visible_p=true;}
gadget.closeSubVideobox=function(){
this.videoframe.visible_p=false;}
gadget.getStatus=function(){
return {"movable":false,"removable":false};};
gadget.need_update=false;
gadget.default_zapping_hook_func=function (stg,obj,event){

if(event!=obj.UPDATE)
return false;
try{
ACTIVE_ZAPPING;}catch(e){
return;}
if(ACTIVE_ZAPPING.is_activate==true){
ACTIVE_ZAPPING.need_update=true;};
return true;};
gadget.zapping_hook_func=function (stg,obj,event){
if(DEBUG_LOG)console.log("[zapping ev] "+zapping_api.DEF[event]);
switch(event){
case obj.UPDATE:
append_timer(zapping_api,150,function(obj2){
delete_timer(obj2);
try{
gadget.list_gui.activate_video(false);
if(DEBUG_LOG)console.log("load EPG");
if(gadget.is_activate){
load("/tmp/zapping_data.js");
gadget.need_update=false;}
}catch(e){
if(DEBUG_LOG)console.log(e.message);}
if(gadget.list_gui.auto_key_flag){
gadget.list_gui.need_to_update=true;}else{
zapping_api.update();
var old=gadget.tab_gui.info.sub_nw;
gadget.tab_gui.update_service_list();
gadget.list_gui.update_service_list();
var clist=zapping_api.get_epg_info();
if(old!=clist.sub_nw)gadget.tab_gui.VoicePlay();}
gadget.set_mask(gadget.status["onFocus"]);});
break;
case obj.UP_DOWN:
case obj.CREATE:
case obj.ENTER:
case obj.NW_CHANGE:
case obj.DESTROY:
case obj.DIRECT_REC:
break;}
return;};
gadget.freeResource=function(bool){
list_gui.freeResource(bool);
tab_gui.freeResource(bool);
gimageResource(this.list_bg,bool);};
function Tab(){
this.superClass=container;
this.superClass({});
this.visible_p=false;};
Tab.prototype=new container({});
Tab.prototype.init=function(){
this.bg=new gimage({translate:[235-10,0,0],
width:76,"height":205,
src:MY_PATH+TAB_NORMAL});
this.name_gui=new gtext({translate:[232,0,0],rotation:[-90,0,0,1],
width:128,align:CENTER,font_size:28,
color:[128,128,128,255]});
this.components.push(this.bg,this.name_gui);};
Tab.prototype.set_name=function (name){
if(name==this.name_gui.text)return;
setf_text(this.name_gui,name.toString());};
Tab.prototype.set_nw=function (network){
this._network=network;};
Tab.prototype.get_nw=function (){
return this._network;};
Tab.prototype.suspend=function (bool){
if(bool){
this.bg.color=[128,128,128,255];
this.name_gui.color=[64,64,64,255];}else{
this.bg.color=[255,255,255,255];
this.name_gui.color=[128,128,128,255];}
};
Tab.prototype.activate=function (bool){
if(bool){
this.bg.src=MY_PATH+TAB_FOCUS;
this.name_gui.color=[128,128,128,255];}else{
this.bg.src=MY_PATH+TAB_NORMAL;
this.name_gui.color=[255,255,255,255];}
};
Tab.prototype.freeResource=function (bool){
gimageResource(this.bg,bool);
gtextResource(this.name_gui,bool);};
function List(){
this.superClass=container;
this.superClass({});
this.visible_p=false;};
List.prototype=new container({});
List.prototype.init=function(){
this.line1=new gbox({translate:[0,+CHANNEL_HEIGHT/2+1,-0.3],
color:[200,200,200,255],width:392,height:1});
this.line2=new gbox({translate:[0,-CHANNEL_HEIGHT/2-2,-0.3],
color:[200,200,200,255],width:392,height:1});
this.service_gui=new gtext({translate:[-140,56,0],color:[1,69,156,255],
width:120,height:14,
font_size:SERVICE_FONT_SIZE,align:CENTER});
this.name_gui=new gtext({translate:[60,56,0],color:[1,69,156,255],
width:270,height:14,omitter:"...",font_size:28});
this.summary_gui=new gtextbox({translate:[0,SUMMARY_YPOS,0],color:[32,32,32,255],
width:360,height:72,font_size:SUMMARY_FONT_SIZE});
this.timebar_bg=new gbox({translate:[0,TIMEBAR_YPOS,0],color:[92,92,92,255],
width:350,height:6,visible_p:false});
this.timebar=new gbox({translate:[0,TIMEBAR_YPOS,0],color:[16,196,224,255],
height:6,visible_p:false});
this.description_gui=new gtextbox({visible_p:false,
translate:[0,27-CHANNEL_HEIGHT,0],
color:[96,96,96,255],
width:350,height:186,font_size:22});
this.components.push(this.line1,this.line2);
this.components.push(this.timebar_bg,this.timebar);
this.components.push(this.service_gui,this.name_gui,this.summary_gui);
this.components.push(this.description_gui);
this.timeinfo=[0,0,0];};
List.prototype.set_service=function (service){
if(!isString(service))service="";
if(service==this.service_gui.text)return;
setf_text(this.service_gui,service);
this._service=service;};
List.prototype.get_service=function (){
return this._service;};
List.prototype.set_name=function (name){
if(!isString(name))name="";
if(name==this.name_gui.text)return;
setf_text(this.name_gui,name);};
List.prototype.set_summary=function (summary){
if(!isString(summary))summary="";
if(summary==this.summary_gui.text)return;
setf_text(this.summary_gui,summary);};
List.prototype.set_description=function (description){
if(!isString(description))description="";
if(description==this.description_gui.text)return;
setf_text(this.description_gui,description);};
List.prototype.set_timeinfo=function (start,end,offset){
this.timeinfo[0]=0;
try{
var hhmm=start.split(":");
if(hhmm.length>=2){
var time=new Date();
time.setHours(hhmm[0]);
time.setMinutes(hhmm[1]);
this.timeinfo[0]=time.getTime();}
}catch(e){
this.timeinfo[0]=0;}
try{
this.timeinfo[1]=0;
var hhmm=end.split(":");
if(hhmm.length>=2){
var time=new Date();
time.setHours(hhmm[0]);
time.setMinutes(hhmm[1]);
this.timeinfo[1]=time.getTime();}
}catch(e){
this.timeinfo[1]=0;}
this.timeinfo[2]=parseFloat(offset);};
List.prototype.update_timeinfo=function(){
if(!isNumber(this.timeinfo[0])||this.timeinfo[0]==0||
!isNumber(this.timeinfo[1])||this.timeinfo[1]==0){
this.timebar.visible_p=false;
this.timebar_bg.visible_p=false;
return;}
var now=new Date().getTime();
var len=this.timeinfo[1]-this.timeinfo[0];
var current=now-this.timeinfo[0];
if(current>len){
this.timebar.visible_p=false;
this.timebar_bg.visible_p=false;
return;}
this.timebar.width=Math.floor(current/len*350);
if(this.timebar.width>350)this.timebar.width=350;
this.timebar.translate[0]=(this.timebar.width-350)/2;
this.timebar.visible_p=true;
this.timebar_bg.visible_p=true;};
List.prototype.freeResource=function(bool){
gtextResource(this.service_gui,bool);
gtextResource(this.name_gui,bool);
gtextResource(this.summary_gui,bool);
gtextResource(this.description_gui,bool);};
List.prototype.depth_test=function (bool){
this.line1.depth_test=bool;
this.line2.depth_test=bool;
this.service_gui.depth_test=bool;
this.name_gui.depth_test=bool;
this.summary_gui.depth_test=bool;
this.timebar_bg.depth_test=bool;
this.timebar.depth_test=bool;};
List.prototype.set_height=function (upper,lower){
this._upper2=upper;
this._lower2=lower;};
List.prototype.get_height=function (){
return [this._upper2,this._lower2];};

var zapping_api={};
zapping_api.init=function(){
zapping_api.DEF=[];
for(var prop in zapping)
zapping_api.DEF[zapping[prop]]=prop;}();
zapping_api.update=function(){
this.info={};
try{
this.info.all_service_count=all_service_count;
this.info.service_count=service_count;
this.info.current_nw=current_nw;
this.info.current_service=current_service;
this.info.epg_info=epg_info;
this.info.epg_program_info=epg_program_info;
this.info.display_type=startup_display_type;
this.info.rec_flg=rec_flg;
this.info.nw_useflg=nw_useflg;
this.info.current_service_index=current_service_index;}catch(e){
this.info={};
console.log(e.message);}
var data={
"total":isNumber(this.info.all_service_count)?this.info.all_service_count:0,
"result":isNumber(this.info.service_count)?this.info.service_count:0,
"main_nw":isNumber(this.info.main_nw)?this.info.main_nw:0,
"sub_nw":isNumber(this.info.current_nw)?this.info.current_nw:0,
"useflg":this.info.nw_useflg,
"display_type":isNumber(this.info.display_type)?this.info.display_type:1,
"rec_flg":isNumber(this.info.rec_flg)?this.info.rec_flg:0,
"total_nw":0,
"active_nw":0,
"current_service_index":parseInt(this.info.current_service_index||"0",10),
"videobox":false,
"service_list":[],
};
var len=getNetworkNum();
for(var i=0;i<len;i++){
if(data.useflg&&data.useflg[i]!=-1)
data.total_nw++;
if(data.useflg&&data.useflg[i]==1)
data.active_nw++;}
var epg=this.info.epg_info;
var program=this.info.epg_program_info;
if(epg&&epg.length>0){
if((data.display_type-data.rec_flg)>=2&&!IS_1TUNER){
data.videobox=true;}
}
if(epg&&program)
{
for(var i=0;i<epg.length;i++){
var clist={
"onid":(function(){
try{
if(isNumber(epg[i][0]))
return epg[i][0];}catch(e){}
return "";})(),
"tsid":(function(){
try{
if(isNumber(epg[i][1]))
return epg[i][1];}catch(e){}
return "";})(),
"sid":(function(){
try{
if(isNumber(epg[i][2]))
return epg[i][2];}catch(e){}
return "";})(),
"service":(function(){
try{
if(isString(epg[i][3]))
return epg[i][3];}catch(e){}
return "";})(),
"major_ch":epg[i][4],
"summary":(function(){
try{
if(isString(epg[i][5]))
return epg[i][5];}catch(e){}
return "";})(),
"name":(function(){
try{
if(isString(epg[i][6]))
return epg[i][6];}catch(e){}
return "";})(),
"description":(function(){
try{
if(isString(program[epg[i][3]]["info"]))
return program[epg[i][3]]["info"];}catch(e){}
return "";})(),
"start_time":(function(){
try{
var tmp=program[epg[i][3]]["date"].split(" ")[1];
var ret=tmp.split("～");
if(ret&&ret.length>=2)return ret[0];
var ret=tmp.split("-");
if(ret&&ret.length>=2)return ret[0];}catch(e){
return "";}})(),
"end_time":(function(){
try{
var tmp=program[epg[i][3]]["date"].split(" ")[1];
var ret=tmp.split("～");
if(ret&&ret.length>=2)return ret[1];
var ret=tmp.split("-");
if(ret&&ret.length>=2)return ret[1];}catch(e){
return "";}})(),
};
data.service_list.push(clist);};}
this.info.data=data;};
zapping_api.get_current_nw=function(){
return this.info.current_nw;};
zapping_api.get_current_service=function(){
return this.info.current_service;};
zapping_api.get_epg_info=function(){
if(!this.info)return;
return this.info.data;};
zapping_api.updown=function (info,update){
if(!info||
!isNumber(info.onid)||!isNumber(info.tsid)||
!isNumber(info.sid)||!isNumber(info.major_ch))
return;
zapping.updown(info.onid,info.tsid,info.sid,info.major_ch,update);}
zapping_api.rec_control=function (bool){
if(system.locale.language=="ja-JP")
return;
system.key_control.rec=bool;}
return gadget;
