Add better sorting
parent
567d124a6a
commit
fcab506202
|
|
@ -50,7 +50,7 @@ the *default* of `To RAM`
|
||||||
{"name":"+7chname","url":"my-great-app.json"},
|
{"name":"+7chname","url":"my-great-app.json"},
|
||||||
{"name":"-7chname","url":"my-great-app.js"},
|
{"name":"-7chname","url":"my-great-app.js"},
|
||||||
{"name":"*7chname","url":"my-great-app.js","evaluate":true}
|
{"name":"*7chname","url":"my-great-app.js","evaluate":true}
|
||||||
]
|
],
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -74,7 +74,9 @@ the *default* of `To RAM`
|
||||||
"evaluate":true // if supplied, data isn't quoted into a String before upload
|
"evaluate":true // if supplied, data isn't quoted into a String before upload
|
||||||
// (eg it's evaluated as JS)
|
// (eg it's evaluated as JS)
|
||||||
},
|
},
|
||||||
|
"sortorder" : 0, // optional - choose where in the list this goes.
|
||||||
|
// this should only really be used to put system
|
||||||
|
// stuff at the top
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
5
index.js
5
index.js
|
|
@ -2,7 +2,12 @@ var appJSON = []; // List of apps and info from apps.json
|
||||||
var appsInstalled = []; // list of app IDs
|
var appsInstalled = []; // list of app IDs
|
||||||
|
|
||||||
httpGet("apps.json").then(apps=>{
|
httpGet("apps.json").then(apps=>{
|
||||||
|
try {
|
||||||
appJSON = JSON.parse(apps);
|
appJSON = JSON.parse(apps);
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
showToast("App List Corrupted","error");
|
||||||
|
}
|
||||||
appJSON.sort(appSorter);
|
appJSON.sort(appSorter);
|
||||||
refreshLibrary();
|
refreshLibrary();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
4
utils.js
4
utils.js
|
|
@ -33,5 +33,9 @@ function toJS(txt) {
|
||||||
function appSorter(a,b) {
|
function appSorter(a,b) {
|
||||||
if (a.unknown || b.unknown)
|
if (a.unknown || b.unknown)
|
||||||
return (a.unknown)? 1 : -1;
|
return (a.unknown)? 1 : -1;
|
||||||
|
var sa = 0|a.sortorder;
|
||||||
|
var sb = 0|b.sortorder;
|
||||||
|
if (sa<sb) return -1;
|
||||||
|
if (sa>sb) return 1;
|
||||||
return (a.name==b.name) ? 0 : ((a.name<b.name) ? -1 : 1);
|
return (a.name==b.name) ? 0 : ((a.name<b.name) ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue