JS工具类

/*
+++++++++++++++++++++++++++++++++++++
+
+ chat:V1.0
+ email:58293177@qq.com
+ date:2016-06-24
+ author:Tyrael
+
+++++++++++++++++++++++++++++++++++++
*/






//调试
var debug = true;
//打开页面时间
var openTime = new Date();
























// ===== 弹出窗口 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ onclick = "popup('******.jsp?id=&name=','窗口名称');"
+
+++++++++++++++++++++++++++++++++++ 
*/
function popup(JspName,WindowName){
var top=(screen.height-480)/2;
    var left=(screen.width-640)/2;
    var attr="width="+700+",height="+530+",location=0,menubar=0,scrollbars=1,status=0,resizable=0,top="+top+",left="+left;
    var mywin=window.open(JspName, WindowName, attr);
    mywin.focus();
}




//===== 弹出说明 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ onclick = "show(message);"
+
+++++++++++++++++++++++++++++++++++ 
*/
function show(message){
alert(message);
}




// ===== 改变TR颜色 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ οnmοusemοve="changeTrColor(this)"
+
+++++++++++++++++++++++++++++++++++ 
*/
function changeTrColor(obj){
$(".display tr").on("mouseover", function() {$(this).css({"background-color" : "rgb(196,196,255)"});});
$(".display tr").on("mouseout", function() {$(this).css({"background-color" : "rgb(245,245,245)"});});
}




//===== TR点击改变颜色 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ 1.传递tr对象改变颜色
+  2.js调用clickTrColor("表格名称")  重置所有tr颜色
+ οnclick="clickTrColor(this)"
+
+++++++++++++++++++++++++++++++++++ 
*/
function clickTrColor(obj){
var table = obj.parentNode;
if(table != undefined && table.tagName.toLowerCase() == "tbody".toLowerCase()){
for ( var i = 0; i < table.rows.length; i++) {
if (table.rows[i] == obj) {
table.rows[i].style.backgroundColor = "#C4C4FF";

else {
table.rows[i].style.backgroundColor = "#FFFFFF";
}
}
}
else{
//重置TABLE颜色
$("."+obj+" tr").css("background-color","#FFFFFF");
}
}




//===== 获取浏览器内核 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+  本框架支持IE8.0及以上版本,火狐,谷歌
+ getBrowser()
+
+++++++++++++++++++++++++++++++++++ 
*/
function getBrowser(){
var $Browser = navigator.userAgent.toLowerCase() ;
var $IE = /msie [\d.]+;/gi;
//IE
if($Browser.indexOf("msie") > 0){
var browser = $Browser.match($IE) ;
var verinfo = (browser+"").replace(/[^0-9.]/ig,"");
if(Number(verinfo)<8.0){
nWarning("您目前的浏览器版本过低,请升级浏览器版本!");
}
}
}




//===== 元素变为不可编辑 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ noEdit()
+ 页面元素不可编辑
+
+++++++++++++++++++++++++++++++++++ 
*/
function noEdit(){
$("file").attr("disabled", true);  
$("input").attr("disabled",true);
$("select").attr("disabled",true);
$("select").trigger("liszt:updated");
}




//===== 元素变为可编辑 ===== //
/*
+++++++++++++++++++++++++++++++++++
+
+ canEdit()
+ 页面元素可编辑
+
+++++++++++++++++++++++++++++++++++ 
*/
function canEdit(){
$("file").attr("disabled", false);  
$("input").attr("disabled",false);
$("select").attr("disabled",false);
$("select").trigger("liszt:updated");
}




//===== 可编辑页面的按钮控制(默认状态) =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ 默认状态 添加,修改 2个按钮可用

+ 01.点击添加,保存和取消可用,添加,修改不可用
+ 02.点击修改,保存和取消可用,添加,修改不可用
+ defaultButton()
+
+++++++++++++++++++++++++++++++++++ 
*/
function defaultButton(){
$(".insert").show();
$(".update").show();
$(".save").hide();
$(".cancel").hide();
$(".other").show();
}




//===== 可编辑页面的按钮控制(编辑状态) =====//
/*
+++++++++++++++++++++++++++++++++++
+

+
+ editButton()
+
+++++++++++++++++++++++++++++++++++ 
*/
function editButton(){
$(".insert").hide();
$(".update").hide();
$(".save").show();
$(".cancel").show();
$(".other").hide();
}




//===== 获取右侧主体内容DIV =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ getWrapperBody()
+
+++++++++++++++++++++++++++++++++++ 
*/
function getWrapperBody(){
var wrapper = $(".statsRow").next().next();
var topNav = $(".topNav").next();
//正常页的提示位置
if(wrapper.attr("class") == "wrapper"){
return wrapper;
}
//弹出也的提示位置
else if (topNav.attr("class") == "wrapper"){
return topNav;
}
}




//===== 重载提示框体 =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ reLoadMessage()
+
+++++++++++++++++++++++++++++++++++ 
*/
function reLoadMessage(){
$(".hideit").click(function() {
$(this).fadeTo(200, 0.00, function() { //消退200
$(this).slideUp(300, function() { // 渐变300
$(this).remove(); // 移除
});
});
});
}




//===== 错误提示语 =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ nWarning(要提示的信息)
+
+++++++++++++++++++++++++++++++++++ 
*/
function nWarning(message){

var h = "<div class=\"nNote nWarning hideit\">"+
"<p><strong>错误: </strong>"+message+"</p>"+
"</div>";
var wrapper = getWrapperBody();
wrapper.prepend(h);
reLoadMessage();
}




//===== 通知提示语 =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ nWarning(要提示的信息)
+
+++++++++++++++++++++++++++++++++++ 
*/
function nInformation(message){

var h = "<div class=\"nNote nInformation hideit\">"+
"<p><strong>通知: </strong>"+message+"</p>"+
"</div>";
var wrapper = getWrapperBody();
wrapper.prepend(h);
reLoadMessage();
}




//===== 图片预览 =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ upload(this.id)
+
+++++++++++++++++++++++++++++++++++ 
*/
function upload(fileId) {
var file = document.getElementById(fileId);
var img = document.getElementById(fileId+"Pic");
if (file.files) {
img.src = window.URL.createObjectURL(file.files[0]);
}
}




//===== 检测系统是否超时 =====//
/*
+++++++++++++++++++++++++++++++++++
+
+ isTimeout
+
+++++++++++++++++++++++++++++++++++ 
*/




function isTimeout(timeoutTime,loginoutPage){
ctionTime = new Date();// 检测时间
var openMinutes = openTime.getHours()*60+openTime.getMinutes();// 打开页面的分钟
var ctionMinutes = ctionTime.getHours()*60+ctionTime.getMinutes();// 检测时的分钟
if( ctionMinutes - openMinutes > timeoutTime){// 如果超时
window.location.href = "http://"+loginoutPage;// 注销
}
}




//===== 控制台 =====//
function JsLog(data){
if(debug&&window.console){
window.console.log(data);
}
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值