Made tablesorter work without inline-js

Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
This commit is contained in:
Roman Schmerold (BNoiZe) 2014-12-02 17:27:41 +01:00
parent 9627238966
commit 6f5f69db2b
7 changed files with 139 additions and 140 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
$.tablesorter.addParser({
id: 'filesize',
is: function(s) {
return s.match(new RegExp(/[0-9]+(\.[0-9]+)?\ (KiB|B|GiB|MiB|TiB)/));
},
format: function(s) {
var suf = s.match(new RegExp(/(KiB|B|GiB|MiB|TiB)/))[1];
var num = parseFloat(s.match(new RegExp(/^[0-9]+(\.[0-9]+)?/))[0]);
switch (suf) {
case 'B':
return num;
case 'KiB':
return num * 1024;
case 'MiB':
return num * 1024 * 1024;
case 'GiB':
return num * 1024 * 1024 * 1024;
case 'TiB':
return num * 1024 * 1024 * 1024 * 1024;
}
},
type: 'numeric'
});

View File

@ -1,37 +1,10 @@
$header
<script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
<script type="text/javascript">
$.tablesorter.addParser( {
id: 'filesize',
is: function(s) {
return s.match( new RegExp( /[0-9]+(\.[0-9]+)?\ (KiB|B|GiB|MiB|TiB)/ ) );
},
format: function(s) {
var suf = s.match( new RegExp( /(KiB|B|GiB|MiB|TiB)/) )[1];
var num = parseFloat( s.match( new RegExp( /^[0-9]+(\.[0-9]+)?/ ) )[0] );
switch( suf ) {
case 'B':
return num;
case 'KiB':
return num * 1024;
case 'MiB':
return num * 1024 * 1024;
case 'GiB':
return num * 1024 * 1024 * 1024;
case 'TiB':
return num * 1024 * 1024 * 1024 * 1024;
}
},
type: 'numeric'
});
</script>
<article>
<header>
<h2>
<img src="templates/{$theme}/assets/img/icons/traffic_big.png" alt="{$lng['admin']['traffic']}" />&nbsp;{$lng['admin']['traffic']} &nbsp;
</h2>
</header>
{$stats_tables}
</article>
</div>
<article>
<header>
<h2>
<img src="templates/{$theme}/assets/img/icons/traffic_big.png" alt="{$lng['admin']['traffic']}" />&nbsp;{$lng['admin']['traffic']} &nbsp;
</h2>
</header>
{$stats_tables}
</article>
$footer

View File

@ -1,6 +1,6 @@
<h3>{$lng['traffic']['trafficoverview']}&nbsp;{$overview['type']}&nbsp;{$overview['year']}</h3>
<section>
<table class="full" id="stats{$overview['year']}">
<table class="full" id="stats{$overview['year']}" data-toggle="table">
<thead>
<tr>
<th>{$overview['type']}</th>
@ -26,38 +26,5 @@
</tfoot>
</table>
</section>
<script type="text/javascript">
var myTextExtraction = function(node)
{
// extract data from markup and return it
if(node.innerHTML != '-') {
return 1 + node.innerHTML.substr(0,node.innerHTML.length);
} else {
return '0 B';
}
}
$(document).ready(function()
{
$("#stats{$overview['year']}").tablesorter( {
textExtraction: myTextExtraction,
headers: {
1: {sorter: 'filesize'},
2: {sorter: 'filesize'},
3: {sorter: 'filesize'},
4: {sorter: 'filesize'},
5: {sorter: 'filesize'},
6: {sorter: 'filesize'},
7: {sorter: 'filesize'},
8: {sorter: 'filesize'},
9: {sorter: 'filesize'},
10: {sorter: 'filesize'},
11: {sorter: 'filesize'},
12: {sorter: 'filesize'}
},
});
}
);
</script>
<br />
<br />

View File

@ -1044,6 +1044,26 @@ div.right {
margin-left: 50%;
}
/* TABLESORTER */
.tablesorter-header-inner {
margin-left: 15px;
}
table thead th.tablesorter-headerUnSorted {
background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
background-repeat: no-repeat;
background-position: left center;
}
table thead th.tablesorter-headerAsc {
background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
background-repeat: no-repeat;
background-position: left center;
}
table thead th.tablesorter-headerDesc {
background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
background-repeat: no-repeat;
background-position: left center;
}
/* PROGRESS */
.bar[aria-valuemax="100"][aria-valuemin="0"][aria-valuenow="0"] {
width: 0%;

View File

@ -1,10 +1,9 @@
function twoDigits(value) {
if(value < 10) {
return '0' + value;
}
return value;
if (value < 10) {
return '0' + value;
}
return value;
}
$(document).ready(function() {
// Scroll to top
$(window).scroll(function() {
@ -14,18 +13,17 @@ $(document).ready(function() {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function() {
$("html, body").animate({ scrollTop: 0 }, 600);
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
// Back buttons
$('#historyback, .historyback').click(function() {
parent.history.back();
return false;
});
// Load Newsfeed
var ajax_load = "<div id='newsitem'>Loading newsfeed...</div>";
var role = "";
@ -38,31 +36,27 @@ $(document).ready(function() {
$("#newsfeed").slideDown();
}
});
// Enable Infobubbles
$(".tipper").tipper({
direction: "right"
});
// Enable reset search click
$(".resetsearch").click(function() {
$(".searchtext").val("");
$(".submitsearch").click();
});
// Height of divs fix
var snheight = $('#sidenavigation').height();
var mainheight = $('#maincontent').height();
if (snheight > mainheight && !$('#newsfeed').length) {
$('#maincontent').height(snheight);
}
// this is necessary for the special setting feature (ref #1010)
$.getQueryVariable = function(key) {
var urlParams = decodeURI( window.location.search.substring(1) );
if(urlParams === false | urlParams === '') return null;
var urlParams = decodeURI(window.location.search.substring(1));
if (urlParams === false | urlParams === '') return null;
var vars = urlParams.split("&");
for (var i=0;i<vars.length;i++) {
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == key) {
return pair[1];
@ -70,65 +64,85 @@ $(document).ready(function() {
}
return null;
};
if ($('#speciallogwarningpopup').length) {
var $speciallogdialog = $('#speciallogwarningpopup')
.dialog({
autoOpen: false,
closeOnEscape: false,
draggable: false,
modal: true,
resizable: false
});
var $speciallogdialog = $('#speciallogwarningpopup').dialog({
autoOpen: false,
closeOnEscape: false,
draggable: false,
modal: true,
resizable: false
});
}
// make rel="external" links open in a new window
$("a[rel='external']").attr('target', '_blank');
// set focus on username-field if on loginpage
$("#loginname").focus();
// Auto-select next field in configfile - wizard
$('#config_distribution').change(function (){
window.location.href=window.location.href + '&distribution=' + this.options[ this.selectedIndex ].value;
$('#config_distribution').change(function() {
window.location.href = window.location.href + '&distribution=' + this.options[this.selectedIndex].value;
});
$('#config_service').change(function (){
window.location.href=window.location.href + '&service=' + this.options[ this.selectedIndex ].value;
$('#config_service').change(function() {
window.location.href = window.location.href + '&service=' + this.options[this.selectedIndex].value;
});
$('#config_daemon').change(function (){
window.location.href=window.location.href + '&daemon=' + this.options[ this.selectedIndex ].value;
$('#config_daemon').change(function() {
window.location.href = window.location.href + '&daemon=' + this.options[this.selectedIndex].value;
});
// Speciallogfile popup dialog
$('input[name=speciallogfile]').click(function () {
if($.getQueryVariable("page") == "domains" && $.getQueryVariable("action") == "edit") {
$speciallogdialog.dialog("open");
$(".ui-dialog-titlebar").hide();
}
});
$('#speciallogyesbutton').click(function () {
$speciallogdialog.dialog("close");
if($('#delete_stats').val().toLowerCase() != $('#delete_statistics_str').val().toLowerCase()) {
$("#speciallogverified").val("0");
if($('input[name=speciallogfile]').prop("checked") !== false) {
$('input[name=speciallogfile]').attr("checked", false);
} else {
$('input[name=speciallogfile]').attr("checked", true);
}
} else {
$("#speciallogverified").val("1");
}
});
$('input[id=speciallognobutton]').click(function () {
$speciallogdialog.dialog("close");
$("#speciallogverified").val("0");
if($('input[name=speciallogfile]').prop("checked") !== false) {
$('input[name=speciallogfile]').attr("checked", false);
} else {
$('input[name=speciallogfile]').attr("checked", true);
}
});
$('input[name=speciallogfile]').click(function() {
if ($.getQueryVariable("page") == "domains" && $.getQueryVariable("action") == "edit") {
$speciallogdialog.dialog("open");
$(".ui-dialog-titlebar").hide();
}
});
$('#speciallogyesbutton').click(function() {
$speciallogdialog.dialog("close");
if ($('#delete_stats').val().toLowerCase() != $('#delete_statistics_str').val().toLowerCase()) {
$("#speciallogverified").val("0");
if ($('input[name=speciallogfile]').prop("checked") !== false) {
$('input[name=speciallogfile]').attr("checked", false);
} else {
$('input[name=speciallogfile]').attr("checked", true);
}
} else {
$("#speciallogverified").val("1");
}
});
$('input[id=speciallognobutton]').click(function() {
$speciallogdialog.dialog("close");
$("#speciallogverified").val("0");
if ($('input[name=speciallogfile]').prop("checked") !== false) {
$('input[name=speciallogfile]').attr("checked", false);
} else {
$('input[name=speciallogfile]').attr("checked", true);
}
});
// Tablesorting on admin traffic
$("table").each(function(index) {
if ($(this).data("toggle") == "table") {
$(this).tablesorter({
textExtraction: (function(node) {
// extract data from markup and return it
if (node.innerText != '-') {
return node.innerText;
} else {
return '0 B';
}
}),
headers: {
1: { sorter: 'filesize' },
2: { sorter: 'filesize' },
3: { sorter: 'filesize' },
4: { sorter: 'filesize' },
5: { sorter: 'filesize' },
6: { sorter: 'filesize' },
7: { sorter: 'filesize' },
8: { sorter: 'filesize' },
9: { sorter: 'filesize' },
10: { sorter: 'filesize' },
11: { sorter: 'filesize' },
12: { sorter: 'filesize' }
},
});
}
});
});

View File

@ -9,6 +9,8 @@
</if>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="js/plugins/jquery.tablesorter.sizeparser.min.js"></script>
<!--[if lt IE 9]><script type="text/javascript" src="js/html5shiv.min.js"></script><![endif]-->
<if isset($intrafficpage)>
<!--[if lt IE 9]><script type="text/javascript" src="js/excanvas.min.js"></script><![endif]-->