2 qq 31788907 qq_31788907 于 2016.05.10 16:26 提问

这段代码的意义是什么

图片说明
function grabEvent(__key_code) {
var key_code = 0;
if (__USER_AGENT__ == 'android')
{
key_code = __key_code;
}
else
{
key_code = transform_key_value(event.which || event.keyCode);
}

if (key_code < 58 && key_code > 47)
{
key_code = key_code - 48;
if (body_selector_show && body_focus_area == 1)
{
get_num(key_code);
}
return 0;
}
else
{
switch(key_code) {
case 1://up
if (error_show || wait_tips)
{
return 0;
}
if (body_selector_show)
{
if(body_focus_area == 1) {
if(keyPadWeight.focusIdx < 6) {
//to 顶部
$("focusInputItem").style.left = inputItemPos[body_pos] + "px";
$("focusInputItem").style.visibility = "visible";
body_focus_area = 0;
$("keyborad_focus").style.visibility = "hidden";
set_input_style(0);
} else {
keyPadWeight.focusChg(-6);
}
}
}
else
{
if (focus_area == 1)
{

                    focus_area = 0;
                    $("uu" + pos).style.visibility = "hidden";
                    $("u" + pos).style.visibility = "visible";
                    $("gb1").style.visibility = "hidden";
                }
            }
            return 0;
            break;              
        case 2://down                  
            if (error_show || wait_tips)
            {
                return 0;
            }
            if (body_selector_show)
            {
                if (body_focus_area == 0)
                {
                    $("keyborad_focus").style.visibility = "visible";
                    $("focusInputItem").style.visibility = "hidden";
                    input_objs[body_pos].showCursor();
                    body_focus_area = 1;
                } else if(body_focus_area == 1) {
                    if(keyPadWeight.focusIdx < 6) {
                        keyPadWeight.focusChg(6);
                    }
                }
            }
            else 
            {
                if (focus_area == 0)
                {

                    focus_area = 1;
                    $("uu" + pos).style.visibility = "visible";
                    $("u" + pos).style.visibility = "hidden";
                    $("gb1").style.visibility = "visible";
                }
            }
            return 0;               
            break;              
        case 3://left   
            if (error_show || wait_tips)
            {
                return 0;
            }
            if (sex_selector_show)
            {
                change_sex_pos(-1);
                return 0;
            }
            else if (vocation_selector_show)
            {
                change_vocation_pos(-1);
                return 0;
            }
            else if (body_selector_show)
            {
                if (body_focus_area == 0)
                {
                    if(body_pos > 0) {
                        body_pos--;
                        $("focusInputItem").style.left = inputItemPos[body_pos] + "px";
                    }
                } 
                else if(body_focus_area == 1) 
                {
                    keyPadWeight.focusChg(-1);
                }
                return 0;
            }
            if (focus_area == 1)
            {
                change_icon_focus(-1);
            }
            return 0;
            break;
        case 4://right              
            if (error_show || wait_tips)
            {
                return 0;
            }
            if (sex_selector_show)
            {
                change_sex_pos(1);
                return 0;
            }
            else if (vocation_selector_show)
            {
                change_vocation_pos(1);
                return 0;
            }
            else if (body_selector_show)
            {
                if (body_focus_area == 0)
                {
                    if(body_pos < 2) {
                        body_pos++;
                        $("focusInputItem").style.left = inputItemPos[body_pos] + "px";
                    }
                }
                else if(body_focus_area == 1) 
                {
                    keyPadWeight.focusChg(1);
                }
                    return 0;
            }
            if (focus_area == 1)
            {
                change_icon_focus(1);
            }
            return 0;
            break;


    }

}   
return 1;   

}

function change_icon_focus(__num)
{
if (pos == 0 && __num < 0) return;
if (pos == 8 && __num > 0) return;
$("uu" + pos).style.visibility = "hidden";
$("u" + pos).style.visibility = "visible";
pos += __num;
$("uu" + pos).style.visibility = "visible";
$("u" + pos).style.visibility = "hidden";
$("gb1").style.top = focus_index[pos] + "px";
}

function $(id)
{
return document.getElementById(id);
}

2个回答

liummmin
liummmin   2016.05.10 16:59
已采纳

sex_selector_show,vocation_selector_show分别是两个判断条件,满足sex_selector_show=true的话走change_sex_pos(-1)方法,否则如果满足vocation_selector_show=true的话走change_vocation_pos(-1)方法,具体是什么意思,可以看看他们是在哪里定义的,还有在哪里赋了值

bdmh
bdmh   Ds   Rxr 2016.05.10 16:30

无法就是判断两个条件,根据条件不同,改变某些信息,具体什么意思,跟进去看具体代码

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!