vim auto indentation
parent
4aeecee636
commit
7ca80bb1d3
|
|
@ -1,18 +1,18 @@
|
||||||
{ // must be inside our own scope here so that when we are unloaded everything disappears
|
{ // must be inside our own scope here so that when we are unloaded everything disappears
|
||||||
|
|
||||||
/* Desktop launcher
|
/* Desktop launcher
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let settings = Object.assign({
|
let settings = Object.assign({
|
||||||
showClocks: true,
|
showClocks: true,
|
||||||
showLaunchers: true,
|
showLaunchers: true,
|
||||||
direct: false,
|
direct: false,
|
||||||
swipeExit: false,
|
swipeExit: false,
|
||||||
timeOut: "Off"
|
timeOut: "Off"
|
||||||
}, require('Storage').readJSON("dtlaunch.json", true) || {});
|
}, require('Storage').readJSON("dtlaunch.json", true) || {});
|
||||||
|
|
||||||
let s = require("Storage");
|
let s = require("Storage");
|
||||||
var apps = s.list(/\.info$/).map(app=>{
|
var apps = s.list(/\.info$/).map(app=>{
|
||||||
let a=s.readJSON(app,1);
|
let a=s.readJSON(app,1);
|
||||||
return a && {
|
return a && {
|
||||||
|
|
@ -20,28 +20,28 @@ let s = require("Storage");
|
||||||
};}).filter(
|
};}).filter(
|
||||||
app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || (app.type=="launch" && settings.showLaunchers) || !app.type));
|
app=>app && (app.type=="app" || (app.type=="clock" && settings.showClocks) || (app.type=="launch" && settings.showLaunchers) || !app.type));
|
||||||
|
|
||||||
apps.sort((a,b)=>{
|
apps.sort((a,b)=>{
|
||||||
let n=(0|a.sortorder)-(0|b.sortorder);
|
let n=(0|a.sortorder)-(0|b.sortorder);
|
||||||
if (n) return n; // do sortorder first
|
if (n) return n; // do sortorder first
|
||||||
if (a.name<b.name) return -1;
|
if (a.name<b.name) return -1;
|
||||||
if (a.name>b.name) return 1;
|
if (a.name>b.name) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
apps.forEach(app=>{
|
apps.forEach(app=>{
|
||||||
if (app.icon)
|
if (app.icon)
|
||||||
app.icon = s.read(app.icon); // should just be a link to a memory area
|
app.icon = s.read(app.icon); // should just be a link to a memory area
|
||||||
});
|
});
|
||||||
|
|
||||||
let Napps = apps.length;
|
let Napps = apps.length;
|
||||||
let Npages = Math.ceil(Napps/4);
|
let Npages = Math.ceil(Napps/4);
|
||||||
let maxPage = Npages-1;
|
let maxPage = Npages-1;
|
||||||
let selected = -1;
|
let selected = -1;
|
||||||
let oldselected = -1;
|
let oldselected = -1;
|
||||||
let page = 0;
|
let page = 0;
|
||||||
const XOFF = 24;
|
const XOFF = 24;
|
||||||
const YOFF = 30;
|
const YOFF = 30;
|
||||||
|
|
||||||
let drawIcon= function(p,n,selected) {
|
let drawIcon= function(p,n,selected) {
|
||||||
let x = (n%2)*72+XOFF;
|
let x = (n%2)*72+XOFF;
|
||||||
let y = n>1?72+YOFF:YOFF;
|
let y = n>1?72+YOFF:YOFF;
|
||||||
(selected?g.setColor(g.theme.fgH):g.setColor(g.theme.bg)).fillRect(x+11,y+3,x+60,y+52);
|
(selected?g.setColor(g.theme.fgH):g.setColor(g.theme.bg)).fillRect(x+11,y+3,x+60,y+52);
|
||||||
|
|
@ -65,9 +65,9 @@ let drawIcon= function(p,n,selected) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.drawString(line.trim(),x+36,y+54+lineY*8);
|
g.drawString(line.trim(),x+36,y+54+lineY*8);
|
||||||
};
|
};
|
||||||
|
|
||||||
let drawPage = function(p){
|
let drawPage = function(p){
|
||||||
g.reset();
|
g.reset();
|
||||||
g.clearRect(0,24,175,175);
|
g.clearRect(0,24,175,175);
|
||||||
let O = 88+YOFF/2-12*(Npages/2);
|
let O = 88+YOFF/2-12*(Npages/2);
|
||||||
|
|
@ -82,12 +82,12 @@ let drawPage = function(p){
|
||||||
drawIcon(p,i,selected==i && !settings.direct);
|
drawIcon(p,i,selected==i && !settings.direct);
|
||||||
}
|
}
|
||||||
g.flip();
|
g.flip();
|
||||||
};
|
};
|
||||||
|
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
drawPage(0);
|
drawPage(0);
|
||||||
|
|
||||||
let swipeListenerDt = function(dirLeftRight, dirUpDown){
|
let swipeListenerDt = function(dirLeftRight, dirUpDown){
|
||||||
updateTimeoutToClock();
|
updateTimeoutToClock();
|
||||||
selected = 0;
|
selected = 0;
|
||||||
oldselected=-1;
|
oldselected=-1;
|
||||||
|
|
@ -99,16 +99,16 @@ let swipeListenerDt = function(dirLeftRight, dirUpDown){
|
||||||
--page; if (page<0) page=maxPage;
|
--page; if (page<0) page=maxPage;
|
||||||
drawPage(page);
|
drawPage(page);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let isTouched = function(p,n){
|
let isTouched = function(p,n){
|
||||||
if (n<0 || n>3) return false;
|
if (n<0 || n>3) return false;
|
||||||
let x1 = (n%2)*72+XOFF; let y1 = n>1?72+YOFF:YOFF;
|
let x1 = (n%2)*72+XOFF; let y1 = n>1?72+YOFF:YOFF;
|
||||||
let x2 = x1+71; let y2 = y1+81;
|
let x2 = x1+71; let y2 = y1+81;
|
||||||
return (p.x>x1 && p.y>y1 && p.x<x2 && p.y<y2);
|
return (p.x>x1 && p.y>y1 && p.x<x2 && p.y<y2);
|
||||||
};
|
};
|
||||||
|
|
||||||
let touchListenerDt = function(_,p){
|
let touchListenerDt = function(_,p){
|
||||||
updateTimeoutToClock();
|
updateTimeoutToClock();
|
||||||
let i;
|
let i;
|
||||||
for (i=0;i<4;i++){
|
for (i=0;i<4;i++){
|
||||||
|
|
@ -131,25 +131,25 @@ let touchListenerDt = function(_,p){
|
||||||
drawIcon(page,selected,false);
|
drawIcon(page,selected,false);
|
||||||
selected=-1;
|
selected=-1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Bangle.setUI({
|
Bangle.setUI({
|
||||||
mode : 'custom',
|
mode : 'custom',
|
||||||
back : Bangle.showClock,
|
back : Bangle.showClock,
|
||||||
swipe : swipeListenerDt,
|
swipe : swipeListenerDt,
|
||||||
touch : touchListenerDt,
|
touch : touchListenerDt,
|
||||||
remove : ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);}
|
remove : ()=>{if (timeoutToClock) clearTimeout(timeoutToClock);}
|
||||||
});
|
});
|
||||||
|
|
||||||
// taken from Icon Launcher with minor alterations
|
// taken from Icon Launcher with minor alterations
|
||||||
let timeoutToClock;
|
let timeoutToClock;
|
||||||
const updateTimeoutToClock = function(){
|
const updateTimeoutToClock = function(){
|
||||||
if (settings.timeOut!="Off"){
|
if (settings.timeOut!="Off"){
|
||||||
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
|
let time=parseInt(settings.timeOut); //the "s" will be trimmed by the parseInt
|
||||||
if (timeoutToClock) clearTimeout(timeoutToClock);
|
if (timeoutToClock) clearTimeout(timeoutToClock);
|
||||||
timeoutToClock = setTimeout(Bangle.showClock,time*1000);
|
timeoutToClock = setTimeout(Bangle.showClock,time*1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
updateTimeoutToClock();
|
updateTimeoutToClock();
|
||||||
|
|
||||||
} // end of app scope
|
} // end of app scope
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue