Wrote a stand-alone function for calculating the signature of a version string. Works from 0 to 99.99.99.99_S99, where _ is any/no filler and S is 'a', 'b', 'g', 'r', or 'rc' [case-insensitive].
Tested it in both IE7 and FF2 (I don't have any others installed, atm). I'm sure it could use some revamping; so, let me know what you think. Current test results: 900 : 0 0 : 0a 900 : 0h 201 : 0.0.0.0_g1 99999999900 : 99.99.99.99 99999999899 : 99.99.99.99_RC99 1050000900 : 1.5.0 1050100801 : 1.5.1_rc1 1050100802 : 1.5.1_rc2 1050100803 : 1.5.1_rc3 1050100804 : 1.5.1_rc4 1050100900 : 1.5.1 1050101900 : 1.5.1.1 1050102900 : 1.5.1.2 1060000800 : 1.6.0_rc0 1060000801 : 1.6.0_rc1 1060000900 : 1.6.0 1060001900 : 1.6.0.1 1060002900 : 1.6.0.2 var Version = { signature : function (vstr) { // VVvvRRrrSss or VVvvRRBBSss // or: version, sub-version, release, revision or build, stage, stage number var stages = { 's' : 9, // stable 'r' : 8, // release candidate 'g' : 2, // gamma 'b' : 1, // beta 'a' : 0 // alpha }; var sig = 0; var vers = vstr === String(vstr) ? vstr : this.version; var vnum, rnum = /^\s*[0-9\.]+/; // version number var vstg, rstg = /(r(c)?|g|b|a)[0-9]*\s*$/i; // version stage var vsch, vsnm; // version stage character and number var vspl; // version number split if (!!vers.match(rnum)) { vnum = vers.match(rnum)[0]; vstg = !!vers.match(rstg) ? vers.match(rstg)[0] : ''; vsch = !vstg.match(/^[a-z]+/i) ? 's' : vstg.match(/^[a-z]+/i) [0].charAt(0).toLowerCase(); vsnm = !vstg.match(/[0-9]+$/) ? '0' : vstg.match(/[0-9]+$/); vspl = vnum.split('.').slice(0, 4); vspl = vspl.concat([0, 0, 0, 0].splice(0, (4 - vspl.length))); sig += (parseInt(vspl[0], 10) % 100) * Math.pow(10, 9); sig += (parseInt(vspl[1], 10) % 100) * Math.pow(10, 7); sig += (parseInt(vspl[2], 10) % 100) * Math.pow(10, 5); sig += (parseInt(vspl[3], 10) % 100) * Math.pow(10, 3); sig += (!!stages[vsch] ? stages[vsch] : 0) * 100; sig += parseInt(vsnm, 10) % 100; } return sig; } }; - Jon L. On Feb 11, 7:41 pm, "Jon L." <[EMAIL PROTECTED]> wrote: > An alternative could be to use the release date: > > var Prototype = { > Version: '1.6.0.2', > Release: '01/25/2008' > ... > > }; > > if(Date(Prototype.Release) >= Date('11/07/2007')) { // 1.6.0 (November > 7, 2007) > ... > > } > > On Feb 11, 6:55 pm, tancurrom <[EMAIL PROTECTED]> wrote: > > > Build: '5234724' > > Be cautious with the use of strings. > e.g. Prototype.Build >= '6102' returns false ('5' < '6'). > > - Jon L. > > On Feb 11, 6:55 pm, tancurrom <[EMAIL PROTECTED]> wrote: > > > I think using a build number is considerably easier to manipulate in > > the code. Its considerably more specific that a version number. > > But include both > > > var Prototype = { > > Build: '5234724', > > Version: '1.6.0.3', > > ... > > > or > > > var Prototype = { > > Build: '5234724', // v1.6.0.3 > > ... > > > I can actually think when I'm going to need to call the > > Prototype.Version for my code. Let the librarys match it easier. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---