1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

Update media/src/api/api.static.js

Slightly shorter method for checking the version (stops as soon as it reaches a version part that has a difference)
This commit is contained in:
Tim Tucker 2012-09-30 11:07:24 -03:00
parent 6b605936f7
commit 7f35d4fb4d

View File

@ -1,5 +1,4 @@
/**
* Provide a common method for plug-ins to check the version of DataTables being used, in order
* to ensure compatibility.
@ -15,25 +14,24 @@
*/
DataTable.fnVersionCheck = function( sVersion )
{
/* This is cheap, but effective */
var fnZPad = function (Zpad, count)
{
while(Zpad.length < count) {
Zpad += '0';
}
return Zpad;
};
var aThis = DataTable.ext.sVersion.split('.');
var aThat = sVersion.split('.');
var sThis = '', sThat = '';
var iThis, sThat;
for ( var i=0, iLen=aThat.length ; i<iLen ; i++ )
{
sThis += fnZPad( aThis[i], 3 );
sThat += fnZPad( aThat[i], 3 );
for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ){
iThis = parseInt( aThis[i], 10 ) || 0;
iThat = parseInt( aThat[i], 10 ) || 0;
// Parts are the same, keep comparing
if (iThis === iThat)
{
continue;
}
// Parts are different, return immediately
return iThis > iThat;
}
return parseInt(sThis, 10) >= parseInt(sThat, 10);
return true;
};