/*
*
* 验证浏览器
*/
function
getAppVer(){
var
sVer
=
navigator.appVersion;
var
nVer
=
sVer.indexOf(
"
MSIE
"
);
var
appVer
=
""
;
if
(nVer
>
0
) {
appVer
=
"
M
"
+
sVer.substring(nVer
+
5
, nVer
+
9
);
}
else
{
appVer
=
"
N
"
+
sVer.substring(
0
,
4
);
}
if
(appVer.charAt(
4
)
==
"
"
) {
appVer
=
appVer.substring(
0
,
4
)
+
"
0
"
;
}
return
appVer;
}
var
appVer
=
getAppVer();
function
checkSpaceChar(c){
return
((c
==
' ')
||
(c
==
'\t')
||
(c
==
' '));
}
/*
*
* 获取上下文路径
*/
function
getAppPath(){
var
path
=
""
;
var
pathname
=
document.location.pathname;
if
(pathname.length
>
0
) {
if
(pathname.charAt(
0
)
!=
'
/
') {
path
+=
"
/
"
;
}
var
index
=
pathname.indexOf('
/
',
1
);
if
(index
>
0
) {
path
+=
pathname.substring(
0
, index);
}
else
{
path
+=
pathname;
}
return
path;
}
else
{
return
""
;
}
}
/*
*
* 保存jsp页面现场
* @param {Object} String localeName 现场名称,可以不写
*/
var
urlprefix
=
document.location.protocol
+
"
//
"
+
document.location.host
+
getAppPath();
var
rootcontext
=
""
;
function
saveLocale(localeName){
if
($(
"
#saveLocale
"
).val()
!=
undefined
&&
$(
"
#saveLocale
"
).val()
==
'
false
') {
return
;
}
url
=
urlprefix
+
"
/saveBackUrlDefaultAction.action?
"
;
if
(
null
!=
localeName
&&
""
!=
localeName) {
url
+=
"
localeName=
"
+
localeName
+
"
&
"
;
}
//
url += "backurl=" + document.URL.replace(new RegExp("&", "gm"), "$*$");
url
+=
"
backurl=
"
+
document.URL.replace(
/
\
&/
g,
"
$*$
"
);
$.ajax({
type:
"
POST
"
,
url: url,
async:
true
});
}
/*
*
* 退出系统,判断页面中是否有saveLocale变量,如果有则保存现场,否则不保存现场
* 点击退出后,如果需要保存现场,则需要在对应的jsp页面中包含隐藏域
* <input type="hidden" id="saveLocale" name="saveLocale" value="true"/>
* @param {Object} localeName
*/
function
saveLocaleForLogout(localeName){
if
($(
"
#saveLocale
"
).val()
!=
undefined
&&
$(
"
#saveLocale
"
).val()
==
'
true
') {
saveLocale(localeName);
}
else
{
//
删除之前保存的退出现场
var
url
=
urlprefix
+
"
/removeBackUrlDefaultAction.action?
"
;
if
(
null
!=
localeName
&&
""
!=
localeName) {
url
+=
"
localeName=
"
+
localeName;
}
$.ajax({
type:
"
POST
"
,
url: url,
async:
true
});
}
logout();
}
/*
*
* 删除指定现场,完成后返回指定页面
*/
function
removeLocale(localeName,url){
$.ajax({
type:
"
POST
"
,
url: urlprefix
+
"
/removeBackUrlDefaultAction.action?localeName=
"
+
localeName,
async:
true
,
complete :
function
(){
if
(url
!=
null
&&
url
!=
undefined
&&
url
!=
''){
window.location.href
=
url;
}
}
});
}
/*
*
* 确认登陆
*/
function
confirmLogin(){
if
(confirm('您还没有登录,确定登录吗
?
')) {
saveLocale('login');
window.location.href
=
urlprefix
+
"
/front/loginVarFront.action
"
;
return
true
;
}
else
{
return
false
;
}
}
/*
*
* 退出
*/
function
logout(){
$.ajax({
url:
"
http://www.LuckyStar.com.cn/Login/WebLogout.aspx
"
,
dataType:
"
script
"
,
type:
"
post
"
});
}
/*
*
* 退出,完成后返回指定页面
*/
function
logout(url){
$.ajax({
url:
"
http://www.LuckyStar.com.cn/Login/WebLogout.aspx
"
,
dataType:
"
script
"
,
type:
"
post
"
,
complete :
function
(){
window.location.href
=
url;
}
});
}
/*
*
* 系统中的通配
*/
$(
function
(){
if
($(
"
#rootcontext
"
)
!=
null
&&
$(
"
#rootcontext
"
)
!=
undefined
&&
$(
"
#rootcontext
"
).val()
!=
null
&&
$(
"
#rootcontext
"
).val()
!=
undefined
&&
$(
"
#rootcontext
"
).val()
!=
''){
rootcontext
=
$(
"
#rootcontext
"
).val();
}
/*
* 对系统JSP页面中所有A连接中的中文进行编码
* 进行编码的参数在JAVA代码中应该使用java.net.URLDecoder.decode(parametername,"UTF-8");进行解码
*/
if
($(
"
a
"
)
!=
null
) {
$(
"
a
"
).each(
function
(){
if
($(
this
).attr(
"
urlencode
"
)
!=
null
&&
$(
this
).attr(
"
urlencode
"
)
!=
undefined
&&
$(
this
).attr(
"
urlencode
"
)
==
'
true
') {
if
($(
this
).attr(
"
urlencode
"
)
==
'
true
') {
$(
this
).attr(
"
href
"
, encodeURI(encodeURI($(
this
).attr(
"
href
"
))));
}
}
else
{
$(
this
).attr(
"
href
"
, encodeURI(encodeURI($(
this
).attr(
"
href
"
))));
}
/*
var href = $(this).attr("href");
if(href != null && href != undefined && href!=''){
$(this).attr("href",href.replace(".action",".htm"));
}
*/
});
}
//
//
/**
//
* 对URL中的参赛进行编码
//
* @param {Object} url
//
*/
//
function urlEncoding(url){
//
var result = url;
//
if(url != null && url != undefined && url != ''){
//
var i = url.indexOf("?");
//
var paramStr = url.substring(i+1);
//
var params = paramStr.split("&");
//
}
//
return url;
//
}
/*
* 对系统中所有input(button、image、submit、reset)样式统一处理
*/
/*
if($("input[type='button']") != null){
$("input[type='button']").each(function(){
$(this).addClass("button_out").attr("onmouseover","className='button_over'").attr("onmouseout","className='button_out'");
});
}
if($("input[type='image']") != null){
$("input[type='image']").each(function(){
$(this).addClass("button_out").attr("onmouseover","className='button_over'").attr("onmouseout","className='button_out'");
});
}
if($("input[type='submit']") != null){
$("input[type='submit']").each(function(){
$(this).addClass("button_out").attr("onmouseover","className='button_over'").attr("onmouseout","className='button_out'");
});
}
if($("input[type='reset']") != null){
$("input[type='reset']").each(function(){
$(this).addClass("button_out").attr("onmouseover","className='button_over'").attr("onmouseout","className='button_out'");
});
}
*/
})
/*
*
* 添加到收藏夹
* @param {Object} title
* @param {Object} url
*/
function
addBookmark(nome_sito, url_sito){
if
((navigator.appName
==
"
Microsoft Internet Explorer
"
)
&&
(parseInt(navigator.appVersion)
>=
4
))
window.external.AddFavorite(url_sito, nome_sito);
else
if
(navigator.appName
==
"
Netscape
"
)
window.sidebar.addPanel(nome_sito, url_sito, '');
else
alert(
"
对不起!不能将此站点添加到收藏夹!.
"
);
}
/*
*
* 获取剩余时间字符串
*
* @param {Object} ms 剩余时间毫秒数
* @return XX天XX小时XX分钟
*/
function
getDateTime(ms){
var
datetime
=
""
;
var
temptime
=
""
;
var
hours
=
0
;
if
((temptime
=
Math.floor(ms
/
(
24
*
60
*
60
*
1000
)))
>
0
) {
datetime
+=
temptime
+
"
天
"
;
ms
-=
temptime
*
24
*
60
*
60
*
1000
;
}
if
((temptime
=
Math.floor(ms
/
(
60
*
60
*
1000
)))
>
0
) {
datetime
+=
temptime
+
"
小时
"
;
ms
-=
temptime
*
60
*
60
*
1000
;
}
if
((temptime
=
Math.floor(ms
/
(
60
*
1000
)))
>
0
) {
datetime
+=
temptime
+
"
分钟
"
;
}
return
datetime;
}
/*
*
* 格式化数字
* @param {Object} number 浮点数
* @param {Object} pattern 小数位后保留几位
*/
function
formatNumber(number, pattern){
if
(
typeof
(number)
==
"
undefined
"
||
number
==
null
||
number
==
'') {
number
=
"
0
"
;
}
return
parseFloat(number).toFixed(pattern);
}
/*
*
* 图片缩放
* @param {Object} C img dom 对象
* @param {Object} I 宽
* @param {Object} H 高
* @param {Object} B 是否上下有空
* @param {Object} A 是否左右有空
*/
function
resizeImage(C, I, H, B, A){
B
=
B
||
1
;
A
=
A
||
1
;
var
D
=
new
Image();
D.onload
=
function
(){
this
.onload
=
null
;
var
K
=
this
.width, N
=
this
.height;
if
(K
>
0
&&
N
>
0
) {
var
M
=
(I
/
K
<
H
/
N)
?
I
/
K : H
/
N;
var
O
=
0
;
var
J
=
0
;
if
(M
<=
1
) {
O
=
C.width
=
Math.round(K
*
M);
J
=
C.height
=
Math.round(N
*
M)
}
else
{
O
=
C.width
=
K;
J
=
C.height
=
N
}
if
(B
==
1
) {
var
L
=
(I
-
O)
/
2
;
C.style.marginLeft
=
C.style.marginRight
=
L
+
"
px
"
}
if
(A
==
1
) {
var
L
=
(H
-
J)
/
2
;
C.style.marginTop
=
C.style.marginBottom
=
L
+
"
px
"
}
}
C
=
null
};
C.onload
=
null
;
D.src
=
C.src
}
function
initNavigationTime(){
today
=
new
Date();
function
initArray(){
this
.length
=
initArray.arguments.length
for
(
var
i
=
0
; i
<
this
.length; i
++
)
this
[i
+
1
]
=
initArray.arguments[i]
}
var
d
=
new
initArray(
"
星期日
"
,
"
星期一
"
,
"
星期二
"
,
"
星期三
"
,
"
星期四
"
,
"
星期五
"
,
"
星期六
"
);
document.write(
""
, today.getYear(),
"
年
"
, today.getMonth()
+
1
,
"
月
"
, today.getDate(),
"
日
"
, d[today.getDay()
+
1
],
""
);
}
/*
* 复选框全选
*/
function
selectall(domname){
var
checkboxs
=
document.getElementsByName(domname);
for
(
var
i
=
0
; i
<
checkboxs.length; i
++
) {
checkboxs[i].checked
=
true
;
}
}
/*
* 复选框反选
*/
function
invertSelection(domname){
var
checkboxs
=
document.getElementsByName(domname);
for
(
var
i
=
0
; i
<
checkboxs.length; i
++
) {
if
(checkboxs[i].checked) {
checkboxs[i].checked
=
false
;
}
else
{
checkboxs[i].checked
=
true
;
}
}
}
//
//
/*
//
* 检查复选框是否已经选择
//
* @param domname 按钮的id名称
//
* @param url 使用层打开的url
//
*/
//
function checkCheckBox(domname,url){
//
var str="";
//
var objarray=$(".checkbox")
//
for(var i=0;i<objarray.length;i++)
//
{
//
if(objarray[i].checked)
//
str+=objarray[i].value+",";
//
}
//
if(str=='')
//
{
//
alert("请你至少选择一条记录!");
//
$("#"+domname).removeClass("thickbox");
//
return false;
//
}
//
else{
//
$("#"+domname).addClass("thickbox");
//
$("#"+domname).attr("href","<%=basepath %>/console/audit/certification/listMemberPersonalState.action?audit_IDs="+str+"&keepThis=true&TB_iframe=true&height=275&width=425&modal=true");
//
tb_init('a.thickbox');
//
imgLoader = new Image();// preload image
//
imgLoader.src = "<%=basepath %>/images/ico/loadingAnimation.gif";
//
}
//
}
/*
*
* 检查字符串是否为Float类型
* @param {Object} str
*/
function
checkFloat(str){
var
i;
var
len
=
str.length;
var
chkStr
=
"
1234567890.
"
;
if
(len
==
1
) {
if
(chkStr.indexOf(str.charAt(i))
<
0
) {
return
false
;
}
}
else
{
if
((chkStr.indexOf(str.charAt(
0
))
<
0
)) {
return
false
;
}
for
(i
=
1
; i
<
len; i
++
) {
if
(chkStr.indexOf(str.charAt(i))
<
0
) {
return
false
;
}
}
}
return
true
;
}
/*
*
* 检查字符串是否为空
* @param {Object} str
*/
function
isEmpty(str){
if
(str
==
null
||
str
==
undefined
||
trim(str)
==
'') {
return
true
;
}
return
false
;
}
/*
*
* 检查字符串是否给Number类型
* @param {Object} str
*/
function
checkNumber(str){
var
i;
var
len
=
str.length;
var
chkStr
=
"
1234567890
"
;
if
(len
==
1
) {
if
(chkStr.indexOf(str.charAt(i))
<
0
) {
return
false
;
}
}
else
{
if
((chkStr.indexOf(str.charAt(
0
))
<
0
)) {
return
false
;
}
for
(i
=
1
; i
<
len; i
++
) {
if
(chkStr.indexOf(str.charAt(i))
<
0
) {
return
false
;
}
}
}
return
true
;
}
/*
*
* 去掉字符串两遍空格
* @param {Object} str
*/
function
trim(str){
var
len
=
str.length;
var
begin
=
0
;
var
end
=
len
-
1
;
var
chkOne
=
true
;
var
chkTwo
=
true
;
if
((appVer.charAt(
0
)
==
'M')
||
(appVer
>
"
N4.03
"
)) {
for
(begin; (begin
<
len)
&&
checkSpaceChar(str.charAt(begin)); begin
++
)
;
for
(end; (end
>=
0
)
&&
checkSpaceChar(str.charAt(end)); end
--
)
;
}
else
if
(appVer.charAt(
0
)
==
'N') {
while
(chkOne
||
chkTwo) {
if
(begin
<
len) {
if
(checkSpaceChar(str.charAt(begin))) {
begin
++
;
chkOne
=
true
;
}
else
{
chkOne
=
false
;
}
}
else
{
chkOne
=
false
;
}
if
(begin
<
len
-
1
) {
if
(str.substring(begin, begin
+
2
)
==
"
"
) {
begin
+=
2
;
chkTwo
=
true
;
}
else
{
chkTwo
=
false
;
}
}
else
{
chkTwo
=
false
;
}
}
chkOne
=
true
;
chkTwo
=
true
;
while
(chkOne
||
chkTwo) {
if
(end
>
-
1
) {
if
(checkSpaceChar(str.charAt(end))) {
end
--
;
chkOne
=
true
;
}
else
{
chkOne
=
false
;
}
}
else
{
chkOne
=
false
;
}
if
(end
>
0
) {
if
(str.substring(end
-
1
, end
+
1
)
==
"
"
) {
end
-=
2
;
chkTwo
=
true
;
}
else
{
chkTwo
=
false
;
}
}
else
{
chkTwo
=
false
;
}
}
}
if
(begin
>
end) {
return
""
;
}
return
str.substring(begin, end
+
1
);
}
/*
*
* 验证标题信息(只允许字母、数字、中文、空格、小数点)
*/
function
validateTitle(title){
if
(
/
[
^
\u4E00
-
\u9FA50
-
9a
-
zA
-
Z. ]
/
.test(title)) {
return
false
;
}
else
{
return
true
;
}
}
/*
*
* 对字符串进行URL编码
* 将编码后的字符串中&和+替换成中文字符
*/
function
encoding(str){
if
(str
!=
null
&&
str
!=
undefined
&&
trim(str)
!=
'') {
var
result
=
encodeURI(encodeURI(str));
if
(result.indexOf(
"
&
"
)
!=
-
1
) {
result
=
result.replace(
/
\
&/
g,
"
&
"
);
}
if
(result.indexOf(
"
+
"
)
!=
-
1
) {
result
=
result.replace(
/
\
+/
g,
"
+
"
);
}
return
result;
}
return
""
;
}
/*
*
* 对Input文本框进行URL编码
* @param {Object} names Input文本框name名称,多个可用逗号分割
*/
function
encodingForInput(ids){
var
result
=
""
;
if
(ids.indexOf(
"
,
"
)
!=
-
1
) {
var
array
=
ids.split(
"
,
"
);
for
(
var
i
=
0
; i
<
array.lenght; i
++
) {
$(
"
input[name='
"
+
array[i]
+
"
']
"
).each(
function
(){
$(
this
).val(encoding($(
this
).val()));
});
}
}
else
{
$(
"
input[name='
"
+
ids
+
"
']
"
).each(
function
(){
$(
this
).val(encoding($(
this
).val()));
});
}
}