const NULL_FUNCTION=function(){return null;};
try{
if(configure){
console_log("pkg_common configure loaded.");}
}catch(e){
var path=APPLI_PATH+"0077777700140002/gadget/";
add_package_load_path("configure",path+"configure.js");
require("configure");}
var common_key={};
common_key.set_cursor=function(o_obj,cobj){
this.old=o_obj.cursor;
if(this.old==cobj)
{
return;}
if(this.old)
{
if(this.old.leave_focus)
{
this.old.leave_focus(this.old);}
if(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;
this.obj=cobj;
}
function MoveTo(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;
if(!param.angle)param.angle=0;
this.tmp.da=param.angle-this.rotation[0];
this.rotation[0]+=this.tmp.da*this.tmp.rate

force_redraw();
append_timer(this,10,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);

obj.tmp.da=param.angle-obj.rotation[0];
obj.rotation[0]+=obj.tmp.da*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;

obj.rotation[0]=param.angle;
if(typeof param.end_func=="function"){
param.end_func(obj);}
}
force_redraw();});}
function button_item(param){
this.translate=param.translate;
this.rotation=param.rotation;
this.visible_p=param.visible_p;
this.t=param.text;
this.width=param.width?param.width:240;
this.height=param.height?param.height:50;
this.font=param.font?param.font:40;
this.obj=param.obj;
this.clr_text=param.color?param.color:system.fdp_color.TEXT_ONPOINT;
this.focus_offset=param.focus_offset?param.focus_offset:[0,0,0];
this.focus_obj=param.focus_obj;
this.focus_in_cb=param.focus_in_cb?param.focus_in_cb:null;
this.focus_out_cb=param.focus_out_cb?param.focus_out_cb:null;
this.index=param.index;
this.frame=new gbox({width:this.width,height:this.height,translate:[0,0,0],color:[0,0,0,0],
visible_p:false,});
this.focus_obj.visible_p=false;
this.img_btn=new container({
components:[
new gbox({width:this.width,height:this.height,color:system.fdp_color.BTN_BORDER}),
new gbox({translate:[-0.5,0.5,0],width:this.width-1,height:this.height-1,color:system.fdp_color.BTN}),
],
});
this.img_btn_sel=new gimage({width:this.width+2,height:this.height+2,translate:[0,0,0],
visible_p:false,draw_type:DIRECT,src:"",visible_p:false,});
this.text=new gtext({translate:[0,3,0.1],width:this.width-20,font_size:this.font,align:CENTER,
text:this.t,color:this.clr_text,visible_p:true,});
this.components=[this.frame,this.img_btn,this.img_btn_sel,this.text];
if(get_text_width(this.text,this.t)>this.text.width){
for(var i=this.font;i>14;i-=2){
this.text.font_size=i;
if(get_text_width(this.text,this.t)<=this.text.width){
break;}
}
setf_text(this.text,this.t);}
}
button_item.prototype=new container({});
button_item.prototype.enter_in_action=function (){
this.img_btn_sel.visible_p=true;
}
button_item.prototype.enter_out_action=function (){
}
button_item.prototype.enter_focus=function (){
this.img_btn_sel.visible_p=true;
var self=this;
this.focus_obj.moveTo({x:this.translate[0]+this.obj.translate[0]+this.focus_offset[0],
y:this.translate[1]+this.obj.translate[1]+this.focus_offset[1],
z:this.translate[2]+this.obj.translate[2]+1+this.focus_offset[2],
w:this.frame.width,h:this.frame.height,
end_func:function(){}
});
this.focus_obj.appear();
}
button_item.prototype.leave_focus=function (){
this.img_btn_sel.visible_p=false;
if(this.focus_out_cb)this.focus_out_cb();
}
button_item.prototype.set_font_color=function (color){
this.text.color=color;
}
button_item.prototype.free=function (){
this.img_btn_sel.src="";
setf_text(this.text,"");
this.components.splice(0,this.components.length);
}
function text_item(param){
this.translate=param.translate;
this.visible_p=param.visible_p?param.visible_p:true;
this.input_text=param.text?param.text:"";
this.width=param.width?param.width:240;
this.height=param.height?param.height:50;
this.mode=param.mode?param.mode:0;
this.font=param.font?param.font:40;
this.obj=param.obj;
this.frame_color=param.bg_color?param.bg_color:system.fdp_color.TEXT_ONPOINT;
this.clr_text=param.color?param.color:system.fdp_color.BASE;
this.focus_offset=param.focus_offset?param.focus_offset:[0,0,0];
this.focus_obj=param.focus_obj;
this.index=param.index;
this.frame=new gbox({width:this.width,height:this.height,
translate:[0,0,0],color:this.frame_color,});
this.text=new gtext({translate:[0,3,0.1],width:this.width-20,
font_size:this.font,text:this.input_text,color:this.clr_text,omitter:"...",});
this.components=[this.frame,this.text];
this.focus_obj.visible_p=false;
}
text_item.prototype=new container({});
text_item.prototype.set_text=function (text){
this.input_text=text;
var work="";
if(this.mode!=0){
for(var i=0;i<text.length;i++){
work+="*"
}
}else{
work=text;}
setf_text(this.text,work);
}
text_item.prototype.get_text=function (){
return this.input_text;
}
text_item.prototype.enter_focus=function (){
var self=this;
this.focus_obj.moveTo({
x:this.translate[0]+this.obj.translate[0]+this.focus_offset[0],
y:this.translate[1]+this.obj.translate[1]+this.focus_offset[1],
z:this.translate[2]+this.obj.translate[2]+1+this.focus_offset[2],
w:this.frame.width,h:this.frame.height,});
this.focus_obj.appear();
}
text_item.prototype.leave_focus=function (){
}
text_item.prototype.free=function (){
setf_text(this.text,"");
this.components.splice(0,this.components.length);
}
var left_load_flg=false;
var right_load_flg=false;
var middle_load_flg=false;
function popup_panel(){
this.visible_p=false;
left_load_flg=false;
right_load_flg=false;
middle_load_flg=false;

this.img_bg_l=new gbox({width:50,height:0,color:system.fdp_color.POP});
this.img_bg_r=new gbox({width:50,height:0,color:system.fdp_color.POP});
this.img_bg_m=new gbox({width:0,height:0,color:system.fdp_color.POP});
this.message=new gtextbox({color:system.fdp_color.TEXT_ONBASE,valign:MIDDLE,});
this.title=new gtext({font_size:36,font_name:"F015T-bold",color:system.fdp_color.TEXT_ONBASE});
this.components=[this.img_bg_l,this.img_bg_r,this.img_bg_m,this.title,this.message];
this.ary_btn=new Array();
this.move_to=MoveTo;
}
popup_panel.prototype=new container({});
popup_panel.prototype.appear=function(param){
var self=this;
this.st_translate=param.st_translate?
param.st_translate:[param.translate[0],param.translate[1],param.translate[2]];
this.translate=eval(this.st_translate.toSource());
this.rotation[0]=-180;
this.message_text=param.text?param.text:"";
this.return_cb=param.return_cb?param.return_cb:function(){};
this.focus_obj=param.focus_obj?param.focus_obj:function(){};
this.focus_offset=param.focus_offset?param.focus_offset:0;
this.width=param.width?param.width:950;
this.height=param.height?param.height:500;
this.offset_text=param.offset_text?param.offset_text:0;
this.offset_text_w=param.offset_text_w?param.offset_text_w:0;
this.offset_text_h=param.offset_text_h?param.offset_text_h:0;
this.btn_offset=param.btn_offset?param.btn_offset:0;
this.text_font_size=param.text_font_size?param.text_font_size:32;
this.btn_num=param.btn_text.length;
this.pos_current=param.cur_pos?param.cur_pos:0;

this.img_bg_l.height=this.height;
this.img_bg_l.translate[0]=-this.width/2+25;

this.img_bg_r.height=this.height;
this.img_bg_r.translate[0]=this.width/2-25;

this.img_bg_m.height=this.height;
this.img_bg_m.width=this.width-100;
this.img_bg_m.translate=[0,0,0];
this.title.width=this.width-120+this.offset_text_w;
this.title.translate[1]=this.height/2-65;
this.message.width=this.width-120+this.offset_text_w;
this.message.height=get_text_font_height(this.message,this.message_text)+20;
this.message.translate[1]=this.title.translate[1]-this.message.height/2-60;
this.message.font_size=this.text_font_size;
setf_text(this.message,this.message_text);

setf_text(this.title,param.title);

for(var i=0;i<this.btn_num;i++){
this.ary_btn[i]=new button_item({translate:[0,0,0],
font_size:40,text:param.btn_text[i],obj:this,focus_obj:this.focus_obj,
visible_p:true,index:i,});
this.ary_btn[i].cb=param.btn_cb[i];
this.ary_btn[i].action=function(obj){
self.disappear(obj.cb);}
this.ary_btn[i].mouseover=function(obj){
if(self.pos_current!=obj.index){
self.pos_current=obj.index;
common_key.set_cursor(self,obj);}else{
obj.enter_focus();}
}
this.ary_btn[i].mouseout=function(obj){
}
this.components.push(this.ary_btn[i]);}
if(this.btn_num==1){
this.ary_btn[0].translate=[0,-60+this.btn_offset,0];}else if(this.btn_num==2){
this.ary_btn[0].translate=[-140,-60+this.btn_offset,0];
this.ary_btn[1].translate=[140,-60+this.btn_offset,0];}
this.visible_p=true;
this.fg_done=false;
this.move_to({x:param.translate[0],y:param.translate[1],z:param.translate[2],angle:0,
end_func:param.appear_cb,count:20});
}
popup_panel.prototype.disappear=function(cb,sync){
var self=this;
this.focus_obj.disappear();
if(sync){
self.visible_p=false;
for(var i=0;i<self.btn_num;i++){
self.ary_btn[i].free();}
self.components.splice(self.components.length-self.btn_num,self.btn_num);
if(cb)cb();
}else{
this.move_to({x:this.st_translate[0],y:this.st_translate[1],z:0,angle:-90,
end_func:function(){
self.visible_p=false;
for(var i=0;i<self.btn_num;i++){
self.ary_btn[i].free();}
self.components.splice(self.components.length-self.btn_num,self.btn_num);
if(cb)cb();
},count:15});}
}
popup_panel.prototype.free=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="";}
if(this.components[i].free)this.components[i].free();}
this.components.splice(0,this.components.length);}
popup_panel.prototype.enter_focus=function (){
common_key.set_cursor(this,this.ary_btn[this.pos_current]);
delete_timer(this.focus_obj);
this.focus_obj.placeTo(this.cursor.translate[0]+this.translate[0],
this.cursor.translate[1]+this.translate[1],
this.cursor.translate[2]+this.translate[2]+0.1,
this.cursor.frame.width,this.cursor.frame.height,this.cursor.frame.rotation[0]);
this.focus_obj.appear();
}
popup_panel.prototype.leave_focus=function (){
}
popup_panel.prototype.key_hook=function(up_down,key){
if(up_down==KEY_DOWN)this.fg_done=true;
if((up_down!=KEY_UP)||(!this.fg_done))return true;
this.fg_done=false;

switch(key){
case TXK_RETURN:
this.disappear(this.return_cb);
return true;
break;
case TXK_ENTER:
this.disappear(this.cursor.cb);
return true;
break;
case TXK_UP:
case TXK_DOWN:
break;
case TXK_LEFT:
if(this.pos_current>0){
this.pos_current--;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;
case TXK_RIGHT:
if(this.pos_current<this.btn_num-1){
this.pos_current++;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;}
}
popup_panel.prototype.get_btn_obj=function (){
var obj=[];
for(var i=0;i<this.ary_btn.length;i++){
obj[i]=this.ary_btn[i];}
return obj;}
function common_popup_button_item(param){
this.translate=param.translate;
this.rotation=param.rotation;
this.visible_p=param.visible_p;
this.t=param.text;
this.width=param.width?param.width:220;
this.height=param.height?param.height:50;
this.font=param.font?param.font:32;
this.obj=param.obj;
this.clr_text=param.color?param.color:system.fdp_color.BASE;
this.focus_offset=param.focus_offset?param.focus_offset:[0,0,0];
this.focus_obj=param.focus_obj;
this.focus_in_cb=param.focus_in_cb?param.focus_in_cb:null;
this.focus_out_cb=param.focus_out_cb?param.focus_out_cb:null;
this.index=param.index;
this.frame=new gbox({width:this.width-10,height:this.height-12,translate:[0,0,0],color:[0,0,0,0],
visible_p:false,});
this.focus_obj.visible_p=false;
this.img_btn=new container({
components:[
this.btn_image_c=new gbox({width:this.width,height:this.height,
color:system.fdp_color.BTN_BORDER}),
this.btn_image_c2=new gbox({translate:[-0.5,0.5,0],width:this.width-1,height:this.height-1,
color:system.fdp_color.BTN}),
],
});
this.img_btn_sel=new gimage({width:this.width+2,height:this.height+2,translate:[0,0,0],
visible_p:false,draw_type:DIRECT,src:"",visible_p:false,});
this.text=new gtext({translate:[0,3,0.1],width:this.width-20,font_size:this.font,align:CENTER,
text:this.t,color:system.fdp_color.TEXT_ONBASE,visible_p:true,});
this.components=[this.frame,this.img_btn,this.img_btn_sel,this.text];
if(get_text_width(this.text,this.t)>this.text.width){
for(var i=this.font;i>14;i-=2){
this.text.font_size=i;
if(get_text_width(this.text,this.t)<=this.text.width){
break;}
}
setf_text(this.text,this.t);}
}
common_popup_button_item.prototype=new container({});
common_popup_button_item.prototype.enter_in_action=function (){
this.img_btn_sel.visible_p=true;
}
common_popup_button_item.prototype.enter_out_action=function (){
}
common_popup_button_item.prototype.enter_focus=function (){
this.img_btn_sel.visible_p=true;
var self=this;
this.focus_obj.moveTo({x:this.translate[0]+this.obj.translate[0]+this.focus_offset[0],
y:this.translate[1]+this.obj.translate[1]+this.focus_offset[1],
z:this.translate[2]+this.obj.translate[2]+1+this.focus_offset[2],
w:this.frame.width,h:this.frame.height,
end_func:function(){}
});
this.focus_obj.appear();
}
common_popup_button_item.prototype.leave_focus=function (){
this.img_btn_sel.visible_p=false;
if(this.focus_out_cb)this.focus_out_cb();
}
common_popup_button_item.prototype.set_font_color=function (color){
this.text.color=color;
}
common_popup_button_item.prototype.free=function (){
this.btn_image_c.src="";
this.btn_image_c2.src="";
this.img_btn.components.splice(0,this.img_btn.components.length);
this.img_btn_sel.src="";
setf_text(this.text,"");
this.components.splice(0,this.components.length);
}
function common_popup_panel(){
this.visible_p=false;
this.state_animation=false;
this.img_panel=new gbox({width:0,height:0,color:system.fdp_color.POP_A});
this.message=new gtextbox({color:system.fdp_color.TEXT_ONBASE,valign:MIDDLE,});
this.title=new gtext({font_size:36,font_name:"F015T-bold",color:system.fdp_color.TEXT_ONBASE,});
this.components=[this.img_panel,this.title,this.message];
this.size_ary_base_parts=this.components.length;
this.ary_btn=new Array();
this.move_to=MoveTo;
}
common_popup_panel.prototype=new container({});
common_popup_panel.prototype.appear=function(param){
var self=this;
this.st_translate=param.st_translate?
param.st_translate:[param.translate[0],param.translate[1],param.translate[2]];
this.translate=eval(this.st_translate.toSource());
this.rotation[0]=-180;
this.message_text=param.text?param.text:"";
this.return_cb=param.return_cb?param.return_cb:function(){};
this.focus_obj=param.focus_obj?param.focus_obj:function(){};
this.focus_offset=param.focus_offset?param.focus_offset:0;
this.focus_force_set=param.focus_force_set?param.focus_force_set:false;
this.width=param.width?param.width:950;
this.height=param.height?param.height:500;
this.offset_text=param.offset_text?param.offset_text:0;
this.offset_text_w=param.offset_text_w?param.offset_text_w:0;
this.offset_text_h=param.offset_text_h?param.offset_text_h:0;
this.offset_btn_x=param.offset_btn_x?param.offset_btn_x:0;
this.offset_btn_y=param.offset_btn_y?param.offset_btn_y:0;
this.text_font_size=param.text_font_size?param.text_font_size:32;
this.btn_num=param.btn_text?param.btn_text.length:0;
this.pos_current=param.cur_pos?param.cur_pos:0;
this.delete_time=param.delete_time?param.delete_time:0;
this.btn_place=param.btn_place?param.btn_place:"";

this.img_panel.width=this.width;
this.img_panel.height=this.height;
this.img_panel.color=system.fdp_color.POP_A;
this.message.color=system.fdp_color.TEXT_ONBASE;
this.title.color=system.fdp_color.TEXT_ONBASE;
this.title.width=this.width-120+this.offset_text_w;
this.title.translate[1]=this.height/2-65;
this.message.width=this.width-120+this.offset_text_w;
this.message.height=get_text_font_height(this.message,this.message_text)+20;
this.message.translate[1]=this.title.translate[1]-this.message.height/2+this.offset_text_h;
this.message.font_size=this.text_font_size;
setf_text(this.message,this.message_text);
setf_text(this.title,param.title);

for(var i=0;i<this.btn_num;i++){
this.ary_btn[i]=new common_popup_button_item({translate:[0,0,0],
font_size:32,text:param.btn_text[i],obj:this,focus_obj:this.focus_obj,
visible_p:true,index:i,});
this.ary_btn[i].cb=param.btn_cb[i];
this.ary_btn[i].action=function(obj){
self.disappear(obj.cb);}
this.ary_btn[i].mouseover=function(obj){
if(self.focus_force_set){
if(!self.focus_obj.visible_p){
self.pos_current=obj.index;
common_key.set_cursor(self,obj);}
}else{
if(!self.focus_obj.visible_p)return;
if(self.pos_current!=obj.index){
self.pos_current=obj.index;
common_key.set_cursor(self,obj);}else{
obj.enter_focus();}
}
}
this.ary_btn[i].mouseout=function(obj){
if(self.focus_force_set){
if(self.focus_obj.visible_p){
common_key.set_cursor(self,null);
self.focus_obj.disappear();}
}
}
this.components.push(this.ary_btn[i]);}
if(this.btn_num==1){
this.ary_btn[0].translate=[0,-60+this.offset_btn_y,0];}else if(this.btn_num==2){
if(this.btn_place=="vertical"){
this.ary_btn[0].translate=[this.offset_btn_x,this.offset_btn_y,0];
this.ary_btn[1].translate=[this.offset_btn_x,this.offset_btn_y-50,0];}else{
this.ary_btn[0].translate=[-150+(-this.offset_btn_x),-60+this.offset_btn_y,0];
this.ary_btn[1].translate=[150+this.offset_btn_x,-60+this.offset_btn_y,0];}
}else{
if(this.btn_place=="vertical"){
for(var i=0;i<this.btn_num;i++){
this.ary_btn[i].translate=[this.offset_btn_x,this.offset_btn_y-50*i,0];}
}
}
this.visible_p=true;
this.fg_done=false;
this.state_animation=false;
this.move_to({x:param.translate[0],y:param.translate[1],z:param.translate[2],angle:0,
end_func:function(){
param.appear_cb();
if(self.delete_time!=0){
delete_timer(self);
append_timer(self,self.delete_time,function (obj,count){
delete_timer(self);
self.disappear(self.return_cb);});}
},count:20});
}
common_popup_panel.prototype.disappear=function(cb,sync){
if(this.state_animation)return;
var self=this;
this.focus_obj.disappear();
this.focus_force_set=false;
var def_comp_col=new Array();
var def_btn_col=new Array();
if(sync){
self.visible_p=false;
for(var i=0;i<self.btn_num;i++){
self.ary_btn[i].free();}
self.ary_btn.splice(0,self.btn_num);
self.components.splice(self.size_ary_base_parts);
if(cb)cb();
}else{
this.state_animation=true;
delete_timer(this);
append_timer(this,50,function (obj,count){
var alpha=30;
for(var i=0,max=self.components.length-self.btn_num;i<max;i++){
var comp_color=[self.components[i].color[0],
self.components[i].color[1],
self.components[i].color[2],
self.components[i].color[3]-alpha];
self.components[i].color=comp_color;}
for(var j=0;j<self.btn_num;j++){
var btn_color=[self.ary_btn[j].btn_image_c.color[0],
self.ary_btn[j].btn_image_c.color[1],
self.ary_btn[j].btn_image_c.color[2],
self.ary_btn[j].btn_image_c.color[3]-alpha];
self.ary_btn[j].btn_image_c.color=btn_color;
if(self.ary_btn[j].btn_image_c2){
btn_color=[self.ary_btn[j].btn_image_c2.color[0],
self.ary_btn[j].btn_image_c2.color[1],
self.ary_btn[j].btn_image_c2.color[2],
self.ary_btn[j].btn_image_c2.color[3]-alpha];
self.ary_btn[j].btn_image_c2.color=btn_color;}
btn_color=[self.ary_btn[j].img_btn_sel.color[0],
self.ary_btn[j].img_btn_sel.color[1],
self.ary_btn[j].img_btn_sel.color[2],
self.ary_btn[j].img_btn_sel.color[3]-alpha];
self.ary_btn[j].img_btn_sel.color=btn_color;
btn_color=[self.ary_btn[j].text.color[0],
self.ary_btn[j].text.color[1],
self.ary_btn[j].text.color[2],
self.ary_btn[j].text.color[3]-alpha];
self.ary_btn[j].text.color=btn_color;}
force_redraw();
if(count>8){
delete_timer(self);
self.visible_p=false;
for(var k=0,max=self.components.length-self.btn_num;k<max;k++){
self.components[k].color[3]=255;}
for(var m=0;m<self.btn_num;m++){
self.ary_btn[m].free();}
self.ary_btn.splice(0,self.btn_num);
self.components.splice(self.size_ary_base_parts);
if(cb)cb();
self.state_animation=false;}
});}
}
common_popup_panel.prototype.free=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="";}
if(this.components[i].free)this.components[i].free();}
this.components.splice(0,this.components.length);}
common_popup_panel.prototype.enter_focus=function (){
common_key.set_cursor(this,this.ary_btn[this.pos_current]);
delete_timer(this.focus_obj);
this.focus_obj.placeTo(this.cursor.translate[0]+this.translate[0],
this.cursor.translate[1]+this.translate[1],
this.cursor.translate[2]+this.translate[2]+0.1,
this.cursor.frame.width,this.cursor.frame.height,this.cursor.frame.rotation[0]);
this.focus_obj.appear();
}
common_popup_panel.prototype.leave_focus=function (){
}
common_popup_panel.prototype.key_hook=function(up_down,key){
if(up_down==KEY_DOWN)this.fg_done=true;
if((up_down!=KEY_UP)||(!this.fg_done))return true;
this.fg_done=false;
switch(key){
case TXK_RETURN:
if(this.btn_place=="vertical")
this.disappear(this.return_cb,true);
else
this.disappear(this.return_cb);
return true;
break;
case TXK_ENTER:
if(this.btn_place=="vertical")
this.disappear(this.cursor.cb,true);
else
this.disappear(this.cursor.cb);
return true;
break;
case TXK_UP:
if(this.btn_place!="vertical")break;
if(!this.focus_obj.visible_p)break;
if(this.pos_current>0){
this.pos_current--;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;
case TXK_DOWN:
if(this.btn_place!="vertical")break;
if(!this.focus_obj.visible_p)break;
if(this.pos_current<this.btn_num-1){
this.pos_current++;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;
case TXK_LEFT:
if(this.btn_place=="vertical")break;
if(!this.focus_obj.visible_p)break;
if(this.pos_current>0){
this.pos_current--;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;
case TXK_RIGHT:
if(this.btn_place=="vertical")break;
if(!this.focus_obj.visible_p)break;
if(this.pos_current<this.btn_num-1){
this.pos_current++;
common_key.set_cursor(this,this.ary_btn[this.pos_current]);}
break;}
}
common_popup_panel.prototype.get_btn_obj=function (){
var obj=[];
for(var i=0;i<this.ary_btn.length;i++){
obj[i]=this.ary_btn[i];}
return obj;}
smapho_listener={};
smapho_listener.start=function(){
if(PLATINUM_BOOT_OPTION){
if(PLATINUM_BOOT_OPTION.launch_from==2){
smapho_listener.connect(0);
require("pkg_browser");}else{
smapho_listener.connect(0);
if((PLATINUM_BOOT_OPTION.launch_from!=0)&&(!NAGARA_LAUNCH)){
require("pkg_browser");}
}
}else{
smapho_listener.connect(0);}
};
smapho_listener.connect=function(session_id){
var message=["vc_app:"+session_id+":resource_id=1063:platinum"];
console_log("message:"+message);
if(ebus.smartphone){
console_log("smartphone ok");
this.smapho=new ebus.smartphone.Listener();
try{
this.smapho.recv_hook=this.recv_hook;
this.smapho.connect();
this.smapho.send({
"action":this.smapho.ACTION_RUNNOTIFY,
"req_ack":this.smapho.REQ,
"result":this.smapho.RESULT_REQUEST,
"message":message,
"message_length":message.length});
console_log("[smapho_listener.connect]"+message);}catch(e){
console_log("[smapho_listener.connect]smapho error:"+e);
this.smapho=null;}
}
};
smapho_listener.recv_hook=function(session_id){
var self=smapho_listener;
var event=arguments[2];
var action=arguments[3];
var result=arguments[5];
var data=arguments[6];
console_log("[ROOT][smapho_listener.recv_hook]event  = "+event);
console_log("[ROOT][smapho_listener.recv_hook]action  = "+action);
console_log("[ROOT][smapho_listener.recv_hook]result  = "+result);
if(event!=self.smapho.RECEIVED_EV){
self.smapho=null;
return;}
if((result!=0x00)&&(result!=0x01)){
console_log("[ROOT][smapho_listener.recv_hook]NG");
try{
if((result==0xf1)||(result==0xf2)){
self.smapho.disconnect();}else{
self.send_error({act:action,sdata:""});}
}catch(e){
console_log("[ROOT][smapho_listener.recv_hook]error:"+e);}
self.smapho=null;
return;}
console_log("[ROOT][smapho_listener.recv_hook]data length  = "+data.length);
if(data.length!=0){
for(i=0;i<data.length;i++)
console_log("data["+i+"]  = "+data[i]);}
try{
if(action==self.smapho.ACTION_CONNECT){
var message=["HTML5 web browser "+VERSION];
self.smapho.send({
"action":self.smapho.ACTION_CONNECT,
"req_ack":self.smapho.ACK,
"result":self.smapho.RESULT_SUCCESS,
"message":message,
"message_length":message.length});
if(data.length!=0){
socket_mgr.connect(data[1]);}
}else if(action==self.smapho.ACTION_QUERY){
console_log("[ROOT][smapho_listener.recv_hook]query:"+data+"a");
if(data[0].charCodeAt(data[0].length-1)==0)
data[0]=data[0].slice(0,data[0].length-1);
if(data[0]=="TITLE"){
console_log("[ROOT][smapho_listener.recv_hook]query:"+data[0]);
if(self.event_hook)self.event_hook(QUERY_TITLE);}else{
console_log("[ROOT][smapho_listener.recv_hook]query error");
try{
var sdata=["error"];
self.send_error({act:self.smapho.ACTION_QUERY,sdata:sdata});
console_log("[ROOT][smapho_listener.recv_hook]query error send");}catch(e){
console_log("[ROOT][smapho_listener.recv_hook]ack error");}
}
}
}catch(e){
console_log("[ROOT][smapho_listener.recv_hook]ack error");}
};
smapho_listener.send_error=function(param){
this.smapho.send({
"action":param.act,
"req_ack":this.smapho.ACK,
"result":this.smapho.RESULT_ERROR,
"message":param.sdata});};
smapho_listener.add_event_hook=function(event_hook){
this.event_hook=event_hook;};
smapho_listener.send_query=function(ev,data){
switch(ev){
case QUERY_TITLE:
var message=["no title"];
if(data)message[0]=data;
this.smapho.send({
"action":this.smapho.ACTION_QUERY,
"req_ack":this.smapho.ACK,
"result":this.smapho.RESULT_SUCCESS,
"message":message,
"message_length":message.length});
break;
default:
break;}
};
smapho_listener.close=function(){
if(smapho_listener.smapho)smapho_listener.smapho.disconnect();};
socket_mgr={};
socket_mgr.init=function(){
this.data=null;
this.obj=null;
this.smapho_req=false;
this.smapho_add_bookmark=false;
this.event_hook=null;};
socket_mgr.connect=function(data){
this.data=data;
console_log("[socket_mgr.connect]");
if(BROWSER_READY){
console_log("browser standby ok");
try{
var sdata=new Array();
sdata=this.data.split(":");
this.obj=new socket();
this.obj.open({"sock_type":this.obj.SOCK_TYPE_TCP});
this.obj.connect_hook=this.connect_hook;
this.obj.connect({"host":sdata[0],
"port":sdata[1],
"timeout":5000,
"async":true
});
this.data=null;}catch(e){
console_log("socket connect error:"+e);}
}else{
console_log("not browser standby");}
};
socket_mgr.connect_hook=function(data){
var obj=arguments[1];
var result=arguments[2];
console_log("[socket_mgr.connect_hook]result->"+result);
if(result==obj.CONNECTED_EV){
console_log("[socket_mgr.connect_hook]ok");
obj.recv_hook=socket_mgr.recv_header_hook;
ret=obj.recv({"size":8,
"waitall":true,
"async":true,
"timeout":30000});}else if(result==obj.ERROR_EV){
console.log("[socket_mgr.connect_hook]error");}else if(result==obj.RESULT_TIMEOUT){
console.log("[socket_mgr.connect_hook]timeout");}else
console.log("[socket_mgr.connect_hook]error other");};
socket_mgr.send_hook=function(){
var obj=arguments[1];
var result=arguments[2];
console_log("[socket_mgr.send_hook]result "+result);
if(result==obj.SENT_EV){
console_log("[socket_mgr.send_hook]ok");}else if(result==obj.ERROR_EV){
console_log("[socket_mgr.send_hook]error");}else if(result==obj.DISCONNECTED_EV){
console_log("[socket_mgr.send_hook]disconnected");
obj.close();
obj=null;}else if(result==obj.RESULT_TIMEOUT){
console_log("[socket_mgr.send_hook]timeout");}
};
socket_mgr.recv_header_hook=function(){
var self=socket_mgr;
var obj=arguments[1];
var result=arguments[2];
var binobj=arguments[3];
console_log("[socket_mgr.recv_header_hook]ok");
console_log("[socket_mgr.recv_header_hook]result "+result);
if(result==obj.RECEIVED_EV){
console_log("[socket_mgr.recv_header_hook]result ok");
if(binobj[3]!=0x10){
switch(binobj[1]){
case 0x03:
self.smapho_add_bookmark=true;
case 0x01:
var tmp="";
var hdata=new Array();
for(var i=4;i<8;i++){
hdata[i]=binobj[i].toString(16);
var t=("0"+hdata[i]).slice(-2);
tmp+=t;}
console_log("[socket_mgr.recv_header_hook]tmp:"+tmp);
var length=parseInt(tmp,16);
console_log("[socket_mgr.recv_header_hook]message length:"+length);
obj.recv_hook=socket_mgr.recv_data_hook;
ret=obj.recv({"size":length,
"waitall":true,
"async":true,
"timeout":5000});
break;
case 0x02:
if(self.event_hook)self.event_hook(SEND_URL_EV);
break;
case 0x04:
if(self.event_hook)self.event_hook(SEND_TITLE_EV);
break;}
}
}else if(result==obj.ERROR_EV){
console_log("[socket_mgr.recv_header_hook]error");}else if(result==obj.DISCONNECTED_EV){
console_log("[socket_mgr.recv_header_hook]disconnected");
obj.close();
obj=null;}else if(result==obj.RESULT_TIMEOUT){
console_log("[socket_mgr.recv_header_hook]timeout");}
};
socket_mgr.recv_data_hook=function(){
var self=socket_mgr;
var obj=arguments[1];
var result=arguments[2];
var binobj=arguments[3];
var recv_ev;
var action;
if(self.smapho_add_bookmark){
recv_ev=RECV_BOOKMARK_URL_EV;
action=SEND_ACK_REQ_BOOKMARK;}
else {
recv_ev=RECV_URL_EV;
action=SEND_ACK_REQ_URL;}
console_log("[socket_mgr.recv_data_hook]result "+result);
if(result==obj.RECEIVED_EV){
if(binobj.is_utf8_string()){
try{
var url=sysutil.tconv.binary_to_string(binobj);
console_log("[socket_mgr.recv_data_hook]recv data ->"+url);
self.smapho_req=true;
if(self.event_hook)self.event_hook(recv_ev,url);
obj.recv_hook=self.recv_header_hook;}catch(e){
console_log("[socket_mgr.recv_data_hook]error:"+e);
self.smapho_req=false;
self.smapho_add_bookmark=false;}
}else{
console_log("[socket_mgr.recv_data_hook]not string");
try{
send_event(action,null,false);
}catch(e){
console_log("[socket_mgr.recv_data_hook]ack error:"+e);}
}
}else if(result==obj.ERROR_EV){
console_log("[socket_mgr.recv_data_hook]error");
self.smapho_add_bookmark=false;}else if(result==obj.DISCONNECTED_EV){
console_log("[socket_mgr.recv_data_hook]disconnected");
self.smapho_add_bookmark=false;
obj.close();
obj=null;}else if(result==obj.RESULT_TIMEOUT){
console_log("[socket_mgr.recv_data_hook]timeout");
self.smapho_add_bookmark=false;}
};
socket_mgr.is_smapho_req=function(){
return this.smapho_req;};
socket_mgr.is_smapho_add_bookmark=function(){
return this.smapho_add_bookmark;};
socket_mgr.reset_smapho_req=function(){
this.smapho_req=false;};
socket_mgr.reset_smapho_add_bookmark=function(){
this.smapho_add_bookmark=false;};
socket_mgr.add_event_hook=function(event_hook){
this.event_hook=event_hook;};
socket_mgr.send_event=function(req,data,stat){
var dataArray=new Binary();
this.obj.send_hook=this.send_hook;
switch(req){
case SEND_ACK_REQ_URL:
case SEND_ACK_REQ_BOOKMARK:
dataArray.length=8;
dataArray[0]=0xF4;
dataArray[1]=(req==SEND_ACK_REQ_URL)?0x01:0x03;
dataArray[2]=0x02;
dataArray[3]=(stat==true)?0x01:0x10;
dataArray[4]=0x00;
dataArray[5]=0x00;
dataArray[6]=0x00;
dataArray[7]=0x00;
try{
this.obj.send({"data":dataArray,
"async":true,
"timeout":5000
});}catch(e){
console_log("[socket_mgr.send_event]SEND_ACK_REQ error:"+e);}
break;
case SEND_URL_REQ:
case SEND_TITLE_REQ:
var binaryData=sysutil.tconv.string_to_binary(data);
binaryData[binaryData.length]=0x00;
var length=binaryData.length;
var hex=("0000000"+length.toString(16)).slice(-8);
var datalist=new Array();
for(var i=0;i<4;i++){
datalist[i]=hex.substring(i*2,i*2+2);}
console_log("[socket_mgr.send_event]array:"+datalist);
dataArray[0]=0xF4;
dataArray[1]=(req==SEND_URL_REQ)?0x02:0x04;
dataArray[2]=0x02;
dataArray[3]=0x01;
dataArray[4]=parseInt(datalist[0],16);
dataArray[5]=parseInt(datalist[1],16);
dataArray[6]=parseInt(datalist[2],16);
dataArray[7]=parseInt(datalist[3],16);
var send_data=dataArray.concat(binaryData);
try{
this.obj.send({"data":send_data,
"async":true,
"timeout":5000
});}catch(e){
console_log("[socket_mgr.send_event]SEND_URL_REQ error:"+e);}
break;
default:
return;}
};
socket_mgr.close=function(){
if(this.obj)this.obj.close();};
function tooltip_item(){
if(this.components.length!=0)return;
this.offset_x=30;
this.offset_y=-80;
this.margin_w=25;
this.margin_h=20;
this.max_w=500;
this.create();
}
tooltip_item.prototype=new container({});
tooltip_item.prototype.create=function(){
if(this.components.length!=0)return;
this.visible_p=false;
this.components=[
this.shadow=new gbox({translate:[3,-3,0],width:0,height:0,color:[0,0,0,100]}),
this.frame=new gbox({color:[0,0,0,255]}),
this.box=new gbox({color:[255,250,199,255]}),
this.word=new gtextbox({align:LEFT,font_size:28,width:this.max_w,color:[0,0,0,255]}),
];
};
tooltip_item.prototype.free=function(){
if(this.components.length==0)return;
setf_text(this.word,"");
this.components.splice(0,this.components.length);
};
tooltip_item.prototype.disappear=function(){
delete_timer(this);
this.visible_p=false;
this.free();
force_redraw();
};
tooltip_item.prototype.appear=function(param){
if(this.components.length==0)this.create();
setf_text(this.word,param.text);
var text_wh=get_dimension_textbox(this.word);
var text_w=text_wh[0];
var text_h=text_wh[1];
this.word.width=text_w;
this.word.height=text_h;
setf_text(this.word,param.text);
this.shadow.width=text_w+this.margin_w;
this.shadow.height=text_h+this.margin_h;
this.frame.width=text_w+this.margin_w;
this.frame.height=text_h+this.margin_h;
this.box.width=text_w+this.margin_w-2;
this.box.height=text_h+this.margin_h-2;
this.translate=param.translate;
this.translate[0]+=this.offset_x;
this.translate[1]+=(-text_h/2+this.offset_y);
if(this.translate[1]<(-SCREEN_HEIGHT/2+this.frame.height/2)){
this.translate[1]=-SCREEN_HEIGHT/2+this.frame.height/2;}
var posx=this.translate[0]+this.shadow.translate[0]+this.shadow.width/2;
if(posx>SCREEN_WIDTH/2){
this.translate[0]=SCREEN_WIDTH/2-(this.shadow.translate[0]+this.shadow.width/2);}
posx=this.translate[0]+this.frame.translate[0]-this.frame.width/2;
if(posx<-SCREEN_WIDTH/2){
this.translate[0]=-SCREEN_WIDTH/2-(this.frame.translate[0]-this.frame.width/2);}
var self=this;
delete_timer(self);
append_timer(self,300,function (obj,count){
delete_timer(obj);
obj.visible_p=true;
force_redraw();});
};

var MatchUrl=function(domain,path,query_string,target_url)
{
if(target_url==null){
return false;}
var t=ParseUrl(target_url);
if(t==null||t[2]==null||t[4]==null){
return false;}
if(domain!=null){
if(t[2].indexOf(domain)==-1){
return false;}
}
if(path!=null){
var t_path=" "+t[4];var b_path=" "+path;if(t_path.indexOf(b_path)==-1){
return false;}
}
if(query_string!=null&&t[5]!=null){
if(t[5].indexOf(query_string)==-1){
return false;}
}
return true;}
var ParseUrl=function(url)
{
var ret=url.match(/^(http|https):\/\/([-\w\.]+):?(\d+)?(\/[^\s\?]*)?\??([^\s#]*)?[^\s]*$/);
return ret;}
var ParseQueryStrings=function(query)
{

var tmp="^";
for(i=0;i<4;i++){
tmp+="([^\\s&]*)?&?";}
tmp+="[^\\s]*";
var regexp=new RegExp(tmp);
var ret=query.match(regexp);
return ret;}
