var product_id="0387878700140034";
var app_name="BOOKMARKS";
var path=APPLI_PATH+product_id+"/gadget/";
var BROWSER_PRODUCT_ID="0077777700140002";
var brw_js_path=APPLI_PATH+BROWSER_PRODUCT_ID+"/gadget/";

var TTS_SUPPORT=(ebus.tts&&ebus.tts.supported)?true:false;
var BROWSER_TOU_VERSION="1.0";
var COUNTRY_CODE=system.locale.country.substr(0,2);
var TOU_PATH=getHostName()+"/browser_info/term_of_use/";
var DEF_FDP=(system.fdp_color)?true:false;
var browser_get_version=function(){
var MAJOR_VERSION="1";
var file_name=TOU_PATH+MAJOR_VERSION+".json";
var result=null;
var request_handler=0;
try{
if(request_handler)cancel_http_request(request_handler);
request_handler=http_request({
url:file_name,
sync:true,
onload:function(status,header,body){
if(status==200){
var dt=eval("("+body+")");
if(dt!=null){
result=("version" in dt)?dt.version:null;}
}
}
});
request_handler=0;}catch(e){
console.log("Error get file");}
return result;}
var BOOKMARK_BG_IMG=[
"bookmarks_bg_l.png",
"bookmarks_bg_m.png",
"bookmarks_bg_r.png",
"bookmarks_bg_flat.png",
];
var BG_MAP=[[-205,0,-0.5,8,990],
[0,0,-0.5,402,990],
[205,0,-0.5,8,990],
[0,0,-0.5,418,990],
];
var BOOKMARK_BG_LIST_IMG=[
"bookmark_bg_l.png",
"bookmark_bg_m.png",
"bookmark_bg_r.png",
"bookmark_bg_flat.png",
];
var DEF_4K2K=false;
if(system.screen){
if(system.screen.view_width==3840&&system.screen.view_height==2160){
DEF_4K2K=true;}
}
var BOOKMARK_BG_HEIGHT=990;
var BOOKMARK_BG_WIDTH=418;
var CAPTURE_UPDATE_WAIT=0;
var CAPTURE_UPDATETIME_CHECK_WAIT=1;
var ANIM_30_MIN=30*60*10;var ANIM_1_MIN=60*10;
var DEF_MULTI_USER=false;
if(system.user_profile&&system.user_profile.supported){
try{
var uprofile={};
var _uprofile=system.user_profile.get({mhc:{id:null}});
if(_uprofile&&_uprofile.mhc){
uprofile=_uprofile;
if(uprofile&&uprofile.mhc&&(typeof uprofile.mhc.multiuser_supported=="boolean")){
DEF_MULTI_USER=uprofile.mhc.multiuser_supported;}
}
}catch(e){
}
}
var USER_PROFILE_ID=-1;
var get_user_profile_id=function(){
if(DEF_MULTI_USER){
try{
var profile=system.user_profile.get({mhc:{id:null}});
USER_PROFILE_ID=(profile.mhc.id=="undefined")?-1:profile.mhc.id;
if(USER_PROFILE_ID<0)USER_PROFILE_ID=-1;}catch(e){
USER_PROFILE_ID=-1;}
}
}
var BOOKMARK_PARTS_ITEM_W=364;
var BOOKMARK_PARTS_ITEM_MARGIN=4;
if(DEF_4K2K){
var BOOKMARK_PARTS_ITEM_MAX=2;
var BOOKMARK_PARTS_ITEM_H=428;
var BOOKMARK_PARTS_FACTOR=1.5;
var BOOKMARK_FOCUS_MARGIN=19;
var BOOKMARK_FOCUS_POS_X=-1;
var BOOKMARK_FOCUS_POS=[
(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*0.5-BOOKMARK_FOCUS_MARGIN,
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*0.5-BOOKMARK_FOCUS_MARGIN
];
var BOOKMARK_FOCUS_H=408;
var BOOKMARK_FOCUS_W=346;
var BOOKMARK_TITLE_POS=-178;
var BOOKMARK_IMAGE_H=410;
var BOOKMARK_COVER_H=550;
var BOOKMARK_COVER_FACT=1;
var BOOKMARK_COVER_FACT2=2;
var BOOKMARK_IMG_MARGIN_X=-1;
var BOOKMARK_IMG_MARGIN_Y=5;}else {
var BOOKMARK_PARTS_ITEM_MAX=4;
var BOOKMARK_PARTS_ITEM_H=212;
var BOOKMARK_PARTS_FACTOR=2.5;
var BOOKMARK_FOCUS_MARGIN=20;
var BOOKMARK_FOCUS_POS_X=0;
var BOOKMARK_FOCUS_POS=[
(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*1.5-BOOKMARK_FOCUS_MARGIN,
(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*0.5-BOOKMARK_FOCUS_MARGIN,
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*0.5-BOOKMARK_FOCUS_MARGIN,
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*1.5-BOOKMARK_FOCUS_MARGIN
];
var BOOKMARK_FOCUS_H=192;
var BOOKMARK_FOCUS_W=344;
var BOOKMARK_TITLE_POS=-70;
var BOOKMARK_IMAGE_H=192;
var BOOKMARK_COVER_H=250;
var BOOKMARK_COVER_FACT=2;
var BOOKMARK_COVER_FACT2=2;
var BOOKMARK_IMG_MARGIN_X=0;
var BOOKMARK_IMG_MARGIN_Y=4;}
function bookmark_parts_item(param){
this.superClass=container;
this.superClass({});
this.translate=param.translate;
this.enable=false;
this.url=null;
if(DEF_FDP){
this.components=[
this.item=new container({components:[
this.bg_img=new gimage({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_IMG_MARGIN_Y,0.1],width:350-4,height:BOOKMARK_IMAGE_H,
draw_type:DIRECT,src:path+BOOKMARK_BG_LIST_IMG[3],depth_test:true}),
this.bm_img_bk=new gimage({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_IMG_MARGIN_Y,0.1],width:350-4,height:BOOKMARK_IMAGE_H,
src:null,draw_type:DIRECT,depth_test:true}),
this.bm_img=new gimage({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_IMG_MARGIN_Y,0.1],width:350-4,height:BOOKMARK_IMAGE_H,
src:null,draw_type:DIRECT,depth_test:true}),
this.bm_title_bg=new gbox({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_TITLE_POS-2,0.2],width:350-4,height:40,
color:[255,255,255,255],visible_p:false,depth_test:true}),
this.bm_title=new gtext({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_TITLE_POS,0.3],width:310,font_size:26,
color:[135,135,135,255],text:"",omitter:"...",depth_test:true}),
]}),
];}
else{
this.components=[
this.item=new container({components:[
this.bg_img_l=new gimage({translate:[-174,0,0],width:8,height:BOOKMARK_PARTS_ITEM_H,
draw_type:DIRECT,src:path+BOOKMARK_BG_LIST_IMG[0],depth_test:true}),
this.bg_img_m=new gimage({translate:[0,0,0],width:340,height:BOOKMARK_PARTS_ITEM_H,
draw_type:DIRECT,src:path+BOOKMARK_BG_LIST_IMG[1],depth_test:true}),
this.bg_img_r=new gimage({translate:[178,0,0],width:16,height:BOOKMARK_PARTS_ITEM_H,
draw_type:DIRECT,src:path+BOOKMARK_BG_LIST_IMG[2],depth_test:true}),
this.bm_img_bk=new gimage({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_IMG_MARGIN_Y,0.1],width:350-4,height:BOOKMARK_IMAGE_H,
src:null,draw_type:DIRECT,depth_test:true}),
this.bm_img=new gimage({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_IMG_MARGIN_Y,0.1],width:350-4,height:BOOKMARK_IMAGE_H,
src:null,draw_type:DIRECT,depth_test:true}),
this.bm_title_bg=new gbox({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_TITLE_POS-2,0.2],width:350-4,height:40,
color:[255,255,255,255],visible_p:false,depth_test:true}),
this.bm_title=new gtext({translate:[BOOKMARK_IMG_MARGIN_X,BOOKMARK_TITLE_POS,0.3],width:310,font_size:26,
color:[135,135,135,255],text:"",omitter:"...",depth_test:true}),
]}),
];}
this.anim_flg=false;
this.anim_cnt=0;
this.bm_title_bk="";};
bookmark_parts_item.prototype.set_data=function(index){
setf_text(this.bm_title,"");
this.bm_img.src="";
this.bm_title_bg.visible_p=false;
if(index>=gadget.bookmark_num){
setf_text(this.bm_title,"");
this.bm_img.src="";
this.update_time=0;
return;}
if(index<0)return;
gadget.get_nvram_list();
var data=get_bookmark_info(index);
setf_text(this.bm_title,data.title);
this.bm_title_bg.visible_p=true;
this.bm_img.src=data.img;
this.enable=true;
this.update_time=data.update_time;};
bookmark_parts_item.prototype.freeResource=function(bool){
if(bool){
this.bm_img.org_src=this.bm_img.src;
this.bm_img.src="";}else{
this.bm_img.src=this.bm_img.org_src;
this.bm_img.org_src="";}
};
bookmark_parts_item.prototype.cap_update=function(index){
var data=get_bookmark_info(index);
this.bm_img_bk.src=data.img;
this.bm_title_bk=data.title;
this.anim_flg=true;
this.anim_cnt=0;
this.bm_img.color[3]=255;}
bookmark_parts_item.prototype.animation=function(count){
if(this.anim_flg!=true)return;
this.anim_cnt++;
if(this.anim_cnt<32){
this.bm_img.color[3]=this.bm_img.color[3]-8;}else if(this.anim_cnt==32){
this.bm_img.src=this.bm_img_bk.src;
this.bm_img.color[3]=255;
if(this.bm_title.text!=this.bm_title_bk){
setf_text(this.bm_title,this.bm_title_bk);}
}else if(this.anim_cnt==33){
this.anim_reset();}
}
bookmark_parts_item.prototype.anim_reset=function(){
this.bm_img_bk.src="";
this.anim_flg=false;
this.anim_cnt=0;
this.bm_img.color[3]=255;
this.bm_title_bk="";}
function bookmark_parts_box(param){
this.superClass=container;
this.superClass({});
this.translate=param.translate;
this.height=param.height;
this.frame=new container({});
this.frame.move_to=(DEF_4K2K)?MoveTo4K:MoveTo;
this.components.push(this.frame);
this.item_array_num=BOOKMARK_PARTS_ITEM_MAX+2;
this.item_array=[];
for(var i=0;i<this.item_array_num;i++){
this.item_array[i]=new bookmark_parts_item({
translate:[0,(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_PARTS_FACTOR
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*i,0]});
this.frame.components.push(this.item_array[i]);}
};
bookmark_parts_box.prototype.init=function(){
this.data_index_top=1;
this.data_index_btm=BOOKMARK_PARTS_ITEM_MAX;
this.moveTo_state=false;
for(var i=1;i<this.item_array_num;i++){
this.item_array[i].set_data(i-1);}
gadget.backup_bookmark_data();};
bookmark_parts_box.prototype.reset_data=function(index){
for(var i=0;i<this.item_array_num;i++){
this.item_array[i].set_data(i-1);
this.item_array[i].translate[1]=(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_PARTS_FACTOR
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*i;}
gadget.backup_bookmark_data();
this.frame.translate[1]=0;
this.data_index_top=1;
this.data_index_btm=BOOKMARK_PARTS_ITEM_MAX;
this.moveTo_state=false;
gadget.btn_top.set_scroll_disable();
if(gadget.bm_item_max<=BOOKMARK_PARTS_ITEM_MAX){
gadget.btn_btm.set_scroll_disable();}else{
gadget.btn_btm.set_scroll_enable();}
};
bookmark_parts_box.prototype.update_data=function(){
for(var i=0;i<this.item_array_num;i++){
var index=this.data_index_top+i-2;
this.item_array[i].set_data(index);
this.item_array[i].anim_reset();}
gadget.backup_bookmark_data();
if(this.data_index_top-1<=0){
gadget.btn_top.set_scroll_disable();}else{
gadget.btn_top.set_scroll_enable();}
if(this.data_index_btm>=gadget.bookmark_num){
gadget.btn_btm.set_scroll_disable();}else{
gadget.btn_btm.set_scroll_enable();}
};
bookmark_parts_box.prototype.up_move=function(){
var self=this;
this.moveTo_state=true;
this.frame.move_to({
x:this.frame.translate[0],
y:this.frame.translate[1]-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN),
z:this.frame.translate[2],
end_func:function(obj){self.moveTo_state=false},
rate:0.4
});
this.data_index_top--;
this.data_index_btm--;
this.data_pop_unsh();
if(this.data_index_btm>=gadget.bookmark_num){
gadget.btn_btm.set_scroll_disable();}else{
gadget.btn_btm.set_scroll_enable();}
if(this.data_index_top-1<=0){
gadget.btn_top.set_scroll_disable();}
};
bookmark_parts_box.prototype.down_move=function(){
var self=this;
this.moveTo_state=true;
this.frame.move_to({
x:this.frame.translate[0],
y:this.frame.translate[1]+(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN),
z:this.frame.translate[2],
end_func:function(obj){self.moveTo_state=false},
rate:0.4
});
this.data_index_top++;
this.data_index_btm++;
this.data_sh_pu();
gadget.btn_top.set_scroll_enable();
if(this.data_index_btm>=gadget.bookmark_num){
gadget.btn_btm.set_scroll_disable();}
};
bookmark_parts_box.prototype.data_pop_unsh=function(){
var tmp=this.item_array.pop();
this.frame.components.pop();
tmp.set_data(this.data_index_top-2);
tmp.translate[1]=(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_PARTS_FACTOR
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*(this.data_index_top-1);
this.item_array.unshift(tmp);
this.frame.components.unshift(tmp);
this.item_array[0].anim_reset();};
bookmark_parts_box.prototype.data_sh_pu=function(){
var tmp=this.item_array.shift();
this.frame.components.shift();
tmp.set_data(this.data_index_btm);
tmp.translate[1]=(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_PARTS_FACTOR
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*(this.data_index_btm+1);
this.item_array.push(tmp);
this.frame.components.push(tmp);
this.item_array[this.item_array.length-1].anim_reset();};
bookmark_parts_box.prototype.freeResource=function(bool){
for(var i=0,max=this.item_array_num;i<max;i++){
this.item_array[i].freeResource(bool);}
};
bookmark_parts_box.prototype.cap_update=function(up_list,all_list){
var all_list_num=all_list.length;
var ret_list=new Array();
for(var i=0,max=up_list.length;i<max;i++){
for(var k=0,j=this.data_index_top-2,max2=this.item_array_num;k<max2;k++){
var index=j+k;
if(index<0)continue;
if(index>all_list_num-1)break;
if(up_list[i].url==all_list[index].url){
if(up_list[i].update_time!=all_list[index].update_time){
this.item_array[k].cap_update(index);}
break;}
}
}
}
bookmark_parts_box.prototype.cap_update_check=function(all_list){
var all_list_num=all_list.length;
var ret_list=new Array();
for(var k=0,i=this.data_index_top-2,max=this.item_array_num;k<max;k++){
var index=i+k;
if(index<0)continue;
if(index>all_list_num-1)break;
var data={};
data.id=all_list[index].id;
data.times=all_list[index].times+"";
data.update_time=all_list[index].update_time;
data.title=all_list[index].title;
data.url=all_list[index].url;
ret_list.push(data);
BROWSER.get_bookmark_capture(data.id,data.url);
}
return ret_list;}
bookmark_parts_box.prototype.animation=function(count){
for(var i=0,max=this.item_array_num;i<max;i++){
this.item_array[i].animation(count);}
};

function bookmark_scroll_btn(param){
this.superClass=container;
this.superClass({});
var self=this;
this.translate=param.translate;
this.direction=param.direction;
this.enable=false;
this.scroll_enable=false;
this.focus_move=param.focus_move?param.focus_move:null;
if(system.mdl_cfg.with_pen_support_startup_ui){
this.visible_p=true;
this.components=[
this.base=new gbox({width:BOOKMARK_PARTS_ITEM_W,height:30,color:[0,0,0,150],
round_enable:true,round_width:8,round_height:8}),
this.img=new gimage({
width:28,rotation:[-90,0,0,1],
draw_type:DIRECT,src:IMG_PATH+"apps_arrow_l.png"}),
this.img_prs=new gimage({
width:28,rotation:[-90,0,0,1],
draw_type:DIRECT,src:IMG_PATH+"apps_arrow_l_fcs.png",visible_p:false}),
];
if(this.direction=="down"){
this.img.rotation[0]=90;
this.img_prs.rotation[0]=90;}
}else{
this.visible_p=false;
if(DEF_FDP){
this.components=[
this.img=new gimage({
width:25,height:53,rotation:[-90,0,0,1],color:system.fdp_color.ICON_ONBASE,
draw_type:DIRECT,src:IMG_PATH+"apps_arrow_l.png"}),
];
if(this.direction=="down"){
this.img.rotation=[90,0,0,1];}
}
else {
this.components=[
this.img=new gimage({
width:119,height:25,
draw_type:DIRECT,src:path+"arrow_top.png"}),
];
if(this.direction=="down"){
this.img.src=path+"arrow_btm.png";}
}
}
};
bookmark_scroll_btn.prototype.set_scroll_enable=function(mode){
this.scroll_enable=true;
if(system.mdl_cfg.with_pen_support_startup_ui){
this.base.color=[0,0,0,150];}else{
this.visible_p=true;}
};
bookmark_scroll_btn.prototype.set_scroll_disable=function(mode){
this.scroll_enable=false;
if(system.mdl_cfg.with_pen_support_startup_ui){
this.base.color=[200,200,200,150];}else{
this.visible_p=false;}
};
bookmark_scroll_btn.prototype.onFocus=function(){
if(this.focus_move)
this.focus_move([0,this.translate[1]-20,0],[BOOKMARK_PARTS_ITEM_W-8,30-8],0,42,null);};
bookmark_scroll_btn.prototype.done_focus=function(){
if(!system.mdl_cfg.with_pen_support_startup_ui)return;
this.img.visible_p=false;
this.img_prs.visible_p=true;

force_redraw();
append_timer(this,200,function(obj,count){
delete_timer(obj);
this.img.visible_p=true;
obj.img_prs.visible_p=false;
force_redraw();});};
function MoveTo(param){
delete_timer(this);
if(param.func)param.func(this);
this.tmp={};
this.endpos={};
this.tmp.RATE=0.6;
this.tmp.max_count=param.count?param.count:9;
if(param.rate){
this.tmp.RATE=param.rate;}
if(param.count)this.tmp.max_count=param.count;
this.endpos.x=param.x;
this.endpos.y=param.y;
this.endpos.z=param.z;
this.tmp.dx=param.x-this.translate[0];
this.tmp.dy=param.y-this.translate[1];
this.tmp.dz=param.z-this.translate[2];
this.translate[0]+=this.tmp.dx*this.tmp.RATE;
this.translate[1]+=this.tmp.dy*this.tmp.RATE;
this.translate[2]+=this.tmp.dz*this.tmp.RATE;

force_redraw();
append_timer(this,50,function (obj,count){
obj.tmp.dx=param.x-obj.translate[0];
obj.tmp.dy=param.y-obj.translate[1];
obj.tmp.dz=param.z-obj.translate[2];
obj.translate[0]+=Math.floor(obj.tmp.dx*obj.tmp.RATE);
obj.translate[1]+=Math.floor(obj.tmp.dy*obj.tmp.RATE);
obj.translate[2]+=Math.floor(obj.tmp.dz*obj.tmp.RATE);

if(count>=obj.tmp.max_count){
delete_timer(obj);
obj.translate[0]=param.x;
obj.translate[1]=param.y;
obj.translate[2]=param.z;

if(typeof param.end_func=="function"){
param.end_func(obj);}
}
force_redraw();});}
function MoveTo4K(param){
if(param.func)param.func(this);
this.translate[0]=param.x;
this.translate[1]=param.y;
this.translate[2]=param.z;
if(typeof param.end_func=="function"){
param.end_func(this);}
force_redraw();}
function get_bookmark_info(index){
if((index<0)||
(index>gadget.bookmark_data.bookmarkpanel.length-1))
return;
var data={};
try{
if(!DEF_4K2K){
data.img=apps_nvram_file.read({
filename:gadget.bookmark_data.bookmarkpanel[index].times+"",
async:false,finished:function(){},product_id:"home"});}else {
data.img=apps_nvram_file.read({
filename:gadget.bookmark_data.bookmarkpanel[index].times+"_4k",
async:false,finished:function(){},product_id:"home"});}
}catch(e){
data.img="default_bookmark_img.png";}
data.title=gadget.bookmark_data.bookmarkpanel[index].title;
data.update_time=gadget.bookmark_data.bookmarkpanel[index].update_time;
return data;}
var gadget=new Gadget();
gadget.init=function(){
this.lang=load_pkg_lang(path+"lang",app_name);
this.cursor_pos=0;
this.confirm_state=false;
if(DEF_FDP){
this.title=new gtext({translate:[0,BOOKMARK_BG_HEIGHT/2-19,-0.2],
width:BOOKMARK_BG_WIDTH-50,color:system.fdp_color.TEXT_ONBASE,align:CENTER,
text:this.lang("LT_HOME_GADGET_BOOKMARKS")});}
else {
this.title=new gtext({translate:[0,BOOKMARK_BG_HEIGHT/2-19,-0.2],
width:BOOKMARK_BG_WIDTH-50,color:[255,255,255,255],align:CENTER,
text:this.lang("LT_HOME_GADGET_BOOKMARKS")});}

this.bg=new Array();
this.bookmark_bg_list=new Array();
this.bookmark_img=new Array();
this.bookmark_title_list=new Array();
this.bookmark_title_bg_list=new Array();
this.bookmark_data=new Array();
this.bookmark_num=0;
this.bookmark_data_bk_update_time=new Array();
this.bookmark_num_bk=0;
this.capture_list=new Array();
this.capture_big_list=new Array();
this.capture_count=0;

this.get_nvram_list();
if(DEF_FDP){
this.bg.push(
new gimage({translate:[BG_MAP[3][0],BG_MAP[3][1],BG_MAP[3][2]],
width:BG_MAP[3][3],height:BG_MAP[3][4],
draw_type:DIRECT,src:path+BOOKMARK_BG_IMG[3]})
);
this.components.push(this.bg[0]);}
else {
for(var m=0;m<3;m++){
this.bg.push(
new gimage({translate:[BG_MAP[m][0],BG_MAP[m][1],BG_MAP[m][2]],
width:BG_MAP[m][3],height:BG_MAP[m][4],
draw_type:DIRECT,src:path+BOOKMARK_BG_IMG[m]})
);
this.components.push(this.bg[m]);}
}
this.components.push(this.title);
this.bookmark_parts=new container({
translate:[0,-20,-0.1],width:364,heigth:906,
components:[
this.cover_top=new gbox({translate:[0,
(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_COVER_FACT+BOOKMARK_COVER_H/BOOKMARK_COVER_FACT2,0.1],
width:400,height:BOOKMARK_COVER_H,color:[255,255,255,0],depth_test:true}),
this.cover_btm=new gbox({translate:[0,
-(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_COVER_FACT-BOOKMARK_COVER_H/BOOKMARK_COVER_FACT2,0.1],
width:400,height:BOOKMARK_COVER_H,color:[255,255,255,0],depth_test:true}),
this.bm_btn=new bookmark_parts_box({translate:[0,0,-0.3],
height:(BOOKMARK_PARTS_ITEM_H+BOOKMARK_PARTS_ITEM_MARGIN)*BOOKMARK_PARTS_ITEM_MAX+BOOKMARK_PARTS_ITEM_H}),
this.btn_top=new bookmark_scroll_btn({translate:[0,BOOKMARK_BG_HEIGHT/2-43,0.2],
direction:"up",focus_move:this.requestFocus}),
this.btn_btm=new bookmark_scroll_btn({translate:[0,-BOOKMARK_BG_HEIGHT/2+43,0.2],
direction:"down",focus_move:this.requestFocus}),
]
});
this.components.push(this.bookmark_parts);
this.bm_btn.init();
this.btn_top.set_scroll_disable();
if(this.bookmark_num>BOOKMARK_PARTS_ITEM_MAX){
this.btn_btm.set_scroll_enable();}else{
this.btn_btm.set_scroll_disable();}
this.anim_cnt=0
this.anim_30_min=ANIM_30_MIN;
this.anim_1_min=ANIM_1_MIN;
this.anim_cnt_max=this.anim_1_min;
this.cap_update_status=CAPTURE_UPDATETIME_CHECK_WAIT;
this.cap_up_data=new Array();};
gadget.isUseFrame=function(){return false;};
gadget.onFocus=function(is_focused,key,point_env){
if(is_focused){
var ret=false;
if(point_env){
ret=this.onfocus_for_point(point_env,1);}
if(this.confirm_state){
this.confirm_state=false;}
if(!ret){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[0]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,null);
this.cursor_pos=0;}
}
};
gadget.voicePlay=function(){
gadget.set_tts_str(this._getTitle());};
gadget.getStatus=function(){
return {"movable":false,"removable":false};};
gadget.bm_move_up=function(){
if(this.btn_top.scroll_enable){
if(!this.bm_btn.moveTo_state){
this.btn_top.done_focus();
this.bm_btn.up_move();}
return true;}
return false;};
gadget.bm_move_down=function(){
if(this.btn_btm.scroll_enable){
if(!this.bm_btn.moveTo_state){
this.btn_btm.done_focus();
this.bm_btn.down_move();}
return true;}
return false;};
gadget.check_tutorial=function(){
if((this.cursor_pos+this.bm_btn.data_index_top)>this.bookmark_num){
this.confirmpanel_create();
return true;}
return false;};
gadget.key_hook=function(up_down,keysym,pos){
var self=this;
switch(keysym){
case TXK_SCROLL_UP:
case TXK_UP:
if(up_down!=KEY_PRESS)return true;
if(this.cursor_pos>0){
HOME_SOUND_PLAY(0);
this.cursor_pos--;
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,this.end_focus_move);
return true;}else{
if(this.bm_move_up()){
this.voicePlay();
return true;}else
return false;}
case TXK_SCROLL_DOWN:
case TXK_DOWN:
if(up_down!=KEY_PRESS)return true;
if(this.cursor_pos<BOOKMARK_PARTS_ITEM_MAX-1){
HOME_SOUND_PLAY(0);
this.cursor_pos++;
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,this.end_focus_move);
return true;}else{
if(this.bm_move_down()){
this.voicePlay();
return true;}else
return false;}
case TXK_LEFT:
this.cursor_pos=0;
break;
case TXK_ENTER:
if(pos!=undefined){
if(this.cursor_pos!=pos){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,this.end_focus_move);
this.cursor_pos=pos;
return true;}
}
if(up_down!=KEY_PRESS)return true;
delete_timer(this);
return this.check_tutorial();
default:
break;}
return false;};
gadget.point_hook=function (type,identifier,x,y,screenX,screenY){
var ret=this.onfocus_for_point({x:x,y:y},0);
if(ret)return true;

return false;};
gadget.onfocus_for_point=function (point_env,from){
if((point_env.x<-BOOKMARK_PARTS_ITEM_W/2)
||(BOOKMARK_PARTS_ITEM_W/2<point_env.x)){
if(from==0){
return true;}else{
return false;}
}
if((447>=point_env.y)&&(417<=point_env.y)){
this.bm_move_up();}
if((-457>=point_env.y)&&(-487<=point_env.y)){
this.bm_move_down();}
for(var i=0;i<BOOKMARK_PARTS_ITEM_MAX;i++){
if((BOOKMARK_FOCUS_POS[i]+BOOKMARK_PARTS_ITEM_H/2>=point_env.y)
&&(point_env.y>=BOOKMARK_FOCUS_POS[i]-BOOKMARK_PARTS_ITEM_H/2)){
if(this.cursor_pos!=i){
this.cursor_pos=i;
if(from==0){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,
this.end_focus_move);}else{
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,null);}
return true;}else{
return this.check_tutorial();}
}
}
if(from==0){
return true;}else{
return false;}
};
gadget.end_focus_move=function(){
gadget.set_tts_str(gadget._getTitle());};
gadget.set_tts_str=function(title){
if((TTS_SUPPORT)&&(ebus.tts.mode)){
var pos=this.cursor_pos+this.bm_btn.data_index_top-1;
if(pos<this.bookmark_data.bookmarkpanel.length)
VoicePlay((title?title+". ":"")+this.bookmark_data.bookmarkpanel[pos].title);}
};
gadget.destroy=function(){
if(this.components.length==0)return;
for(var i=0,max=this.components.length;i<max;i++){
if(this.components[i] instanceof gtext||
this.components[i] instanceof gtextbox){
setf_text(this.components[i],"");}else if(this.components[i] instanceof gimage){
this.components[i].src="";}else if(typeof this.components[i].destroy=="function"){
this.components[i].destroy();}
}
this.components.splice(0,this.components.length);};
gadget.freeResource=function(bool){
this.bm_btn.freeResource(bool);};
gadget.confirmpanel_create=function(){
var self=this;
var confirmData={
"title":"",
"msg":this.lang("LT_BOOKMARK_MSG"),
"cancel":function(){self.confirmpanel_return_action();},
"button":[
{"label":this.lang("LT_LAUNCH_BROWSER"),"action":function(){self.launchApl_formTutorial();}},
{"label":this.lang("LT_HOME_TUTORIAL"),"action":function(){self.confirmpanel_tutorial_action();}},
{"label":this.lang("LT_PM_RETURN"),"action":function(){self.confirmpanel_return_action();}},
]
};
this.requestConfirmPanelFunc(confirmData);
this.confirm_state=true;};
gadget.confirmpanel_return_action=function(){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,null);};
gadget.confirmpanel_tutorial_action=function(){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,null);
system.guidance.launch_request(system.guidance.LAUNCH_USER_BOOKMARK);};
gadget.launchApl=function(locked_panel,report){
var pos=this.cursor_pos+this.bm_btn.data_index_top-1;
BROWSER_TOU_VERSION=browser_get_version();
if((this.cursor_pos+this.bm_btn.data_index_top)>this.bookmark_num){
weblink.set({"launch_from":weblink.CODE.ICON});
return apputil.launch_apl("0077777700140002",null,locked_panel,report,null,"platinum_main");}else{
var transit=null;
var pre_check="yes";
if(system.mdl_cfg.with_browser_with_tv){
var tou_disp=false;
if(apps_nvram.read("TOU_DISP","home")!=null)
tou_disp=apps_nvram.read("TOU_DISP","home");
var tou_version="0.0";
if(apps_nvram.read("TOU_VER","home")!=null)
tou_version=apps_nvram.read("TOU_VER","home");
if((tou_disp)&&(BROWSER_TOU_VERSION<=tou_version)&&(BROWSER_TOU_VERSION!=null)){
pre_check="no";
if(SHOW_TVINFO){
var tv_x=(11+576/2)-1920/2;
var tv_y=1080/2-(9+324/2)+14;
var tv_height=324-27;
var tv_width=Math.floor(tv_height*16/9);}else {
var tv_x=(11+576/2)-1920/2;
var tv_y=1080/2-(9+324/2);
var tv_width=576;
var tv_height=324;}
if(system.mdl_cfg.with_bp_transit_effect){
transit={
uniq_id:this._uniq_id,
to:{x:tv_x,y:tv_y,width:tv_width,height:tv_height},
from_bookmark:{x:0,y:BOOKMARK_FOCUS_POS[this.cursor_pos],
width:346,height:BOOKMARK_FOCUS_H},
to_bookmark:{x:280,y:-30,width:1280,height:945},
mode:BP_TRANSIT_TO_NAGARA,
bookmark_image:this.bookmark_data.bookmarkpanel[pos].times+"_platinum",
};}
else{
transit=null;}
}
}
weblink.set({"launch_from":weblink.CODE.BOOKMARK,"url":this.bookmark_data.bookmarkpanel[pos].url,
"extra_data":pre_check});
return apputil.launch_apl("0077777700140002",null,locked_panel,report,null,"platinum_main",transit);}
}
gadget.launchApl_formTutorial=function(){
this.requestFocus([BOOKMARK_FOCUS_POS_X,BOOKMARK_FOCUS_POS[this.cursor_pos]+4,0],[BOOKMARK_FOCUS_W,BOOKMARK_FOCUS_H],0,42,null);
this.launchMyself();};
gadget.activate=function(bool){
get_user_profile_id();
if(typeof BROWSER.get_bookmark_data=="function"){
var bookmark_data=BROWSER.get_bookmark_data();
if(DEF_MULTI_USER){
var tmp_data=gadget.get_user_bookmark(USER_PROFILE_ID,bookmark_data);
if(tmp_data){
bookmark_data.bookmarkpanel.length=0;
for(var i in tmp_data.bookmarkpanel){
bookmark_data.bookmarkpanel.push(tmp_data.bookmarkpanel[i]);}
}
if(bool&&tmp_data==null&&USER_PROFILE_ID!=-1){
bookmark_data.bookmarkpanel.length=0;}
}
if(bool&&this.update_check(bookmark_data.bookmarkpanel)){
this.get_nvram_list();
this.bm_btn.update_data();}
}else{
this.get_nvram_list();
if(bool&&this.update_check(this.bookmark_data.bookmarkpanel)){
this.bm_btn.update_data();}
}
}
gadget.get_user_bookmark=function(profile_id,bm_dt){
var profile_name="Bookmark_sort";
var tmp=null;
try{
var nvram_file_list=apps_nvram_file.list({product_id:"home"});
if((nvram_file_list)&&(nvram_file_list.indexOf(profile_name)!=-1)){
tmp=apps_nvram_file.read({"filename":profile_name,async:false,
finished:function(){},product_id:"home"});}
}catch(e){
console_log("[get_user_bookmark]nvram read fail ("+profile_name+"):"+e);
return null;}
if(!tmp)
return null;
tmp=sysutil.tconv.binary_to_string(tmp);
var sort_data=eval(tmp);
var tmp_data={};
tmp_data.bookmarkpanel=[];
var sdt=new Array();
for(var i in sort_data.bookmark){
if(sort_data.bookmark[i].id==profile_id){
sdt=sort_data.bookmark[i].times;
break;}
}
for(var i in sdt){
for(var j in bm_dt.bookmarkpanel){
if(sdt[i]==bm_dt.bookmarkpanel[j].times){
tmp_data.bookmarkpanel.push(bm_dt.bookmarkpanel[j]);
break;}
}
}
return tmp_data;}
gadget.get_nvram_list=function(){
var tmp=null;
var nvram_file_list=apps_nvram_file.list({product_id:"home"});
if((nvram_file_list)&&(nvram_file_list.indexOf("Bookmark")!=-1)){
tmp=apps_nvram_file.read({"filename":"Bookmark",async:false,
finished:function(){},product_id:"home"});}
if(tmp){
tmp=sysutil.tconv.binary_to_string(tmp);
this.bookmark_data=eval(tmp);}else{
this.bookmark_data.bookmarkpanel=[];}
if(DEF_MULTI_USER){
var tmp_data=this.get_user_bookmark(USER_PROFILE_ID,this.bookmark_data);
if(tmp_data){
this.bookmark_data.bookmarkpanel.length=0;
for(var i in tmp_data.bookmarkpanel){
this.bookmark_data.bookmarkpanel.push(tmp_data.bookmarkpanel[i]);}
}
if(tmp_data==null&&USER_PROFILE_ID!=-1){
this.bookmark_data.bookmarkpanel.length=0;}
}
this.bookmark_num=this.bookmark_data.bookmarkpanel.length;}
gadget.animation=function(count){
if(this.bookmark_num==0)return;
this.anim_cnt++;
if(this.anim_cnt==this.anim_cnt_max){
if(this.cap_update_status==CAPTURE_UPDATE_WAIT){
this.get_nvram_list();
this.bm_btn.cap_update(this.cap_up_data,
this.bookmark_data.bookmarkpanel);
this.anim_cnt_max=this.anim_30_min;
this.cap_update_status=CAPTURE_UPDATETIME_CHECK_WAIT;}else{
this.cap_up_data=
this.bm_btn.cap_update_check(this.bookmark_data.bookmarkpanel);
if(this.cap_up_data.length>0){
this.anim_cnt_max=this.anim_1_min;
this.cap_update_status=CAPTURE_UPDATE_WAIT;}else{
this.anim_cnt_max=this.anim_30_min;
this.cap_update_status=CAPTURE_UPDATETIME_CHECK_WAIT;}
}
this.anim_cnt=0;}
this.bm_btn.animation(count);}
gadget.setLocked=function(locked){
if(locked==true&&!this._locked_face){
this._locked_face=new gimage({src:IMG_PATH+"locked.png",
translate:[182,470,0],});
this.components.push(this._locked_face);}
try{
this._locked_face.visible_p=locked;}catch(e){
}
};
gadget.backup_bookmark_data=function(){
this.bookmark_num_bk=this.bookmark_num;
for(var i=0,max=this.bookmark_num;i<max;i++){
this.bookmark_data_bk_update_time[i]=
this.bookmark_data.bookmarkpanel[i].update_time;}
this.profile_id_bk=USER_PROFILE_ID;}
gadget.update_check=function(data){
if(this.bookmark_num_bk!=data.length)return true;
for(var i=0,max=data.length;i<max;i++){
if(this.bookmark_data_bk_update_time[i]!=data[i].update_time){
return true;}
}
if(this.profile_id_bk!=USER_PROFILE_ID){
return true;}
return false;}
return gadget;
