Skip to content

Commit 8a0a618

Browse files
author
Dominik Tomasi
committed
compare versions in a separated function
1 parent 25ee435 commit 8a0a618

1 file changed

Lines changed: 17 additions & 42 deletions

File tree

system/modules/multicolumnwizard/html/js/multicolumnwizard_be_src.js

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -757,34 +757,27 @@ MultiColumnWizard.addOperationClickCallback('down', MultiColumnWizard.downClick)
757757
};
758758
})(window.Backend);
759759

760+
760761
/**
761-
* Simply compares two string version values.
762-
*
763-
* Example:
764-
* versionCompare('1.1', '1.2') => -1
765-
* versionCompare('1.1', '1.1') => 0
766-
* versionCompare('1.2', '1.1') => 1
767-
* versionCompare('2.23.3', '2.22.3') => 1
768-
*
769-
* Returns:
770-
* -1 = left is LOWER than right
771-
* 0 = they are equal
772-
* 1 = left is GREATER = right is LOWER
773-
* And FALSE if one of input versions are not valid
774-
*
775-
* @function
776-
* @param {String} left Version #1
777-
* @param {String} right Version #2
778-
* @return {Integer|Boolean}
779-
* @author Alexey Bass (albass)
780-
* @since 2011-07-14
762+
* Compare Versions
781763
*/
782-
versionCompare = function(left, right) {
783-
if (typeof left + typeof right != 'stringstring')
764+
versionCompare = function(toCompare) {
765+
766+
// Get Version-Class and convert it to a valid Version-String
767+
var version = $('top').get('class').match(/version_[^\s]*/);
768+
version = version[0];
769+
version = version.replace('version_', '');
770+
version = version.split('-').join('.');
771+
772+
if (typeof version !== 'string') {
773+
return false;
774+
}
775+
776+
if (typeof toCompare + typeof version != 'stringstring')
784777
return false;
785778

786-
var a = left.split('.')
787-
, b = right.split('.')
779+
var a = toCompare.split('.')
780+
, b = version.split('.')
788781
, i = 0, len = Math.max(a.length, b.length);
789782

790783
for (; i < len; i++) {
@@ -797,21 +790,3 @@ versionCompare = function(left, right) {
797790

798791
return 0;
799792
};
800-
801-
/**
802-
* Parse the Version of Contao from Class "top"
803-
* see: MultiColumnWizardHelper::addVersionToClass()
804-
*
805-
* @function
806-
* @return {String}
807-
*/
808-
parseContaoVersion = function() {
809-
810-
// Get Version-Class and convert it to a valid Version-String
811-
var version = $('top').get('class').match(/version_[^\s]*/);
812-
version = version[0];
813-
version = version.replace('version_', '');
814-
version = version.split('-').join('.');
815-
816-
return version
817-
};

0 commit comments

Comments
 (0)