| | |
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
Autor | Správa |
---|
Registrovaný: 11.01.09 Prihlásený: 17.07.22 Príspevky: 371 Témy: 181 Bydlisko: BB | Napísal d0.0b: 22.09.2009 15:59 | |
|
Caute uz 2 dni si lámem hlavu nad tým ako by som mohol toto použiŤ
Kód: function getVersionArray(version) { // initialize variables var subVerCheck, mainVer, subVer, versionBits, i;
// check if we have a subversion (x.y.z Beta 1 etc.) if (subVerCheck = version.match(/^([a-zA-Z]+ )?([0-9\.]+)\s*([a-zA-Z].*)$/)) { mainVer = subVerCheck[2]; subVer = subVerCheck[3].toUpperCase(); } else { // there is no sub-version mainVer = version; subVer = ""; }
// split the main version by periods versionBits = mainVer.split(".");
// if the main version number does not have 4 components, create the missing ones as zeroes if (versionBits.length < 4) { for (i = versionBits.length; i < 4; i++) { versionBits[i] = 0; } }
// add default subversion numbers versionBits[4] = 0; versionBits[5] = 0;
// check if we have a sub-version if (subVer != "") { // attempt to match the sub-version string if (matches = subVer.match(/^(A|ALPHA|B|BETA|G|GAMMA|RC|RELEASE CANDIDATE|GOLD|STABLE|FINAL|PL|PATCH LEVEL|PATCH)\s*(\d*)$/i)) { // check the value of the sub-version type (beta/rc etc.) switch(matches[1]) { // alpha: set the value to -4 case "A": case "ALPHA": versionBits[4] = -4; break;
// beta: set the value to -3 case "B": case "BETA": versionBits[4] = -3; break;
// gamma: set the value to -2 case "G": case "GAMMA": versionBits[4] = -2; break;
// release candidate: set the value to -1 case "RC": case "RELEASE CANDIDATE": versionBits[4] = -1; break;
// patch version: set value to 1 case "PL": case "PATCH LEVEL": case "PATCH": versionBits[4] = 1; break;
// something else: set the value to 0 case "GOLD": case "STABLE": case "FINAL": default: versionBits[4] = 0; }
// add the matches to the versionBits array versionBits[5] = matches[2]; } }
// ensure that each element of the versionBits array is an integer for (i = 0; i < 6; i++) { if (!(versionBits[i] = parseInt(versionBits[i]))) { versionBits[i] = 0; } }
/* for(var i = 0; i < versionBits.length; i++) { document.write("Version '" + version + "' part " + i + ": <b>" + versionBits[i] + "</b><br />"); } document.write('<hr />'); */
// return the completed array return versionBits; }
// ############################################################################################## // compares the array of integers from two version numbers to see if one is newer than the other function isNewerVersion(thisVersion, latestVersion) { // initialize variables var curVersion, newVersion, i;
// are the version numbers different? if (thisVersion != latestVersion) { // get arrays from the version numbers curVersion = getVersionArray(thisVersion); newVersion = getVersionArray(latestVersion);
// check each element of the arrays against each other for (i = 0; i < 6; i++) { // is the 'new' value the same as the 'current' value? if (newVersion[i] != curVersion[i]) { // values are not the same - return true if greater, false if lesser return (newVersion[i] > curVersion[i]); } } }
return false; }
|
|
Registrovaný: 31.05.09 Prihlásený: 02.06.17 Príspevky: 562 Témy: 37 Bydlisko: BegyBen |
To ti mame povedat ako to mas pouzit? Ten skript som dobre nestudoval ale zrejme ide o to ze tak vkladas nejaky retazec o tato funkcia ti z toho urci verziu niecoho
|
|
Registrovaný: 13.11.07 Prihlásený: 20.08.16 Príspevky: 1702 Témy: 0 | Napísal chrono: 22.09.2009 21:53 | |
|
Z názvu tej funkcie (a jej popisu) je jasné, na čo to slúži a tebe taká funkcia bude úplne zbytočná.
|
|
| Stránka: 1 z 1
| [ Príspevkov: 3 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
| Cena tohto PC v Informujem sa | 2 | 370 | 02.06.2015 9:45 kllr007 | | nazov tohto scriptu v JavaScript, VBScript, Ajax | 3 | 425 | 13.12.2009 23:40 Romanko | | Výkon tohto procesora v AMD - Advanced Micro Devices | 5 | 798 | 13.10.2009 20:25 Jaro | | Nazov tohto softu? v Mobilné zariadenia | 1 | 547 | 18.03.2009 6:20 Jaro | | Hodnotenie Tohto Webu v Webdesign | 15 | 1183 | 02.12.2009 21:37 don jebot | | Názov skriptu v Redakčné systémy | 2 | 3379 | 17.07.2007 19:49 pepek92 | | Zavolanie skriptu v JavaScript, VBScript, Ajax | 8 | 866 | 17.04.2008 14:06 Ded'leg | | Ma moznost tohto vystupu ? v ATI/AMD grafické karty | 0 | 532 | 16.02.2009 19:11 icefire | | [VYRIESENE] Bezpečnosť skriptu v PHP, ASP | 25 | 831 | 20.02.2009 13:44 Tominator | | wmp chyba skriptu v Audio programy | 0 | 1120 | 23.09.2010 23:43 MiGi | | Perl - spustenie skriptu v Perl, Python, Ruby, CGI | 2 | 1370 | 02.08.2010 15:27 DARSON | | Limitované spustenie skriptu? v PHP, ASP | 1 | 334 | 18.05.2010 18:33 JanoF | | Testovanie rýchlosti skriptu v PHP, ASP | 0 | 429 | 04.09.2012 21:17 1daemon1 | | aku grafiku do tohto pc?? v Grafické karty | 25 | 1414 | 17.11.2008 12:45 pukepulos | | poradte aku grafiku do tohto v Grafické karty | 16 | 796 | 06.11.2007 16:07 Xaltotun | | aka je hodnota tohto počitača? v Informujem sa | 3 | 296 | 01.08.2015 16:16 Xaltotun |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|