Revision: 2518
https://sourceforge.net/p/mrbs/code/2518/
Author: cimorrison
Date: 2012-10-22 16:06:34 +0000 (Mon, 22 Oct 2012)
Log Message:
-----------
Restructured code
Modified Paths:
--------------
mrbs/trunk/web/js/datatables.js.php
mrbs/trunk/web/js/report.js.php
Modified: mrbs/trunk/web/js/datatables.js.php
===================================================================
--- mrbs/trunk/web/js/datatables.js.php 2012-10-22 15:19:54 UTC (rev 2517)
+++ mrbs/trunk/web/js/datatables.js.php 2012-10-22 16:06:34 UTC (rev 2518)
@@ -12,6 +12,41 @@
echo "'use strict';\n";
}
+
+// Get the sTypes, which are assumed to be in a data-sType in a <span> in the
<th>
+// of the table
+?>
+var getSTypes = function getSTypes(table) {
+ var type,
+ types = {},
+ sTypes = [];
+
+ table.find('thead tr:first th').each(function(i) {
+ var type = $(this).find('span').data('stype');
+ if (type)
+ {
+ if (types[type] === undefined)
+ {
+ types[type] = [];
+ }
+ types[type].push(i);
+ }
+ });
+
+ for (type in types)
+ {
+ if (types.hasOwnProperty(type))
+ {
+ sTypes.push({sType: type,
+ aTargets: types[type]});
+ }
+ }
+
+ return sTypes;
+ };
+
+
+<?php
// Try and get a sensible value for the fixed column width, which is the
// smaller of the actual column width and either a fixed width or a
// proportion of the overall table width.
@@ -97,7 +132,7 @@
oTable = table.dataTable(mergedOptions);
}, 200);
- }
+ };
if (lteIE6)
{
@@ -107,7 +142,7 @@
else
{
var table = $(id);
- if (table.length == 0)
+ if (table.length === 0)
{
return false;
}
@@ -185,7 +220,7 @@
// from the column visibility list because it is fixed and (b) stop it
// being reordered
?>
- var colVisExcludeCols = []
+ var colVisExcludeCols = [];
if ((leftCol !== undefined) && (leftCol !== null))
{
colVisExcludeCols.push(0);
Modified: mrbs/trunk/web/js/report.js.php
===================================================================
--- mrbs/trunk/web/js/report.js.php 2012-10-22 15:19:54 UTC (rev 2517)
+++ mrbs/trunk/web/js/report.js.php 2012-10-22 16:06:34 UTC (rev 2518)
@@ -186,28 +186,9 @@
var table = $('#report_table');
<?php
- // Get the sTypes (which are in a data-sType in a <span> in the <th>) and
- // feed those into dataTables
+ // Get the sTypes and feed those into dataTables
?>
- var sTypes = {};
- table.find('thead tr:first th').each(function(i) {
- var type = $(this).find('span').data('stype');
- if (type)
- {
- if (sTypes[type] === undefined)
- {
- sTypes[type] = [];
- }
- sTypes[type].push(i);
- }
- });
- tableOptions.aoColumnDefs = [];
- var type;
- for (type in sTypes)
- {
- tableOptions.aoColumnDefs.push({sType: type,
- aTargets: sTypes[type]});
- }
+ tableOptions.aoColumnDefs = getSTypes(table);
<?php
// Fix the left hand column. This has to be done when initialisation is
@@ -237,7 +218,7 @@
.click(function() {
var aData = reportTable.fnGetFilteredData();
var nEntries = aData.length;
- if (confirm("<?php echo
escape_js(get_vocab('delete_entries_warning')) ?>" +
+ if (window.confirm("<?php echo
escape_js(get_vocab('delete_entries_warning')) ?>" +
nEntries.toLocaleString()))
{
<?php
@@ -288,7 +269,7 @@
{
if (!isInt.test(results[i]))
{
- alert("<?php echo
escape_js(get_vocab('delete_entries_failed')) ?>");
+ window.alert("<?php echo
escape_js(get_vocab('delete_entries_failed')) ?>");
break;
}
nDeleted += parseInt(results[i], 10);
@@ -302,7 +283,7 @@
var oSettings = reportTable.fnSettings();
if (oSettings.sAjaxSource &&
!oSettings.bServerSide &&
- ($('#div_summary').length == 0))
+ ($('#div_summary').length === 0))
{
reportTable.fnReloadAjax();
<?php
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits