1、日志界面过滤过长字符串 2、界面鼠标悬停事件(洪庆)
This commit is contained in:
43
src/main/webapp/static/pages/scripts/pageLogs.js
Normal file
43
src/main/webapp/static/pages/scripts/pageLogs.js
Normal file
@@ -0,0 +1,43 @@
|
||||
$(document).ready(function() {
|
||||
// 界面鼠标悬停事件
|
||||
$("table.logTb").find("td").not(":has(a)").bind("mouseover", function(){
|
||||
this.title=$(this).html(this.innerHTML.trim()).text();
|
||||
});
|
||||
|
||||
$("table.logTb th").each(function(){
|
||||
// 判断是否支持currentStyle属性 是:IE 否:FF or Chrome
|
||||
var finalStyle = this.currentStyle ? this.currentStyle : document.defaultView.getComputedStyle(this , null);
|
||||
var fontSize = (finalStyle.fontSize).replace("px","");
|
||||
|
||||
var px = getPixelsCount($(this).text(),fontSize)+55;
|
||||
this.setAttribute('width',px+'px');
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// 获取界面标题字符串对等的像素值
|
||||
function getPixelsCount(str, strFontSize){
|
||||
// 字符串字符个数
|
||||
var stringCharsCount = str.length;
|
||||
|
||||
// 像素值
|
||||
var stringPixelsCount = 0;
|
||||
|
||||
var element = document.createElement("span");
|
||||
element.style.fontSize = strFontSize; // 设置span的fontSize
|
||||
element.style.visibility = "hidden"; // 设置span不可见
|
||||
element.style.display = "inline-block";
|
||||
element.style.wordBreak = "break-all !important";
|
||||
|
||||
document.body.appendChild(element);
|
||||
for(var i = 0; i < stringCharsCount; i++){
|
||||
if(str[i] == " "){
|
||||
element.innerHTML = " ";
|
||||
}else{
|
||||
element.innerHTML = str[i];
|
||||
}
|
||||
stringPixelsCount += element.offsetWidth;
|
||||
}
|
||||
|
||||
return stringPixelsCount;
|
||||
}
|
||||
Reference in New Issue
Block a user