2013年10月23日 星期三

generator-tabledata.jsp

function ; give the paramter , and give out the report in the html screen

<!-- e.g. http://192.168.10.80:8080/hr/tableData.jsp?table=payroll&fields=surname,bankstatus,year,mth,surname,departmentName,banker,bankerno,netpay,recordID&format=S,S,S,S,S,S,S,S,S,S&where=where%20bankstatus:`B`-->
<%
//String FIELDS="";
//if (request.getParameter("fields") == null) {} else {FIELDS=request.getParameter("fields");}
//if (request.getParameter("fields") != null) {}
//if (request.getParameter("fields") != null) {out.println("_HEADERS='"+request.getParameter("fields")+"'");}
//if (request.getParameter("format") != null) {out.println("_FORMATS='"+request.getParameter("format")+"'");}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- script src="http://code.jquery.com/jquery-1.9.1.js"></script -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

<script src="js/udf2.js"></script>
<%@ page contentType="text/html; charset=UTF-8" %>
<%String Title=""; String CountField="";
String FONT=request.getParameter("Font");
String SQL=request.getParameter("Sql");%>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<script type="text/javascript" >
<% String headers=request.getParameter("headers");%>
<%
String tableHeight="650px";
%>
var _HEADERS="surname,bankstatus,year,mth,surname,departmentName,banker,bankerno,netpay,recordID";
var _FORMATS="S,S,S,S,S,S,S,S,S,S"
var _TABLE="payroll"
var _CONSTRAINT="where status:`D`"
<%
if (request.getParameter("fields") != null) {out.println("_HEADERS='"+request.getParameter("fields")+"'");}
if (request.getParameter("format") != null) {out.println("_FORMATS='"+request.getParameter("format")+"'");}
if (request.getParameter("table") != null) {out.println("_TABLE='"+request.getParameter("table")+"'");}
if (request.getParameter("where") != null) {out.println("_CONSTRAINT='"+request.getParameter("where")+"'");}

%>


//_HEADERS="<%=headers%>"


</script>
<title><%=Title%></title>
<!--STYLESHEETS-->
<!-- link href="css/style.css" rel="stylesheet" type="text/css" / -->

<link href="css/general.css" rel="stylesheet" type="text/css" />


<style type="text/css">
#container {width: 1160px; margin: auto;}
.posttext {font-size: 0.875em; line-height: 1.5}
#content {margin: 30px 0;}
input {margin-right: 10px;}
label {margin-right: 10px;}
.focused {background: #abcdef;}
input[type="text"][disabled] {color:black; background: #abcdef; filter:alpha(opacity=60);}
#td_id {width: <>; border-collapse: collapse;}
#td_id th {border: solid 1px #000000; padding: 8px;
background-color: #4378b6; color:white; font-size: 0.875em; text-align: left;}
/*background-color: #4378b6;*/
#td_id td {border: solid 1px #0000ff; padding: 8px; font-size: 0.875em;}
#table {float: left;margin:0px;}
#body {float: right;margin:0px; }
/*div.scroll {height: <%=tableHeight%>; overflow: auto; border: 1px solid #666; background-color: #ccc;}*/
div.scroll {border: 1px solid #666; background-color: #ccc;}
</style>
</head>
<!--********************************************
*
* HTML.body
*
********************************************-->
<body>
<div id="container">
<div id="head"><div id="header"><div id="header_inner">
<h1><%=Title%></h1>
</div></div></div>
<div style="display:none;">
<input type="text" disabled="disabled" value="" name="clock" id="clock"style="width:60px; margin-right: 5px; " />
<input type="text" disabled="disabled" value="" name="ip" id="ip"style="width:120px; margin-right: 5px; " />
Browser Level
<input type="text" disabled="disabled" value="" name="browser" id="browser"style="width:10px; margin-right: 5px; " />
RowNo
<input type="text" disabled="disabled" value="" name="rowno" id="rowno"style="width:10px; margin-right: 5px; " />
</div>
<div id="content">
<div id="table"  class="scroll"></div>
</div>
</div>
<script>
var arr = _dimension(50);
_b = _HEADERS.split(',');
function ajax2()
{
s= 'http://192.168.10.80:8080/hr/tableRead?'+
'table='+_TABLE+'&'+
'fields='+_HEADERS+'&'+
'&format='+_FORMATS+'&'+
'where='+_CONSTRAINT+'&'+
'callback=?';
$.getJSON(s,
function(data) {
if (data[0]){
_gentable("td_id",_b.length+1,data.length);
for (rr=0 ; rr<data.length; rr++){
for (a=0;a<_b.length;a++){
_1=_b[a];
_value=data[rr][a];
_refresh("td_id"+"["+(rr+1)+"]"+"["+(a+1)+"]",_value);
}
}
}  else { alert("tableData.jsp : No This Number ");}
}
); //endofgetJson
}

$('#td_id th').css('width','1000px');
$("th").css("background-color","yellow");

$( "#content" ).delegate( "*", "focus blur", function( event ) {
var elem = $( this );
setTimeout(function() {elem.toggleClass( "focused", elem.is( ":focus" ) );}, 0);
});
function clock(){
now = new Date();hours = now.getHours();minutes = now.getMinutes();seconds = now.getSeconds();
//$.ajax({url: "heartbeat"})
timeValue = hours+':'+((minutes < 10) ? "0":"") + minutes + ":"+((seconds < 10) ? "0":"") + seconds ;
_refreshv("clock",timeValue);
setTimeout("clock()",1000);
}
theader='<table border="1" id="td_id"> ';tfooter='</table>';
tbody='<tr><th></th>';
var _b =_HEADERS.split(',');for (a in _b){tbody=tbody+"<th>"+_b[a]+"</th>";}
tbody=tbody+"</tr>"
_11=theader+tbody+tfooter;
document.getElementById('table').innerHTML = _11
$(document).ready( function() {
ajax2();
    $.getJSON( "http://smart-ip.net/geoip-json?callback=?",
    function(data){_refreshv("ip",data.host);});
    clock();
    _refreshv('browser',_getlevel());
});
</script>
</body>
</html>


沒有留言:

張貼留言