Skip to content

Commit bd46361

Browse files
committed
[refactor] improve update module
1 parent 9ddb144 commit bd46361

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

‎src/js/update.js‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
varupdate=(function(){
22

3+
varmod={};
4+
35
// this associative array contains all the updates. add a new entry if you need to modify data.
46
// example, this assumes the previous version is less than 3.28.0:
57
// "3.28.0": function(data){
68
// return data;
79
// };
810
// always add the version in increasing order so the most recent version is last.
9-
var_update={
11+
mod.all={
1012
"1.0.0": function(data){
1113
data.version="1.0.0";
1214
returndata;
@@ -593,10 +595,10 @@ var update = (function(){
593595
}
594596
};
595597

596-
functionrun(data){
598+
mod.run=function(data){
597599
// legacy update as first version of nightTab did not have a version number stored in the state object
598600
if(!("version"indata)){
599-
data=_update["1.0.0"](data);
601+
data=mod.all["1.0.0"](data);
600602
};
601603

602604
// old version numbers were type of number
@@ -607,11 +609,11 @@ var update = (function(){
607609
data.version=data.version.join(".");
608610
};
609611

610-
// loop over all updates in _update object
611-
for(varkeyin_update){
612+
// loop over all updates in mod.all object
613+
for(varkeyinmod.all){
612614
if(version.compare(data.version,key)==-1){
613615
console.log("\t > running update",key);
614-
data=_update[key](data);
616+
data=mod.all[key](data);
615617
data.version=key;
616618
};
617619
};
@@ -625,9 +627,13 @@ var update = (function(){
625627
returndata;
626628
};
627629

630+
varrun=function(data){
631+
returnmod.run(data);
632+
};
633+
628634
// exposed methods
629635
return{
630-
_update: _update,
636+
mod: mod,
631637
run: run
632638
};
633639

‎src/js/version.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
varversion=(function(){
22

3-
varcurrent="3.59.1";
3+
varcurrent="3.60.0";
44

55
varcompare=function(a,b){
66
varpa=a.split(".");

‎src/manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nightTab",
33
"short_name": "nightTab",
44
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
5-
"version": "3.59.1",
5+
"version": "3.60.0",
66
"manifest_version": 2,
77
"chrome_url_overrides":{
88
"newtab": "index.html"

0 commit comments

Comments
(0)