mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-10-05 09:41:59 +02:00
[refactor] Better version check and compare
This commit is contained in:
parent
37e95f8775
commit
c480736d23
BIN
images/icon-128.png
Normal file
BIN
images/icon-128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
images/icon-16.png
Normal file
BIN
images/icon-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
images/icon-48.png
Normal file
BIN
images/icon-48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
images/icon.psd
Normal file
BIN
images/icon.psd
Normal file
Binary file not shown.
16
js/update.js
16
js/update.js
@ -155,6 +155,7 @@ var update = (function() {
|
|||||||
console.log("\t -- running update", 1.00);
|
console.log("\t -- running update", 1.00);
|
||||||
data = _update_100(data);
|
data = _update_100(data);
|
||||||
};
|
};
|
||||||
|
if (typeof data.version == "number") {
|
||||||
if (data.version < 2.00) {
|
if (data.version < 2.00) {
|
||||||
console.log("\t -- running update", 2.00);
|
console.log("\t -- running update", 2.00);
|
||||||
data = _update_200(data);
|
data = _update_200(data);
|
||||||
@ -191,9 +192,22 @@ var update = (function() {
|
|||||||
console.log("\t -- running update", 2.91);
|
console.log("\t -- running update", 2.91);
|
||||||
data.version = 2.91;
|
data.version = 2.91;
|
||||||
};
|
};
|
||||||
|
if (data.version < 2.96) {
|
||||||
|
// introduction of a new semantic version check function so the version is being bumped to 2.10.0 and changed to a string
|
||||||
|
console.log("\t -- running update", "2.10.0");
|
||||||
|
data.version = "2.10.0";
|
||||||
|
};
|
||||||
|
} else if (typeof data.version == "string") {
|
||||||
|
// new updates will go here
|
||||||
|
// example update compare check
|
||||||
|
// if (version.compare(data.version, "2.11.0") == -1) {
|
||||||
|
// console.log("\t -- running update", "2.11.0");
|
||||||
|
// data.version = "2.11.0";
|
||||||
|
// };
|
||||||
|
};
|
||||||
// if no update is needed
|
// if no update is needed
|
||||||
// version bump
|
// version bump
|
||||||
if (data.version < version.get()) {
|
if (version.compare(data.version, version.get()) == -1) {
|
||||||
console.log("\t -- nothing to update, version bump to", version.get());
|
console.log("\t -- nothing to update, version bump to", version.get());
|
||||||
data.version = version.get();
|
data.version = version.get();
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,38 @@
|
|||||||
var version = (function() {
|
var version = (function() {
|
||||||
|
|
||||||
// version is normally bumped when the state needs changing or any new functionality is added
|
// version is normally bumped when the state needs changing or any new functionality is added
|
||||||
var current = "2.9.5";
|
var current = "2.10.0";
|
||||||
|
|
||||||
|
var compare = function(a, b) {
|
||||||
|
var pa = a.split(".");
|
||||||
|
var pb = b.split(".");
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
var na = Number(pa[i]);
|
||||||
|
var nb = Number(pb[i]);
|
||||||
|
if (na > nb) {
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
if (nb > na) {
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
if (!isNaN(na) && isNaN(nb)) {
|
||||||
|
return 1;
|
||||||
|
};
|
||||||
|
if (isNaN(na) && !isNaN(nb)) {
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
var get = function() {
|
var get = function() {
|
||||||
var number = current.split(".");
|
return current;
|
||||||
return parseFloat(number.shift() + "." + number.join(""));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// exposed methods
|
// exposed methods
|
||||||
return {
|
return {
|
||||||
get: get
|
get: get,
|
||||||
|
compare: compare
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -5,5 +5,10 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"chrome_url_overrides": {
|
"chrome_url_overrides": {
|
||||||
"newtab": "index.html"
|
"newtab": "index.html"
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"16": "images/icon-16.png",
|
||||||
|
"48": "images/icon-48.png",
|
||||||
|
"128": "images/icon-128.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user