/**
 * @author LuBiHua
 * 常用方法
 */

Ext.namespace('AssistCom','AssistCom.Core','AssistCom.Core.Method');

/**
 * 传入一个字符串，获取出他的长度(中文当作2个长度)
 * @param {Object} str
 */
AssistCom.Core.Method.GetStrLength = function(str){
	
	if(str == null){
		return null;
	}else {
		return str.replace(/[^\x00-\xff]/g, '**').length;
	}
};

/**
 * 从服务器获取数据列表
 * @param {Object} cmd	命令类型
 * @param {Object} params	参数列表
 * @param {Object} callbackFun 请求响应返回时的回调函数
 * @param {Object} scope	在回调函数的主题this
 * @param {Object} isCmdStr	命令格式
 * @param {Object} maskStr	处理请求时冻结页面时候显示的文字
 */
AssistCom.Core.Method.GetDataFromServer = function(cmd,params,callbackFun,scope,isCmdStr,maskStr){
	
		
		var parameterObj = {
            cmd: cmd,
            params: params,
            isCmdStr: isCmdStr == true ?true : false,
            scope: scope,
			maskStr : maskStr,			
            callbackFun: callbackFun
        };
        
        AssistCom.Util.Ajax.Send(parameterObj);
};


/**
 * 利用Window.name去保存数据
 * @param {Object} name
 * @param {Object} value
 */
AssistCom.Core.setSession = function(name,value){

	var wn = null;
	try{
		wn = Ext.decode(window.name);
	}catch(e){
		if(!wn)
			wn = {};
	}
	wn[name] = value;
	
	try{
		window.name = Ext.encode(wn);
	}catch(ex){
		return null;
	}
	return value;
};

/**
 * 利用window.name去获取数据
 * @param {Object} name
 */
AssistCom.Core.getSession = function(name){
	var value = null;
	try{
		value = Ext.decode(window.name);
	}catch(e){
		return null;
	}
	return value[name];
}

