mirror of https://github.com/espruino/BangleApps
Initial commit of widcw
widcw is a widget to display the current calendar week.pull/1506/head
parent
f7ab9adb56
commit
7ce25c8774
|
@ -0,0 +1 @@
|
||||||
|
0.01: First version
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="48"
|
||||||
|
height="48"
|
||||||
|
viewBox="0 0 12.7 12.7"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5"
|
||||||
|
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
|
||||||
|
sodipodi:docname="logo.svg"
|
||||||
|
inkscape:export-filename="/home/klomp/Repositories/BangleApps/apps/widcw/widget.png"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview7"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
width="48px"
|
||||||
|
inkscape:zoom="16.106622"
|
||||||
|
inkscape:cx="29.242631"
|
||||||
|
inkscape:cy="21.481848"
|
||||||
|
inkscape:window-width="1061"
|
||||||
|
inkscape:window-height="439"
|
||||||
|
inkscape:window-x="2326"
|
||||||
|
inkscape:window-y="806"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-weight:bold;font-size:5.6446px;line-height:2.4ex;font-family:Orbitron;-inkscape-font-specification:'Orbitron Bold';text-align:end;letter-spacing:0.21961px;word-spacing:0px;writing-mode:lr-tb;text-anchor:end;fill:none;stroke:#000000;stroke-width:0.264591px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
x="11.591952"
|
||||||
|
y="-4.2952275"
|
||||||
|
id="text3356"
|
||||||
|
inkscape:export-filename="/home/klomp/Repositories/BangleApps/apps/widcw/widget.png"
|
||||||
|
inkscape:export-xdpi="96"
|
||||||
|
inkscape:export-ydpi="96"
|
||||||
|
transform="scale(0.99997031,-1.0000297)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3354"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:5.6446px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.264591px"
|
||||||
|
x="11.811562"
|
||||||
|
y="-4.2952275">CW</tspan></text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.3 KiB |
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"id": "widcw",
|
||||||
|
"name": "Calendar Week Widget",
|
||||||
|
"version": "0.01",
|
||||||
|
"description": "Widget which shows the current calendar week",
|
||||||
|
"icon": "widget.png",
|
||||||
|
"type": "widget",
|
||||||
|
"tags": "widget,calendar",
|
||||||
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
|
"storage": [
|
||||||
|
{"name":"widcw.wid.js","url":"widget.js"}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
(function() {
|
||||||
|
var width = 22; // width of the widget
|
||||||
|
|
||||||
|
function draw() {
|
||||||
|
const x = this.x, y = this.y, x2 = x+21, y2 = y+23;
|
||||||
|
|
||||||
|
var date = new Date();
|
||||||
|
|
||||||
|
// Calculate calendar week (https://stackoverflow.com/a/6117889)
|
||||||
|
getCW= function(date){
|
||||||
|
var d=new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||||
|
var dayNum = d.getDay() || 7;
|
||||||
|
d.setDate(d.getDate() + 4 - dayNum);
|
||||||
|
var yearStart = new Date(d.getFullYear(),0,1);
|
||||||
|
return Math.ceil((((d - yearStart) / 86400000) + 1)/7);
|
||||||
|
};
|
||||||
|
|
||||||
|
g.reset().setFontAlign(0, 0) // center all text
|
||||||
|
// header
|
||||||
|
.setBgColor("#f00").setColor("#fff")
|
||||||
|
.clearRect(x, y, x2, y+8).setFont("4x6").drawString("CW", (x+x2)/2+1, y+5)
|
||||||
|
// date
|
||||||
|
.setBgColor("#fff").setColor("#000")
|
||||||
|
.clearRect(x, y+9, x2, y2).setFont("Vector:16").drawString(getCW(date), (x+x2)/2+2, y+17);
|
||||||
|
|
||||||
|
if (!g.theme.dark) {
|
||||||
|
// black border around date for light themes
|
||||||
|
g.setColor("#000").drawPoly([
|
||||||
|
x, y+9,
|
||||||
|
x, y2,
|
||||||
|
x2, y2,
|
||||||
|
x2, y+9
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// redraw when date changes
|
||||||
|
setTimeout(()=>WIDGETS["widcw"].draw(), (86401 - Math.floor(date/1000) % 86400)*1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// add your widget
|
||||||
|
WIDGETS["widcw"]={
|
||||||
|
area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right)
|
||||||
|
width: width, // how wide is the widget? You can change this and call Bangle.drawWidgets() to re-layout
|
||||||
|
draw:draw // called to draw the widget
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
Binary file not shown.
After Width: | Height: | Size: 884 B |
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
width="48"
|
||||||
|
height="48"
|
||||||
|
viewBox="0 0 12.7 12.7"
|
||||||
|
version="1.1"
|
||||||
|
id="svg5"
|
||||||
|
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20, custom)"
|
||||||
|
sodipodi:docname="logo.svg"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="namedview7"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
width="48px"
|
||||||
|
inkscape:zoom="16.106622"
|
||||||
|
inkscape:cx="29.211588"
|
||||||
|
inkscape:cy="21.450805"
|
||||||
|
inkscape:window-width="1918"
|
||||||
|
inkscape:window-height="1158"
|
||||||
|
inkscape:window-x="1366"
|
||||||
|
inkscape:window-y="20"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer1" />
|
||||||
|
<defs
|
||||||
|
id="defs2" />
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-weight:bold;font-size:5.64444px;line-height:2.4ex;font-family:Orbitron;-inkscape-font-specification:'Orbitron Bold';text-align:end;letter-spacing:0.219604px;word-spacing:0px;writing-mode:lr-tb;text-anchor:end;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
x="11.591612"
|
||||||
|
y="8.4046535"
|
||||||
|
id="text3356"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan3354"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:5.64444px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';fill:#000000;stroke-width:0.264583px"
|
||||||
|
x="11.811215"
|
||||||
|
y="8.4046535">CW</tspan></text>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue