//JSX监听某个事件

alert("当前监听事件个数:"+app.notifiers.length,"提示:")

try
{
    arg_num = arguments.length;
}
catch(e)
{
    arguments = []; //初始赋值为空
}

eventName = "recordMeasurements";

//开启监听
enable_notifier(eventName, $.fileName);

//取消监听
//~ disable_notifier(eventName, $.fileName);

//这里进行监控调用事件
if (arguments.length >= 2) 
{
    //alert(arguments.length);
//~     alert(arguments[0],"动作参数1"); //动作描述符 AR
//~     alert(arguments[1],"动作参数2"); //动作事件ID
    
    alert("事件名:"+typeIDToStringID(arguments[1])+"\n"+"事件ID:"+arguments[1],"提示:");
    
    //main(arguments[0], arguments[1]);  
}




function enable_notifier(event_name, script_name, event_class)  
{  
try   
    {  
    for (var i = 0; i < app.notifiers.length; i++)  
        {  
        if (app.notifiers[i].event == event_name &&  
            File(app.notifiers[i].eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())  
            {  
            if (!app.notifiersEnabled) app.notifiersEnabled = true;  
            return true;  
            }  
        }  

    app.notifiers.add(event_name, File(script_name), event_class);  
    app.notifiersEnabled = true;  
    return true;  
    }  
catch (e) { _alert(e); return false; }  
}  
  

function disable_notifier(event_name, script_name, event_class)  
{  
try   
    {  
    var ret = false;  

    for (var i = 0; i < app.notifiers.length; i++)  
        {  
        if (app.notifiers[i].event == event_name &&  
            File(app.notifiers[i].eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())  
            {  
            app.notifiers[i].remove();  
            ret = true;  
            }  
        }  

    if (!app.notifiers.length) app.notifiersEnabled = false;  

    return ret;  
    }  
catch (e) { _alert(e); return false; }  
}  