function log(){return null;};
var console_log=log;
var APPLI_ID="0387878700000078";
var plist_path=APPLI_PATH+APPLI_ID+"/Info.plist";
var path=APPLI_PATH+APPLI_ID+"/gadget/";
var png_path=APPLI_PATH+APPLI_ID+"/";
var SCREEN_WIDTH=1920;
var SCREEN_HEIGHT=1080;
try{
SCREEN_WIDTH=system.screen.view_width;
SCREEN_HEIGHT=system.screen.view_height;}catch(e){}
var kbd_path=COMMON_PATH+"keyboard/";
var kbd_skin_path=path+"pkg_keyboard_skin.js";
var kbd_default_skin_path=kbd_path+"pkg_keyboard_skin.js";
add_package_load_path("kbd",kbd_path+"pkg_keyboard.js");
add_package_load_path("textarea",kbd_path+"pkg_textarea.js");
load(path+"tween.js");
var enable_keyhook=false;
var COUNTRY=system.locale.country.substr(0,2);
var LANGUAGE=system.locale.language.substr(0,5);
var USE_TTS=(ebus.tts&&ebus.tts.supported)?true:false;
var brwObj=null;
var loadingEndFlg=false;
var withAnim=false;
var common_key={};
common_key.set_cursor=function(o_obj,cobj){
console_log("[START][common_key.set_cursor]");
this.old=o_obj.cursor;
if(this.old==cobj){
return;}
if(this.old){
if(this.old.leave_focus){
this.old.leave_focus(this.old);}
this.old.in_cursor=false;
this.old.toggle_cursor=false;}
if(cobj){
if(cobj.enter_focus){
cobj.enter_focus(cobj);}else {
}
cobj.in_cursor=true;
}
o_obj.cursor=cobj;
}
var TIMER_RESOLUTION=40;
var MoveTo=function(param){
delete_timer(this);
if(param.func)param.func(this);
this.tmp={};
this.pos_end={};
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.pos_end.x=param.x;
this.pos_end.y=param.y;
this.pos_end.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,TIMER_RESOLUTION,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();});}
var direct_input_area={};
direct_input_area.do_confirm_composition=function(text){
console_log("[direct_input_area][do_confirm_composition]");
setupusr_win.plugin.confirm_composition(text);};
direct_input_area.do_set_composition=function(convert_info){
console_log("[direct_input_area][do_set_composition]");
var info_array=[];
info_array[0]=convert_info[0];
info_array[1]=convert_info[1].h;
info_array[2]=convert_info[1].t;
info_array[3]=convert_info[2];
for(var i=0;i<info_array[3];i++){
info_array.push(convert_info[3+i].h)
info_array.push(convert_info[3+i].t)
if(i==0){
info_array.push(true)
}else {
info_array.push(false)
}
}

setupusr_win.plugin.set_composition.apply(setupusr_win.plugin,info_array);};
direct_input_area.do_cancel_composition=function(){
console_log("[direct_input_area][do_cancel_composition]");
setupusr_win.plugin.cancel_composition();};
direct_input_area.do_move_caret=function(key){
console_log("[direct_input_area][do_move_caret]"+key);
if((key==TXK_LEFT)||(key==TXK_RIGHT)){
setupusr_win.plugin.send_key_event(KEY_DOWN,key);
setupusr_win.plugin.send_key_event(KEY_UP,key);}
};
direct_input_area.do_enter_backspace=function(){
console_log("[direct_input_area][do_enter_backspace]");
setupusr_win.plugin.send_key_event(KEY_DOWN,TXK_RETURN);
setupusr_win.plugin.send_key_event(KEY_UP,TXK_RETURN);};
direct_input_area.do_enter_linefeed=function(){
console_log("[direct_input_area][do_enter_linefeed]");};
direct_input_area.do_enter_allclear=function(){
console_log("[direct_input_area][do_enter_allclear]");
setupusr_win.plugin.send_kbd_event(KEY_DOWN,"A".charCodeAt(0),KBD_MOD_CONTROL_L);
setupusr_win.plugin.send_kbd_event(KEY_UP,"A".charCodeAt(0),KBD_MOD_CONTROL_L);
setupusr_win.plugin.send_key_event(KEY_DOWN,TXK_RETURN);
setupusr_win.plugin.send_key_event(KEY_UP,TXK_RETURN);};
direct_input_area.is_singleline=function(){
console_log("[direct_input_area][is_singleline]");
return true;};
var sft_kbd=new container({visible_p:false});
sft_kbd.create=function(skin_path){
require("kbd");
kbd.set_kbd_skin_path(skin_path);
kbd.set_skin_info({color:"WHITE",size:"LARGE"});
this.kbd_item=kbd.create();
this.components.push(this.kbd_item);
this.kbd_item.set_trg_textarea(this.textarea_trg);
this.kbd_item.set_height_change_callback(this.change_kb_height);
this.kbd_item.set_done_callback(this.done_enter_action);
this.kbd_item.set_cancel_callback(this.cancel_enter_action);
if(ebus&&ebus.kbd&&ebus.kbd.supported){
setupusr.add_event_hook(ebus.kbd,sft_kbd.usb_key_hook);}
if(ebus&&ebus.asr&&ebus.asr.supported){
setupusr.add_event_hook(ebus.asr,sft_kbd.asr_dictation_hook);}
this.height=0;
this.change_kb_height(this.kbd_item.get_height());
this.pos_y=-540+this.height/2;
this.focus_out_mode=false;
this.moveTo=MoveTo;};
sft_kbd.appear=function(param){
var self=this;
this.textarea_trg=param.textarea;
this.done_action_cb=(param.done_cb)?param.done_cb:null;
this.cancel_action_cb=(param.cancel_cb)?param.cancel_cb:null;
sft_kbd.create(param.skin_path);
this.translate[1]=-540-this.height/2;
this.moveTo({x:0,y:-540+this.height/2,z:0.1,end_func:function(){}});
this.visible_p=true;
common_key.set_cursor(setupusr,this);
if(InputDevManager.get_pointer_status()){
InputDevManager.set_move_mode("free");}else {
InputDevManager.set_move_mode("key");}
};
sft_kbd.set_kb_starting_point=function(){
var st_p=this.translate.slice();
st_p[1]+=this.height/2;
st_p[2]=0;
this.kbd_item.set_starting_point(st_p);};
sft_kbd.disappear=function(){
var self=this;
setupusr.del_event_hook(ebus.kbd);
setupusr.del_event_hook(ebus.asr);
this.moveTo({x:0,y:-540-this.height/2,z:0.1,end_func:function(){
self.visible_p=false;
self.free();
self.focus_out_mode=false;}});};
sft_kbd.free=function(){
if(this.components.length==0){
return;}
for(var i=0;i<this.components.length;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(this.components[i] instanceof container){
for(var j=0,max=this.components[i].components.length;j<max;j++){
if(this.components[i].components[j] instanceof gimage){
this.components[i].components[j].src="";}
}
}
if(this.components[i].free)this.components[i].free();}
this.components.splice(0,this.components.length);};
sft_kbd.enter_focus=function(){
common_key.set_cursor(this,this.kbd_item);};
sft_kbd.leave_focus=function(){
common_key.set_cursor(this,null);};
sft_kbd.done_enter_action=function(){
if(sft_kbd.done_action_cb){
sft_kbd.done_action_cb(sft_kbd.kbd_item.getText());}
};
sft_kbd.cancel_enter_action=function(){
if(sft_kbd.cancel_action_cb){
sft_kbd.cancel_action_cb();}
};
sft_kbd.change_kb_height=function(height){
console_log("[sft_kbd.change_kb_height]"+height);
var self=sft_kbd;
self.height=height;
self.translate=[0,-540+self.height/2,0.1];
self.kbd_item.set_translate([0,height/2,0]);
self.pos_y=self.translate[1];
self.set_kb_starting_point();
console_log("[sft_kbd.change_kb_height]"+sft_kbd.translate);};
sft_kbd.key_hook=function(up_down,key){
console_log("[START][sft_kbd.key_hook]");
var ret=false;
if((this.cursor==this.kbd_item)&&(!this.focus_out_mode)){
if((key==TXK_UP)||(key==TXK_DOWN)||(key==TXK_LEFT)||(key==TXK_RIGHT)){
this.kbd_item.set_move_mode("key");}
ret=this.kbd_item.keyhook(up_down,key);}

if(up_down!=KEY_PRESS)return false;
console_log("[ROOT][sft_kbd.key_hook]ret:"+ret);
return ret;};
sft_kbd.usb_key_hook=function(){
console_log("[sft_kbd.usb_key_hook]");
if(InputDevManager.get_pointer_status()){
InputDevManager.pointer_disappear();}
sft_kbd.kbd_item.set_move_mode("key");
return sft_kbd.kbd_item.usb_key_hook(
arguments[0],arguments[1],arguments[2],arguments[3],
arguments[4],arguments[5],arguments[6]
);};
sft_kbd.asr_hook=function(arg){
if(this.kbd_item.asr_hook&&typeof this.kbd_item.asr_hook=="function"){
this.kbd_item.asr_hook(arg);}
};
sft_kbd.asr_dictation_hook=function(stage,device,event){
console_log("[sft_kbd.asr_dication_hook]:"+arguments[3]);
if(event==ebus.asr.ASR_RESULT_EV){
console_log("[sft_kbd.asr_dictaion_hook] ASR_STRING_EV:"+arguments[3]);
if(sft_kbd.visible_p){
sft_kbd.asr_hook(arguments);
return;}
}
};
var InputDevManager={};
InputDevManager.init=function(){
this.move_mode="key";
this.state_point=true;};
InputDevManager.init();
InputDevManager.set_move_mode=function(mode){
if(mode==this.move_mode)return;
if(mode=="free"){
this.pointer_appear();
this.move_mode="free";
this.set_free();}else if(mode=="key"){
this.pointer_disappear();
this.move_mode="key";
this.set_key();}else{
this.pointer_appear();
this.move_mode="hybrid";
this.set_hybrid();}
};
InputDevManager.get_move_mode=function(){
console_log("[InputDevManager.get_move_mode]"+this.move_mode);
return this.move_mode;};
InputDevManager.pointer_appear=function(){
if(system.cursor_pointer){
system.cursor_pointer.set_timeout(0);
system.cursor_pointer.force_show();
this.set_pointer_status(true);}
};
InputDevManager.pointer_disappear=function(){
if(system.cursor_pointer){
system.cursor_pointer.set_timeout(1);
system.cursor_pointer.force_show();
this.set_pointer_status(false);}
};
InputDevManager.set_pointer_status=function(state){
this.state_point=state;};
InputDevManager.get_pointer_status=function(){
return this.pointer_status;};
InputDevManager.set_key=function(){};
InputDevManager.set_free=function(){};
InputDevManager.set_hybrid=function(){};
var kbd_done_hook=function(){
setupusr_win.plugin.send_key_event(KEY_DOWN,TXK_ENTER);
setupusr_win.plugin.send_key_event(KEY_UP,TXK_ENTER);};
var kbd_cancel_hook=function(){
setupusr_win.plugin.send_key_event(KEY_DOWN,TXK_EXIT);
setupusr_win.plugin.send_key_event(KEY_UP,TXK_EXIT);};
var show_keyboard=function(){
sft_kbd.appear(
{
textarea:direct_input_area,
skin_path:kbd_default_skin_path,
done_cb:function(){
kbd_done_hook();},
cancel_cb:function(){
kbd_cancel_hook();}
});};
var hide_keyboard=function(){
sft_kbd.disappear();
common_key.set_cursor(setupusr,null);};
var exit_setupusr=function(){
console_log('EXIT SETUPUSR');
setupusr_win.visible_p=false;
common_effect_out(TXK_RETURN);};
var setupusr_win=new container({visible_p:false});
setupusr_win.create=function(plugin){
this.video0=new container({visible_p:false});
this.translate=[0,0,0];
this.video0.components=[
this.videobox0=new videobox({draw_type:DIRECT,
color:[255,255,255,0],
source:0}),
];
this.components.push(this.video0);
this.window=new gwindow({width:1920,height:1080,translate:[0,0,0],rotation:[0,0,0,1]});
this.components.push(this.window);
this.plugin=plugin;
this.plugin.create("setupusr");
this.plugin.launch({src:"file:///usr/local/setupusr/setupusr.html",
width:SCREEN_WIDTH,
height:SCREEN_HEIGHT,
param:isString(setupusr.launch_args)?setupusr.launch_args:null});
this.window.src=this.plugin.pixmap;}
setupusr_win.destroy=function(){
this.visible_p=false;
this.plugin.discard();
this.window.src=null;
force_redraw();}
setupusr_win.update_video0=function(x,y,width,height){
this.video0.translate[0]=x-(SCREEN_WIDTH/2)+width/2;
this.video0.translate[1]=(SCREEN_HEIGHT/2)-y-height/2;
this.videobox0.width=width;
this.videobox0.height=height;
this.video0.visible_p=true;}
setupusr_win.event_hook=function(){
stg=arguments[0];
obj=arguments[1];
ev=arguments[2];
switch(ev){
case obj.LAUNCH_EV:
obj.paint();
break;
case obj.PAINT_EV:

setupusr_win.visible_p=true;
break;
case obj.VIDEOBOX_EV:
if(arguments[7]==0){
setupusr_win.update_video0(arguments[3],arguments[4],arguments[5],arguments[6]);
console_log('VIDEOBOX_EV:'+arguments[3]+':'+arguments[4]+':'+arguments[5]+':'+arguments[6]);}
break;
case obj.INVOKE_OSK_EV:
show_keyboard();
break;
case obj.DISMISS_OSK_EV:
hide_keyboard();
break;
case obj.CONTENT_EV:
console_log('CONTENT_EV: '+arguments[3]);
switch(arguments[3]){
case 3:exit_setupusr();
break;
case 2:
launch_app_from_setupusr();
break;
case 1:
default:
if(withAnim){
brwObj=obj;
if(loadingEndFlg==='wait')
endLoading();}else {
backImg.visible_p=false;
setupusr_win.visible_p=true;}
}
break;
case obj.EXIT_EV:
console_log('EXIT_EV');
common_effect_out(TXK_RETURN);
break;
case obj.EXIT_FULLSCREEN_EV:
console_log('EXIT_FULLSCREEN');
break;
default:
break;}
}
var loadingObj;
var loadingBoxs=[];
var backImg=new gbox({width:1920,height:1080,color:[0,0,0,255]});
redraw_flg=undefined;
function enter_frame()
{
var i,len;
if(redraw_flg)
{
force_redraw();
redraw_flg=false;}
}
var image_path=path;
var imagePath=[

];
var images;
var imagePos;
var sumbW=480/3;
var sumbH=270/3;
var imageW=376;var imageH=208;var imageMargin=4;
(function(){
var sumbOff=100;
var sumbOffY=80;
var sumbOff2=80;
var sumbOff2Y=60;
var sX=960-350;
var sY=540-250;
var offx=-960+imageW/2;
var offy=540-250-imageH/2;
var margin=imageMargin;
imagePos=[
{s:[-sX,sY,0],
d1:[-sumbOff-10,sumbOffY-30,0],
d2:[offx,offy,0],
rot:-10,
},
{s:[sX,-sY,0],
d1:[sumbOff,-sumbOffY+10,0],
d2:[offx+imageW+margin,offy,0],
rot:-5,
},
{s:[-sX,-sY,0],
d1:[-sumbOff,-sumbOffY+10,0],
d2:[offx+(imageW+margin)*2,offy,0],
rot:10,
},
{s:[sX,sY,0],
d1:[sumbOff-10,sumbOffY-10,0],
d2:[offx+(imageW+margin)*3,offy,0],
rot:3,
},
{s:[-sX,sY,0],
d1:[-sumbOff2+30,sumbOff2Y-5,0],
d2:[offx,offy-imageH-margin,0],
rot:-15,
},
{s:[sX,-sY,0],
d1:[sumbOff2,-sumbOff2Y,0],
d2:[offx+(imageW+margin)*2,offy-imageH-margin,0],
rot:10,
},
{s:[-sX,-sY,0],
d1:[-sumbOff2,-sumbOff2Y+10,0],
d2:[offx+(imageW+margin)*3,offy-imageH-margin,0],
rot:-10,
},
{s:[sX,sY,0],
d1:[sumbOff2-10,sumbOff2Y-10,0],
d2:[offx+(imageW+margin)*2,offy-imageH*2-margin*2,0],
rot:-5,
},
{s:[-sX/2,sY/2,0],
d1:[-sumbOff+50,sumbOffY-60,0],
d2:[offx+(imageW+margin)*3,offy-imageH*2-margin*2,0],
rot:-15,
},
{s:[sX/2,-sY/2,0],
d1:[sumbOff2,-sumbOff2Y,0],
d2:[offx+(imageW+margin)*4,offy,0],
rot:10,
},
{s:[-sX/2,-sY/2,0],
d1:[-sumbOff2,-sumbOff2Y+10,0],
d2:[offx+(imageW+margin)*4,offy-imageH-margin,0],
rot:-10,
},
{s:[sX/2,sY/2,0],
d1:[sumbOff2-30,sumbOff2Y-30,0],
d2:[offx+(imageW+margin)*4,offy-imageH*2-margin*2,0],
rot:5,
},
];}());
var endLoading=function ()
{
var image,param;
var imageObjs=images.components;
for(var i=0;i<imageObjs.length;i++){
image=imageObjs[i];
param={time:0.8,
x:imagePos[i].d2[0],y:imagePos[i].d2[1],
width:imageW,
height:imageH,
rotationr:0,
cola:100,
transition:'easeInQuad'};
if(i==4){
param.width=760;
param.height=424;
param.x=param.x+imageW/2;
param.y=param.y-imageH/2-imageMargin;}
if(i==imageObjs.length-1){
param.onComplete=function(){
images.visible_p=false;
JSTweener.addTween(backImg,{time:0.3,cola:0,
onComplete:function(){
images.components.length=0;
backImg.visible_p=false;
append_timer(brwObj,10,function(obj){delete_timer(obj);});}});
setupusr_win.visible_p=true;};}
JSTweener.addTween(image,param);}
loadingObj.visible_p=false;
loadingObj.components.length=0;
loadingBoxs=null;};
var animImages=function ()
{
var i,image,param;
var imageObjs=images.components;
for(i=0;i<imageObjs.length;i++){
image=imageObjs[i];
param={time:i==0?0.4:0.3,
delay:(i+1)*0.2,
cola:255,
x:imagePos[i].d1[0],y:imagePos[i].d1[1],
transition:'easeOutQuad'};
if(i>6)
param.time=0.2;
if(i==8||i==9)
param.delay=9*0.2;
if(i==10||i==11)
param.delay=10*0.2;
if(i==imageObjs.length-1){
param.onComplete=function(){
if(brwObj){
endLoading();
loadingEndFlg='end';}else {
loadingEndFlg='wait';}
};}
JSTweener.addTween(image,param);}
};
var loadImages=function ()
{
var i,image,param;
for(i=0;i<imagePos.length;i++){
image=new gimage({translate:imagePos[i].s,
width:sumbW,
height:sumbH,
color:[255,255,255,0],
rotation:[imagePos[i].rot,0,0,1],
src:image_path+i+'.jpg'});
images.components.push(image);
if(i==0){
image.onload=animImages;}
}
};
var fadein=function ()
{
var transition='easeOutQuad';
var param;
if(loadingObj.visible_p===false)
return;
for(var i=0;i<loadingBoxs.length;i++){
param={time:0.5,delay:i*0.2,cola:255,width:30,height:30,transition:transition};
if(i===loadingBoxs.length-1){
param.onComplete=function(){fadeout();};}
JSTweener.addTween(loadingBoxs[i],param);}
};
var fadeout=function ()
{
var transition='easeInQuad';
var param;
if(loadingObj.visible_p===false)
return;
for(var i=0;i<loadingBoxs.length;i++){
param={time:0.5,delay:i*0.2,cola:0,width:0,height:0,transition:transition};
if(i===loadingBoxs.length-1){
param.onComplete=function(){fadein();};}
JSTweener.addTween(loadingBoxs[i],param);}
};
var start_loading_animation=function (){

append_timer(this,100,function(obj){delete_timer(obj);
if(redraw_flg!==undefined)
append_timer(obj,50,enter_frame);
loadingObj.translate[2]=1000;
JSTweener.addTween(loadingObj,{time:0.4,y:0,z:0,transition:'easeOutBack'});
JSTweener.addTween(loadingObj.components[0].components[0],{time:0.3,cola:120,transition:'easeOutQuad'});
JSTweener.addTween(loadingObj.components[0].components[1],{time:0.3,cola:255,transition:'easeOutQuad'});
JSTweener.addTween(loadingObj.components[1],
{time:0.4,cola:255,transition:'easeOutQuad',
onComplete:function(){
fadein();
loadImages();}});});};
var getTitle=function (){
var title="setupusr";
http_request({url:plist_path,
sync:true,method:"GET",
onload:function(status,header,body){
try{
if(status==200){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,5)+"=(.*)$","m"))[1];}catch(ex_no_key){
try{
title=body.match(new RegExp("^title."+system.locale.language.substr(0,2)+"=(.*)$","m"))[1];}catch(ex_never_key){
try{
title=body.match(new RegExp("^title=(.*)$","m"))[1];}catch(ex_no_title){
console.log("[setupusr][ERROR] No title in \"Info.plist\".");}
}
}
}else{
console.log("[setupusr]Cannot find \"Info.plist\"");}
}catch(e){
console.log(e.message);}
}
});
return title;}
var makeLoadingObj=function (){
var obj=new container({});
var boxs=new container({});
var box;
var textY=-140;
obj.components.push(new container({
components:[
new gimage({translate:[5,-5,0],
color:[155,155,155,0],
src:png_path+"icon.png",
width:160*1.4,
height:112*1.4}),
new gimage({color:[255,255,255,0],
src:png_path+"icon.png",
width:160*1.2,
height:112*1.2})]
}));
obj.components.push(new gtext({translate:[0,textY,0],
color:[244,244,244,0],
text:getTitle(),
font_size:72,
align:CENTER,
width:1920,
height:100
}));
boxs.translate=[0,textY-80,0];

for(var i=0;i<5;i++){
box=new gbox({translate:[(i-2)*35,0,0],
color:[0x40,0xa3,0xff,0],
width:0,
height:0
});
boxs.components.push(box);
loadingBoxs.push(box);}
obj.components.push(boxs);
return obj;};
var StageShow=function(obj){
console_log("[START][StageShow]");
var data=applink.get();
if(data)
setupusr.launch_args=data.rawdata;
InputDevManager.set_move_mode("key");
if(ebus.mouse)setupusr.add_event_hook(ebus.mouse,mouse_hook);
obj.fg_long=false;
common_key.set_cursor(setupusr,null);
if(!this.bplayer)this.bplayer=new BroadcastPlayer();
this.bplayer.set_browser_mode(BR_SRC_DEFAULT);
this.bplayer.set_browser_mode(BR_SRC_VS);
this.bplayer.disconnect();
setupusr.add_event_hook(ebus.plugin[1],setupusr_win.event_hook);
setupusr_win.create(ebus.plugin[1]);
obj.moveTo=MoveTo;
if(system.effect){
setupusr.add_event_hook(system.effect,effect_hook);}
if(ebus&&ebus.kbd&&ebus.kbd.supported){
setupusr.add_event_hook(ebus.kbd,usb_key_hook);}
enable_keyhook=true;
complete_on_stage(obj);
prepare_package("kbd");
prepare_package("textarea");
console_log("[END][StageShow]");
var with_loading=setupusr_win.plugin.with_loading_anim();
console_log('WITH ANIMATION :'+with_loading);
if(with_loading){
withAnim=true;
loadingObj=makeLoadingObj();
images=new container({});
setupusr.components.push(images);
setupusr.components.push(loadingObj);
start_loading_animation();}
};
var StageHide=function(obj){
setupusr_win.destroy();
discard_package("kbd");
discard_package("textarea");
complete_off_stage(obj);};
var effect_out_key=TXK_RETURN;
var common_effect_out=function(key){
console_log("[common_effect_out]");
effect_out_key=key;
system.effect.fade(system.effect.FADE_OUT);};
var effect_hook=function(stage,obj,event){
console_log("[effect_hook]");
if(event==system.effect.FADE_OUT_END){
if(effect_out_key==TXK_RED){
return true;}
common_out_hook(effect_out_key);
return true;}
return false;};
var common_out_hook=function(key){
console_log("[START][common_out_hook]");
var bplayer=new BroadcastPlayer();
bplayer.set_browser_mode(BR_SRC_DEFAULT);
console_log("video box mode(BR_SRC_DEFAULT)");
this.bplayer.connect();
InputDevManager.set_move_mode("key");
if(key==TXK_RETURN||(key==TXK_EXIT)){
this.visible_p=false;
on_stage("HOME");}else {
this.visible_p=false;
on_stage("HOME");}
system.effect.fade(system.effect.FADE_IN);};
var obutton=0;
var mouse_hook=function(){
if(system.is_menu_launch()||system.is_apps_launch()){
return false;}
var ret=false;
var button=arguments[3];
var mouse_pos_x=system.cursor_pointer.get_pos_x();
var mouse_pos_y=system.cursor_pointer.get_pos_y();

InputDevManager.pointer_appear();
if(sft_kbd.visible_p){
sft_kbd.kbd_item.set_move_mode("free");
ret=sft_kbd.kbd_item.mouse_hook(arguments);}else {
}
obutton=button;
return ret;};
function _convert_TXKB_to_TXK(keysym){
switch(keysym){
case TXKB_Return:return TXK_ENTER;
case TXKB_BackSpace:return TXK_RETURN;
case TXKB_Escape:return TXK_EXIT;
case TXKB_Left:return TXK_LEFT;
case TXKB_Up:return TXK_UP;
case TXKB_Right:return TXK_RIGHT;
case TXKB_Down:return TXK_DOWN;
case TXKB_Page_Up:return TXK_SCROLL_UP;
case TXKB_Page_Down:return TXK_SCROLL_DOWN;
default:return null;}
};
var usb_key_hook=function(){
console_log("[START][usb_key_hook]"+arguments);
if(arguments[2]==ebus.kbd.KEYSYM_EV){
var txk_up_down;
var txk_keysym;
var keysym=arguments[4];
var modifier=arguments[5];
var ret=ebus.kbd.keysym_to_string(TXKB_VoidSymbol,keysym);
switch(arguments[3]){
case KBD_PRESS:
txk_up_down=KEY_PRESS;
break;
case KBD_UP:
txk_up_down=KEY_UP;
break;
case KBD_DOWN:
txk_up_down=KEY_DOWN;
break;
default:
return;}
switch(ret){
case KBD_CONTROLKEY:
txk_keysym=_convert_TXKB_to_TXK(keysym);
if(txk_keysym!=null){
key_hook(txk_up_down,txk_keysym);}
break;
case KBD_DEADKEY:
break;
default:
setupusr_win.plugin.send_kbd_event(txk_up_down,ret.charCodeAt(0),modifier);
break;}
}
};
var key_hook=function(up_down,key){
console_log("[START][key_hook]key:"+key+" state:"+up_down);
if((system.is_menu_launch())||(system.is_apps_launch())){
return false;}
if(up_down==KEY_PRESS){
if((key==TXK_UP)||(key==TXK_DOWN)||(key==TXK_LEFT)||(key==TXK_RIGHT)){
if(InputDevManager.get_pointer_status()){
InputDevManager.pointer_disappear();}
}
}
if(!enable_keyhook)return true;
if((key==TXK_HOME)&&(up_down==KEY_PRESS)){
common_effect_out(TXK_HOME);
return true;}
if((key==TXK_EXIT)&&(up_down==KEY_DOWN)){
common_effect_out(TXK_EXIT);
return false;}
if(sft_kbd.visible_p){
sft_kbd.key_hook(up_down,key);
return true;}
if(backImg.visible_p)return true;
var send_up_down=up_down;
if(up_down==KEY_DOWN){
return true;}else if(up_down==KEY_PRESS){
send_up_down=KEY_DOWN;}
setupusr_win.plugin.send_key_event(send_up_down,key);
return false;}
var setupusr=stage({
"symbol":APPLI_ID,
"in":
[
{
"from":["default"],
"hook":StageShow,
},
],
"out":
[
{
"to":["default"],
"hook":StageHide,
},
],
"bg_image":[
],
"components":[
setupusr_win,
backImg,
sft_kbd,
],
"key_hook":key_hook,
});

