Difference between revisions of "Template:Publications"

(Created page with "<table id="tablepaging" class="yui" align="center"> <thead> <tr> <th>Name </th> <th>Major </th> <th>Sex </th> <th>English </th> <th>Tamil </th> <th>Calculus </th> <th>Geometr...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<table id="tablepaging" class="yui" align="center">
+
<html>
<thead>
+
<script type="text/javascript">
<tr>
+
function Pager(tableName, itemsPerPage) {
<th>Name </th>
+
this.tableName = tableName;
<th>Major </th>
+
this.itemsPerPage = itemsPerPage;
<th>Sex </th>
+
this.currentPage = 1;
<th>English </th>
+
this.pages = 0;
<th>Tamil </th>
+
this.inited = false;
<th>Calculus </th>
+
this.showRecords = function(from, to) {
<th>Geometry </th>
+
var rows = document.getElementById(tableName).rows;
</tr>
+
for (var i = 1; i < rows.length; i++) {
</thead>
+
if (i < from || i > to)
<tbody>
+
rows[i].style.display = 'none';
<tr class="even">
+
else
<td>Student01 </td>
+
rows[i].style.display = '';
<td>Languages </td>
+
}
<td>M </td>
+
}
<td>80 </td>
+
this.showPage = function(pageNumber) {
<td>70 </td>
+
if (! this.inited) {
<td>75 </td>
+
alert("not inited");
<td>80 </td>
+
return;
</tr>
+
}
<tr class="odd">
+
var oldPageAnchor = document.getElementById('pg'+this.currentPage);
 
+
oldPageAnchor.className = 'pg-normal';
<td>Student02 </td>
+
this.currentPage = pageNumber;
<td>Languages </td>
+
var newPageAnchor = document.getElementById('pg'+this.currentPage);
<td>M </td>
+
newPageAnchor.className = 'pg-selected';
<td>80 </td>
+
var from = (pageNumber - 1) * itemsPerPage + 1;
<td>70 </td>
+
var to = from + itemsPerPage - 1;
<td>75 </td>
+
this.showRecords(from, to);
<td>80 </td>
+
}
</tr>
+
this.prev = function() {
</tbody>
+
if (this.currentPage > 1)
</table>
+
this.showPage(this.currentPage - 1);
 +
}
 +
this.next = function() {
 +
if (this.currentPage < this.pages) {
 +
this.showPage(this.currentPage + 1);
 +
}
 +
}
 +
this.init = function() {
 +
var rows = document.getElementById(tableName).rows;
 +
var records = (rows.length - 1);
 +
this.pages = Math.ceil(records / itemsPerPage);
 +
this.inited = true;
 +
}
 +
this.showPageNav = function(pagerName, positionId) {
 +
if (! this.inited) {
 +
alert("not inited");
 +
return;
 +
}
 +
var element = document.getElementById(positionId);
 +
var pagerHtml = '<span onclick="' + pagerName + '.prev();" class="pg-normal"> « Prev </span> ';
 +
for (var page = 1; page <= this.pages; page++)
 +
pagerHtml += '<span id="pg' + page + '" class="pg-normal" onclick="' + pagerName + '.showPage(' + page + ');">' + page + '</span> ';
 +
pagerHtml += '<span onclick="'+pagerName+'.next();" class="pg-normal"> Next »</span>';
 +
element.innerHTML = pagerHtml;
 +
}
 +
}
 +
</script>
 +
</html>

Latest revision as of 18:22, 16 May 2014