forked from FOSS/BangleApps
Add changing size through Settings
parent
c09ff6fa36
commit
3da2306c81
|
@ -1,3 +1,4 @@
|
|||
1.0: Local cards data
|
||||
1.1: Download cards data from Trello public board
|
||||
1.2: Configuration instructions added and card layout optimized
|
||||
1.2: Configuration instructions added and card layout optimized
|
||||
1.3: Font size can be changed in Settings
|
||||
|
|
|
@ -3,27 +3,27 @@
|
|||
* We believe in Finnish
|
||||
*/
|
||||
|
||||
// Constants
|
||||
let SWAP_SIDE_BUZZ_MILLISECONDS = 50;
|
||||
let CARD_DATA_FILE = "flashcards.data.json";
|
||||
let CARD_EMPTY = "found no cards";
|
||||
let CARD_LINE_LENGTH = 8;
|
||||
let CARD_LINE_FONT = "20%";
|
||||
|
||||
// Modules
|
||||
var Layout = require("Layout");
|
||||
var locale = require("locale");
|
||||
var storage = require("Storage");
|
||||
|
||||
// Global variables
|
||||
var cards = [];
|
||||
var cardIndex = 0;
|
||||
var backSide = false;
|
||||
let SWAP_SIDE_BUZZ_MILLISECONDS = 50;
|
||||
let CARD_DATA_FILE = "flashcards.data.json";
|
||||
let CARD_SETTINGS_FILE = "flashcards.settings.json";
|
||||
let CARD_EMPTY = "no cards found";
|
||||
let cards = [];
|
||||
let cardIndex = 0;
|
||||
let backSide = false;
|
||||
let drawTimeout = undefined;
|
||||
|
||||
let settings = storage.readJSON(CARD_SETTINGS_FILE,1) || { litsId: "", fontSize: "20%", textSize: 9 };
|
||||
|
||||
// Cards data
|
||||
function wordWrap(str, maxLength) {
|
||||
if (maxLength == undefined) {
|
||||
maxLength = CARD_LINE_LENGTH;
|
||||
maxLength = settings.textSize;
|
||||
}
|
||||
let res = '';
|
||||
while (str.length > maxLength) {
|
||||
|
@ -76,7 +76,6 @@ function refreshCards(cardsJSON,showMsg)
|
|||
}
|
||||
|
||||
// Drawing a card
|
||||
let drawTimeout;
|
||||
let queueDraw = function() {
|
||||
let timeout = 60000;
|
||||
if (drawTimeout) clearTimeout(drawTimeout);
|
||||
|
@ -86,10 +85,10 @@ let queueDraw = function() {
|
|||
}, timeout - (Date.now() % timeout));
|
||||
};
|
||||
|
||||
var cardLayout = new Layout( {
|
||||
let cardLayout = new Layout( {
|
||||
type:"v", c: [
|
||||
{type:"txt", font:"6x8:3", label:"", id:"widgets", fillx:1 },
|
||||
{type:"txt", font:CARD_LINE_FONT, label:"ABCDEFGHIJ KLMNOPQRST UVWXYZÅÖÄ", filly:1, fillx:1, id:"card" },
|
||||
{type:"txt", font:settings.fontSize, label:"ABCDEFGHIJ KLMNOPQRST UVWXYZÅÖÄ", filly:1, fillx:1, id:"card" },
|
||||
{type:"txt", font:"6x8:2", label:"00:00", id:"clock", fillx:1, bgCol:g.theme.fg, col:g.theme.bg }
|
||||
]
|
||||
}, {lazy:true});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "flashcards",
|
||||
"name": "Flash Cards",
|
||||
"shortName": "Flash Cards",
|
||||
"version": "1.2",
|
||||
"version": "1.3",
|
||||
"description": "Flash cards based on public Trello board",
|
||||
"readme":"README.md",
|
||||
"screenshots" : [ { "url":"screenshot.png" }],
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
var trelloURL = "https://api.trello.com/1/lists/$cardsListId/cards/?fields=name%2Cdesc%2Clist";
|
||||
|
||||
var settings = Object.assign({
|
||||
listId: ""
|
||||
listId: "",
|
||||
textSize: 9,
|
||||
fontSize: "20%"
|
||||
}, storage.readJSON(settingsFile, true) || {});
|
||||
|
||||
function writeSettings() {
|
||||
|
@ -17,12 +19,18 @@
|
|||
var settingsMenu = {
|
||||
"" : { "title" : "Flash Cards" },
|
||||
"< Back" : () => back(),
|
||||
/*"List ID": {
|
||||
value: settings.listId,
|
||||
onchange: v=> { settings.listId=v; writeSettings();}
|
||||
}
|
||||
,*/
|
||||
"Get from Trello": () => {
|
||||
/*LANG*/"Font Size": {
|
||||
value: settings.fontSize,
|
||||
min: 0, max: 2,
|
||||
format: v => ["15%","20%","25%"][v],
|
||||
onchange: v => { settings.fontSize = v; writeSettings(); }
|
||||
},
|
||||
/*LANG*/"Text Size": {
|
||||
value: settings.textSize,
|
||||
min: 4, max: 14,
|
||||
onchange: v => { settings.textSize = v; writeSettings(); }
|
||||
},
|
||||
/*LANG*/"Get from Trello": () => {
|
||||
if (!storage.read(settingsFile)) { writeSettings();}
|
||||
E.showPrompt("Download cards?").then((v) => {
|
||||
let delay = 500;
|
||||
|
|
Loading…
Reference in New Issue