
var APPS_TERMINATE=false;
APPS_BACK_SOLID=(function(){
return true;
if(system.product.indexOf("_4K")>0)return true;
if(system.locale.country=="JP")return true;
return false;})();

APPS_ALPHA=APPS_BACK_SOLID?255:200;
var CONTEXT_SURFER=(system.mdl_cfg.apps_context==system.mdl_cfg.APPS_CONTEXT_SURFER);

if(system.mdl_cfg.apps_context==system.mdl_cfg.APPS_CONTEXT_GSERVER)
{

PATH="file:///usr/local/apps_nv/apps/home/";
COMMON_PATH=PATH+"common/";
PROTOTYPE_PATH=PATH+"prototype/";
IMG_PATH=PATH+"img/";
RESIDENT_IMG_PATH="file:///usr/local/png/";
LANG_PATH=PATH+"lang/";
APPLI_PATH="file:///usr/local/apps_nv/apps/";
SOUND_PATH=PATH+"sound/";
CAMERA_POS=-1661.036724459;
var test_load=function (file){
load(file);}
SU_COUNTRY=system.locale.country;
SU_LANGUAGE=system.locale.language.substr(0,5);
SU_IS_4K=(function (product){
try{
if(product.indexOf("_4K")!=-1){
return true;}else {
return false;}
}catch(e){
return false;}
})(system.product);
system.effect_sound.set_sound(0,SOUND_PATH+"move_focus.aiff");
system.effect_sound.set_sound(5,SOUND_PATH+"enter.aiff");
system.effect_sound.set_sound(7,SOUND_PATH+"cancel.aiff");
var HOME_SOUND_MUTE=false;
try{
var ret=eval(apps_nvram.read("sound_mute","home"));
if(ret==null)ret=false;
HOME_SOUND_MUTE=ret;}catch(e){
console.log("Cannot get Sound Effect Setting.");}
function HomeSoundPlay(id){
try{
if(HOME_SOUND_MUTE==false){
if(id=="enter"){
system.effect_sound.play(5);}else if(id=="cancel"){
system.effect_sound.play(7);}else {
system.effect_sound.play(id);}
}
}catch(e){};}
HOME_SOUND_PLAY=HomeSoundPlay;
try{
test_load(PATH+"util.js");
test_load(PROTOTYPE_PATH+"my_lib.js");
test_load(PROTOTYPE_PATH+"focus.js");}catch(e){console.log("Error = "+e.message);};

add_package_load_path("pkg_password",PROTOTYPE_PATH+"password.js");
add_package_load_path("pkg_confirmpanel",PROTOTYPE_PATH+"confirmpanel.js");
add_package_load_path("json2",COMMON_PATH+"json/json2.js");
LockPasswordPanel=function(action_func,cancel_func,focus_moveto){
require("pkg_password");
LockPasswordPanel=pkg_password.LockPasswordPanel;
return new LockPasswordPanel(action_func,cancel_func,focus_moveto);};
Confirmpanel=function(type,action_func,focus_moveto){
require("pkg_confirmpanel");
Confirmpanel=pkg_confirmpanel.Confirmpanel;
return new Confirmpanel(type,action_func,focus_moveto);};
Confirmpanel.prototype.OPTION_TYPE_OK=0;
Confirmpanel.prototype.OPTION_TYPE_YES_NO=1;
Confirmpanel.prototype.OPTION_TYPE_YES_NO_CANCEL=2;

var lang=SU_LANGUAGE;
try{
if(lang=="zh-00"){
lang="zh-CN";}else if((lang=="en-00")||(lang=="en-CN")){
lang="en-HK";}else if(lang=="en-NZ"){
lang="en-AU";}else if(lang=="es-BR"){
lang="es-AR";}else if((lang=="zh-AU")||(lang=="zh-NZ")||(lang=="zh-US")){
lang="zh-CN";}
test_load(LANG_PATH+"lang_"+lang+".js");}catch(e){
lang=lang.substr(0,2);
try{
test_load(LANG_PATH+"lang_"+lang+".js");}catch(e){
try{
test_load(LANG_PATH+"lang_en-IE.js");}catch(e){
console.log("NO pkg lang ");
test_load(LANG_PATH+"lang_en-US.js");}
}
}
}
try{
AppsPlate;}catch(e){
load(PATH+"apps_prototype/apps_plate.js");}
add_stage_load_path("apps_customize",PATH+"apps_customize.js");
var background=new container({});
background.color=APPS_BACK_SOLID?[220,220,220,255]:[255,255,255,255];
background.components.push(
new gbox({color:system.fdp_color.BASE,
width:1920,height:1080}),
new gimage({src:IMG_PATH+"apps_back_gradation.png",
width:1920,height:1080,draw_type:DIRECT,
color:system.fdp_color.TEXT_SUB_ONBASE,
})
);
background.init=function(){
};
background.setAlpha=function(alpha){

};
background.width=1920;
background.height=1080;
append_functions(background,GraphicsLib);
append_functions(background,AnimationLib);
if(CONTEXT_SURFER==false){
background.TIME_INTERVAL=20;}
if(SU_IS_SLOW_ANIM){
background.transparentTo=AnimationLib.transparentToDirect;}
var edit_back=new gimage({width:1920,height:1080,color:[255,255,255,0],
src:IMG_PATH+"switch_back.png",draw_type:DIRECT,
blend:false});
edit_back.init=function(){
this.color[3]=0;};
append_functions(edit_back,GraphicsLib);
append_functions(edit_back,AnimationLib);
var mkt=null;
if(system.mdl_cfg.with_vc_market==true&&SU_IS_GBL15==false){
mkt=new MarketBanner();
mkt.mkt_icon=null;
mkt.translate[0]=-568-64;}else{
mkt=new container({});
mkt.mkt_icon=1;}
mkt.translate[1]=400-4;
var mkt_budge=new container({translate:[-80,-4,0]});
var budge_1=new container({components:[mkt_budge]});
var budge_2=new container({});
var ad=new AdBanner(IMG_PATH+"default_ad_left.png",-1);
ad.translate[0]=-26-54;
ad.translate[1]=mkt.translate[1];
ad.setAdImage(IMG_PATH+"default_ad_left.png");
ad.showAnim=function(){
if(this.exAd&&(typeof this.exAd.showAnim=="function"))
this.exAd.showAnim.apply(this.exAd,arguments);};
ad.animation=function(){
if(this.exAd&&(typeof this.exAd.animation=="function"))
return this.exAd.animation.apply(this.exAd,arguments);
return false;};
ad.launch_appli=function(){
if(this.exAd&&(typeof this.exAd.launch_appli=="function"))
return this.exAd.launch_appli.apply(this.exAd,arguments);};
ad.getAdInfo=function(func){
this.setText(true);
var onload=function(status,header,body){
if(status==200){
try{
ad.exAd=secure_eval(body);
if(ad.exAd!=null){
ad.components.push(ad.exAd);
if(typeof ad.exAd.init=="function")ad.exAd.init(ad);}
}catch(e){
console.log(e.fileName+":"+e.lineNumber,e.name,e.message);}
}
};
var host=getHostName();
host=host.replace("https://","https://ad_app:u77eEnpqlWDT4jI8@");
http_request({"url":host+"/data/ad_app/ssl/apps_ad.js","method":"GET","sync":false,"onload":onload,});};
var ad2=new AdBanner(IMG_PATH+"default_ad_right.png",-1);
ad2.translate[0]=514-18-47;
ad2.translate[1]=mkt.translate[1];
ad2.setAdImage(IMG_PATH+"default_ad_right.png");
var AnimationManager={};
AnimationManager.count=0;
AnimationManager.animation=function(obj,count){
delete_timer(obj);
obj.count++;
var ret=[false,false,false];
try{
ret[0]=mkt.mkt_icon.animation(mkt.mkt_icon,obj.count);}catch(e){
}
try{
ret[1]=ad.animation(ad,obj.count);}catch(e){
}
try{
ret[2]=ad2.animation(ad2,obj.count);}catch(e){
}
if(ret.some(function(val){return val;})){
force_redraw();
}

AnimationManager.startAnimation(obj.count);
if(obj.count==60){
obj.count=0;
applications.updateIcons();}
};
AnimationManager.startAnimation=function(){
append_timer(this,60,this.animation);}
AnimationManager.pauseAnimation=function(){
delete_timer(this);}
AnimationManager.stopAnimation=function(){
delete_timer(this);
this.count=0;}
var settings=new container({
components:[
new gbox({width:154,height:154,color:system.fdp_color.BTN_BORDER,
round_enable:true,round_width:2,round_height:2}),
new gbox({width:154-4,height:154-4,color:system.fdp_color.BASE}),
new gimage({src:IMG_PATH+"apps_settings.png",blend:true,
color:system.fdp_color.ICON_ONBASE,
width:100,height:76,rotation:[0,0,0,0]}),

]});
settings.width=settings.components[0].width-4;
settings.height=settings.components[0].height-4;
settings.translate[0]=840-7;
settings.translate[1]=418-20;
settings.init=function(){
};
settings.getAngle=function(){
return this.components[0].rotation[0];};
settings.setAngle=function(angle){
this.components[0].rotation[0]=angle;
this.components[1].color[3]=Math.floor(255*(1-angle/90));};
settings.getFocusPosition=function(){
return this.translate;};
settings.getFocusSize=function(){
return [this.width+4,this.height+4];};
settings.launch_appli=function(){
if(system.mdl_cfg.with_smart_lock
&&system.mdl_cfg.is_smart_lock
&&system.mdl_cfg.settings_lock){
return;}
apps.goEdit(true);};
settings.setFocus=function(b){
if(b==true){
apps.PAGE_INDEX=apps_list.getCurrentPage();
prepare_stage("apps_customize");}else{
discard_stage("apps_customize");}
};
append_functions(settings,GraphicsLib);
append_functions(settings,AnimationLib);
if(SU_IS_SLOW_ANIM){
settings.rotate=AnimationLib.rotateDirect;}
if(system.mdl_cfg.with_vc_market==false||SU_IS_GBL15==true){
ad.translate[0]-=302;
ad2.translate[0]-=302;
settings.translate[0]-=134;
if(SU_IS_GBL15==false){
var launch_appli=function(){return false;};
ad.launch_appli=launch_appli;
ad2.launch_appli=launch_appli;
AdBanner.prototype.launch_appli=launch_appli;}
}
var header=new container({
components:[
new gbox({width:1920,height:260,
translate:[0,(1080-260)/2,0],
color:system.fdp_color.BASE}),
new gimage({src:IMG_PATH+"apps_mkt_hilight.png",width:726,height:100,
visible_p:(mkt instanceof MarketBanner),
translate:[-(1920-726)/2,(1080-100)/2,0]}),
mkt,
ad,
ad2,
settings,
]
});
header.cursor=-1;
header.icon=[mkt,ad,ad2,settings];
header.init=function(){
this.translate[1]=260;
this.components.forEach(
function(val,idx,arry){
try{
val.init();}catch(e){
}
});};
header.setFocus=function(b,keysym,col){
if(b==true){
if(col!=undefined)
this.cursor=(function(c){
if(c>3){
return 2;}else if(c<2){
return 0;}else{
return 1;}
})(col);
this.correctFocus();}else{
this.icon[this.cursor].setFocus(false);
switch(this.cursor){
case 0:this.cursor=-1;
return 0;
case 1:this.cursor=-1;
return 2;
case 2:this.cursor=-1;
return 5;
case 3:this.cursor=-1;
return 6;
default:this.cursor=-1;
return 0
}
}
};
if(system.mdl_cfg.with_vc_market==false||SU_IS_GBL15==true){
header.icon.shift();
header.setFocus=function(b,keysym,col){
if(b==true){
if(col!=undefined)
this.cursor=(function(c){
if(c==6){
return 2;}else if(c<3){
return 0;}else{
return 1;}
})(col);
this.correctFocus();}else{
this.icon[this.cursor].setFocus(false);
switch(this.cursor){
case 0:this.cursor=-1;
return 1;
case 1:this.cursor=-1;
return 4;
case 2:this.cursor=-1;
return 6;
default:this.cursor=-1;
return 0
}
}
};}
if(system.mdl_cfg.with_pen_support_startup_ui==true){
var close=new gimage({src:IMG_PATH+"apps_close.png",
width:102,height:76,});
close.translate[0]=-settings.translate[0];
close.translate[1]=settings.translate[1];
close.getFocusSize=settings.getFocusSize;
close.getFocusPosition=settings.getFocusPosition;
close.launch_appli=function(){
apps.setShow(false);};
close.setFocus=function(b){
console.log("close.setFocus() : "+b);};
header.components.unshift(close);header.icon.unshift(close);
if(system.mdl_cfg.with_vc_market==true&&SU_IS_GBL15==false){
header.setFocus=function(b,keysym,col){
if(b==true){
if(col!=undefined)
this.cursor=(function(c){
if(c>4){
return 3;}else if(c<2){
return 1;}else{
return 2;}
})(col);
this.correctFocus();}else{
this.icon[this.cursor].setFocus(false);
switch(this.cursor){
case 1:this.cursor=-1;return 1;
case 2:this.cursor=-1;return 3;
case 3:this.cursor=-1;return 5;
case 4:this.cursor=-1;return 6;
default:this.cursor=-1;return 0;}
}
};}else{
header.setFocus=function(b,keysym,col){
if(b==true){
if(col!=undefined)
this.cursor=(function(c){
if(c==6){
return 3;}else if(c==0){
return 0;}else if(c>=3){
return 2;}else{
return 1;}
})(col);
this.correctFocus();}else{
this.icon[this.cursor].setFocus(false);
switch(this.cursor){
case 1:this.cursor=-1;return 1;
case 2:this.cursor=-1;return 4;
case 3:this.cursor=-1;return 6;
default:this.cursor=-1;return 0;}
}
};}
}
header.key_hook=function(updown,keysym){
if(updown!=KEY_PRESS)return false;
if(this.visible_p==false)return true;
switch(keysym){
case TXK_LEFT:
if(this.cursor<=0){
return false;}
this.icon[this.cursor].setFocus(false,keysym,0);
this.cursor--;
this.correctFocus();
return true;
case TXK_RIGHT:
if(this.cursor==this.icon.length-1){
return false;}
this.icon[this.cursor].setFocus(false,keysym,0);
this.cursor++;
this.correctFocus();
return true;
case TXK_ENTER:
try{
this.icon[this.cursor].launch_appli();
return true;}catch(e){
throw e;
return false;}
default:
}
return false;};
header.point_hook=function (type,identifier,x,y,screenX,screenY){
if(type=="touchmove")return false;
DEBUG.warn("header.point_hook = function (type, identifier, x, y, screenX, screenY){ ");
var pos=null;
var size=null;
var tmp=-1;
for(var i=0;i<this.icon.length;i++){
pos=this.icon[i].getFocusPosition();
size=this.icon[i].getFocusSize();
if(isIN(screenX,screenY,pos,size)==true){
tmp=i;
break;}
}
if(tmp==-1){
return false;}else if(tmp==this.cursor){
if(type=="touchend"){
HOME_SOUND_PLAY("enter");
this.key_hook(KEY_PRESS,TXK_ENTER);
return true;}else{
return false;}
}else{
if(type=="touchstart"){
try{
this.icon[this.cursor].setFocus(false);}catch(e){
}
HOME_SOUND_PLAY(0);
this.cursor=tmp;
this.correctFocus();
return true;}else{
return false;}
}
};
header.correctFocus=function(){
var me=this;
var tra=this.icon[this.cursor].getFocusPosition();
var size=this.icon[this.cursor].getFocusSize();
focus_moveto([tra[0]+this.translate[0],
tra[1]+this.translate[1],
tra[2]+this.translate[2]],
size,null,54,
function(){
me.icon[me.cursor].setFocus(true);});};
header.setShow=function(b){
if(b==true){
this.visible_p=true;
this.slide(1,0,8+2,
function(){

budge_1.visible_p=true;
budge_2.visible_p=true;
append_timer({},500,function(o){
delete_timer(o);
ad.getAdInfo(function(){ad.showAnim(true);});
ad2.getAdInfo(function(){ad2.showAnim(true);});
try{
if(!mkt.mkt_icon){
mkt.getMarketIcon(mkt_budge);}
if(mkt.mkt_budge)mkt.mkt_budge.visible_p=true;
AnimationManager.startAnimation();}catch(e){
if(system.mdl_cfg.with_vc_market==true&&SU_IS_GBL15==false){
DEBUG.error(e.message);}else{
console.log("No Problem");
}
}
});});}else{
this.visible_p=false;
budge_1.visible_p=false;
budge_2.visible_p=false;
ad.showAnim(false);
ad2.showAnim(false);
if(mkt.mkt_budge)mkt.mkt_budge.visible_p=false;
AnimationManager.stopAnimation();}
};
append_functions(header,GraphicsLib);
append_functions(header,AnimationLib);
if(SU_IS_SLOW_ANIM){
header.slide=AnimationLib.slideDirect;}
var apps_list=new AppsPlateOperator(focus_moveto);
apps_list.translate[1]=-196-36;
var recent=new FavoriteList(focus_moveto);
recent.translate[1]=210-26;
var applications=new ApplicationList(recent,apps_list);
applications.init=function(){
ApplicationList.prototype.init.call(this);
this.setSize(1920,1080);
this.setTranslate(0,-860,0);
this.showMarketIcon(true);};
var focus=new Focus();
focus.visible_p=false;
if(CONTEXT_SURFER==false){
applications.TIME_INTERVAL=20;
header.TIME_INTERVAL=20;
focus.ANIMATION_TIME_INTERVAL=20;}
function focus_moveto(pos,size,angle,speed,func){
if(!speed)speed=36;
focus.moveTo(pos,size,angle,Math.max(36*(CONTEXT_SURFER?1:2),speed),func);};
var confirm=new Confirmpanel(Confirmpanel.prototype.OPTION_TYPE_OK,
[
function(){
apps.cursor=apps.old_cursor;
confirm.onFocus(false);
var arg=apps.cur_list[apps.cursor].setFocus(false);
apps.cur_list[apps.cursor].setFocus(true,null,arg);
confirm.setShow(false);}
],
focus_moveto);
confirm.setSize(1080,420);
confirm.translate[2]=0.01;
var unlock=new LockPasswordPanel(
function(){apps.cursor=apps.old_cursor;
unlock.onFocus(false);
apps.cur_list[apps.cursor].setFocus(true,null);
unlock.setShow(false);
try{
budge_1.components=[mkt_budge];
budge_2.components=[];}catch(e){}
apputil.launch_apl(this.product_id,null,"pass",this.report);},
function(){apps.cursor=apps.old_cursor;
unlock.onFocus(false);
apps.cur_list[apps.cursor].setFocus(true,null);
unlock.setShow(false);
try{
budge_1.components=[mkt_budge];
budge_2.components=[];}catch(e){}
},
focus_moveto);
unlock.translate[2]=0.15;
function getApplicationListAsync(func){
var ret=["0387878700000001"];try{
apps_nvram_file.read({
product_id:"home",
filename:"apps_list",
async:true,
finished:function(stage,obj,event,id,result,data){
if((event==obj.READ_EV)&&(result==obj.NO_ERROR)){
ret=eval(sysutil.tconv.binary_to_string(data));}
try{
func(ret);}catch(e){
}
}
});}catch(e){
application_list.addApps(ret);}
};
function getApplicationList(){
try{
return eval(
sysutil.tconv.binary_to_string(
apps_nvram_file.read({product_id:"home",
filename:"apps_list",
async:false,
})));}catch(e){
return ["0387878700000001"];}
};
function default_keyhook(updown,keysym){
if(updown!=KEY_PRESS)return false;

if(APPS_TERMINATE==true)return true;
switch(keysym){
case TXK_HOME:
case TXK_EXIT:
complete_off_stage(this);
discard_stage(this.symbol);
return false;
case TXK_APPS:
case TXK_RETURN:
if(isNumber(this.cursor)){
this.setShow(false,TXK_RETURN);
HOME_SOUND_PLAY("cancel");
return true;}
break;
default:
}
try{
if(isNumber(this.cursor)){
if(this.cur_list[this.cursor].key_hook(updown,keysym)==true){
switch(keysym){
case TXK_UP:
case TXK_DOWN:
case TXK_LEFT:
case TXK_RIGHT:
HOME_SOUND_PLAY(0);
break;
case TXK_ENTER:
HOME_SOUND_PLAY("enter");
break;}
return true;}
}else{
this.cursor.key_hook(updown,keysym);
switch(keysym){
case TXK_D1:case TXK_D2:case TXK_D3:case TXK_D4:case TXK_D5:
case TXK_D6:case TXK_D7:case TXK_D8:case TXK_D9:case TXK_D0:
if(this.cursor===unlock)HOME_SOUND_PLAY("enter");
break;
case TXK_RETURN:
HOME_SOUND_PLAY("cancel");
break;
case TXK_ENTER:
if(this.cursor!==unlock)HOME_SOUND_PLAY("enter");
break;
default:
break;}
return true;}
}catch(e){
var warning=true;
if(keysym==TXK_ENTER){
HOME_SOUND_PLAY("enter");
if(e.message.substr(0,4)=="MSG:"){
confirm.setMessageText(e.message.substr(4));
confirm.setShow(true);
this.old_cursor=this.cursor;
confirm.onFocus(true);
this.cursor=confirm;
warning=false;}else if(e.message.substr(0,5)=="PASS:"){
var id=e.message.substr(5);
unlock.report=e.report;
unlock.product_id=id;
unlock.setShow(true);
try{
budge_1.components=[];
budge_2.components=[mkt_budge];}catch(e){}
this.old_cursor=this.cursor;
unlock.onFocus(true);
this.cursor=unlock;
warning=false;}
}
if(warning==true){
DEBUG.warn("key_hook ["+this.cursor+"] : "+e.message);}
return false;}
var arg=null;
switch(keysym){
case TXK_UP:
if(this.cursor==0){
return false;}
arg=this.cur_list[this.cursor].setFocus(false,keysym);
this.cursor--;
this.cur_list[this.cursor].setFocus(true,keysym,arg);
HOME_SOUND_PLAY(0);
return true;

case TXK_DOWN:
if(this.cursor==this.cur_list.length-1){
return false;}
arg=this.cur_list[this.cursor].setFocus(false,keysym);
this.cursor++;
this.cur_list[this.cursor].setFocus(true,keysym,arg);
HOME_SOUND_PLAY(0);
return true;
default:
}
return false;};
var apps=stage({
symbol:"apps",
translate:[0,0,0],
bg_translate:[0,0,0],
key_hook:function(updown,keysym){
if(updown!=KEY_PRESS)return false;
applications.setTranslate(0,0,0);
header.setTranslate(0,0,0);
this.key_hook=function(){return true;};
append_timer(this,300,function(stg){
delete_timer(stg);
stg.key_hook=default_keyhook;
focus.visible_p=true;});
return true;},
components:[
edit_back,
background,
applications,
header,
budge_2,
confirm,
unlock,
focus,
budge_1,
],
"in":[{from:["default"],
hook:function(stg){
resetInputDev();
HOME_SOUND_PLAY("enter");
this.setShow(true);
LogReport.report(LogReport.OPERATE_HS,"apps.list",{action:"start",pos:"-1"});}
},
{
from:["apps_customize"],
hook:function(stg){
complete_on_stage(this);
this.goEdit(false);
discard_stage("apps_customize");}
}],
"out":[{to:["default"],
hook:function(stg){
}
},
{to:["apps_customize"],
hook:function(stg){
complete_off_stage(stg);}
}],
});
apps.cursor=1;
apps.cur_list=[header,applications];
apps.PAGE_INDEX=0;
apps.goEdit=function(b){
if(b==true){
apps.PAGE_INDEX=apps_list.getCurrentPage();
focus.visible_p=false;
header.setShow(false);
applications.moveTo([240-12,40,0],[1440,810],null,16);
edit_back.transparentTo(255,500);
background.transparentTo(0,800,
function(bg){
try{
on_stage("apps_customize");}catch(e){
apps.goEdit(false);}
});}else{
applications.showRestrictedState(getAdultSetting());
applications.addApps(getApplicationList(),apps.PAGE_INDEX);
focus.visible_p=true;
edit_back.transparentTo(0,800);
background.transparentTo(255,500);
applications.moveTo([0,0,0],[1920,1080],null,20,
function(){
header.init();
header.setShow(true);});}
};
apps.setShow=function(b,key,not_discard){
APPS_TERMINATE=!b;
var stg=this;
if(b==true){
applications.init();
background.init();
header.init();
force_redraw();
complete_on_stage(stg);
background.transparentTo(255,(CONTEXT_SURFER?300:160));
append_timer({},100,function(obj){
delete_timer(obj);
force_redraw();
getApplicationListAsync(function(appslist){
applications.showRestrictedState(getAdultSetting());
applications.addApps(appslist);
applications.slide(1,0,36,
function(){
applications.updateIcons();
apps.key_hook=default_keyhook;
stg.cur_list[stg.cursor].setFocus(true,null,0);});
header.setShow(true);});});}else{
focus.visible_p=false;
header.setShow(false);
applications.slide(1,-860,36,
function(){
if(_GLOBAL_.platinum_main)
if(_GLOBAL_.platinum_main.visible_p)
_GLOBAL_.platinum_main.return_func_from_apps();
if(_GLOBAL_.mystream)
if(_GLOBAL_.mystream.visible_p)
_GLOBAL_.mystream.return_func_from_apps();
try{
complete_off_stage(apps_customize);
discard_stage("apps_customize");}catch(e){
}
complete_off_stage(stg);
if(not_discard!=true){
discard_stage(stg.symbol);}
});}
};
apps.add_event_hook(system.screensaver,
function (stg,obj,ev,data){
switch(ev){
case system.screensaver.NO_OPERATION:
if(data==5)
apps.setShow(false,TXK_RETURN);
break;
default:
break;}
return false;});
apps.add_event_hook(system.apps,
function(stg,obj,ev,product_id){
switch(ev){
case system.apps.WAIT_IP_AVAILABLE:
this.setShow(false,null,true);
return;
case system.apps.APPLI_LAUNCH:
this.setShow(false);
return;
case system.apps.APPLI_LAUNCH_NG:
DEBUG.error("<<APPLI_LAUNCH_NG>> : "+product_id);
return;
case system.apps.REQUEST_TERMINATE_APPS:
if(APPS_TERMINATE==true){
try{
discard_stage("apps_customize");
complete_off_stage(apps_customize);}catch(e){};
try{
discard_stage("apps");
complete_off_stage(apps);}catch(e){};
return;}
HOME_SOUND_PLAY("cancel");
useNumKey(false);
try{
complete_off_stage(apps_customize);}catch(e){
}
discard_stage("apps_customize");
unlock.setShow(false);
confirm.setShow(false);
try{
budge_1.components=[mkt_budge];
budge_2.components=[];}catch(e){}
stg.setShow(false);
force_redraw();
return;
default:
DEBUG.warn("<<system.apps>> : Unknown Event = "+ev);}
}
);
apps.acvtiveTouches=[];
apps.add_event_hook(
ebus.touch,
function(stg,obj,ev_obj){
if(!system.mdl_cfg.with_pen_support_startup_ui)
return true;
for(var i=0;i<ev_obj.changedTouches.length;i++){
var type=ev_obj.type;
var identifier=ev_obj.changedTouches.item(i).identifier;
var screenX=ev_obj.changedTouches.item(i).screenX;
var screenY=ev_obj.changedTouches.item(i).screenY;
if(screenX<-1920/2||screenX>1920/2||screenY<-1080/2||screenY>1080/2){
return;}

if(type!="touchstart"&&!stg.acvtiveTouches[identifier]){
return;}
switch(type){
case "touchstart":
stg.acvtiveTouches[identifier]=true;
break;
case "touchmove":
break;
case "touchend":
case "touchcancel":
stg.acvtiveTouches[identifier]=false;
break;
default:
break;}

if(type=="touchmove")return false;
if(isNumber(stg.cursor)==false){
if(stg.cursor.point_hook(type,identifier,screenX,screenY,screenX,screenY)==true){
if(type=="touchend")HOME_SOUND_PLAY("enter");
return true;}else{
return false;}
}
var target=null;
if(screenY>290){
target=0;applications.resetArrows();}else{
target=1;}
try{
var pos=stg.cur_list[target].getTranslate();
if(stg.cur_list[target].point_hook(type,identifier,screenX-pos[0],screenY-pos[1],screenX,screenY)==true){
if(stg.cursor==target){
}else if(type=="touchstart"){
stg.cur_list[stg.cursor].setFocus(false,-1);
stg.cursor=target;
stg.cur_list[stg.cursor].setFocus(true,-1);}
}
}catch(e){
if(e.message.substr(0,4)=="MSG:"){
confirm.setMessageText(e.message.substr(4));
confirm.setShow(true);
stg.old_cursor=stg.cursor;
confirm.onFocus(true);
stg.cursor=confirm;
}else if(e.message.substr(0,5)=="PASS:"){
var id=e.message.substr(5);
unlock.report=e.report;
unlock.product_id=id;
unlock.setShow(true);
try{
budge_1.components=[];
budge_2.components=[mkt_budge];}catch(e){}
stg.old_cursor=stg.cursor;
unlock.onFocus(true);
stg.cursor=unlock;
}
}
}
}
);
DEBUG.setLevel(2);

