* Onelinerz nearly complete - only really need preview MCI implemented

* Added luciano_blocktronics styled onelinerz - need same style for add oneliner still
This commit is contained in:
Bryan Ashby 2016-06-29 23:23:06 -06:00
parent 9bb08c3d54
commit 96348d5ed8
4 changed files with 85 additions and 25 deletions

View File

@ -135,7 +135,7 @@
} }
TM2: { TM2: {
argName: addOrExit argName: addOrExit
items: [ "hell yeah!", "nah" ] items: [ "yeah!", "nah" ]
submit: true submit: true
focus: true focus: true
} }
@ -152,18 +152,22 @@
} }
] ]
} }
actionKeys: [
{
keys: [ "escape" ]
action: @systemMethod:nextMenu
}
]
}, },
1: { 1: {
mci: { mci: {
ET1: { ET1: {
focus: true focus: true
// :TODO: fix this length maxLength: 70
maxLength: 30
width: 30
argName: oneliner argName: oneliner
} }
TL2: { TL2: {
width: 20 width: 60
} }
TM3: { TM3: {
argName: addOrCancel argName: addOrCancel
@ -184,6 +188,12 @@
} }
] ]
} }
actionKeys: [
{
keys: [ "escape" ]
action: @method:cancelAdd
}
]
} }
} }
} }

View File

@ -112,9 +112,14 @@ function OnelinerzModule(options) {
let entries = []; let entries = [];
self.db.each( self.db.each(
`SELECT user_id, user_name, oneliner, timestamp `SELECT *
FROM (
SELECT *
FROM onelinerz FROM onelinerz
LIMIT ${limit};`, ORDER BY timestamp DESC
LIMIT ${limit}
)
ORDER BY timestamp ASC;`,
(err, row) => { (err, row) => {
if(!err) { if(!err) {
row.timestamp = moment(row.timestamp); // convert -> moment row.timestamp = moment(row.timestamp); // convert -> moment
@ -127,19 +132,15 @@ function OnelinerzModule(options) {
); );
}, },
function populateEntries(entriesView, entries, callback) { function populateEntries(entriesView, entries, callback) {
const listFormat = config.listFormat || '{username}: {oneliner}'; const listFormat = config.listFormat || '{username}@{ts}: {oneliner}';// :TODO: should be userName to be consistent
const tsFormat = config.timestampFormat || 'ddd h:mma';
// :TODO: remove meh:
//entries = [
// { user_id : 1, user_name : 'NuSkooler', oneliner : 'Boojahhhh!!!', timestamp : '2016-06-04' }
//]
entriesView.setItems(entries.map( e => { entriesView.setItems(entries.map( e => {
return listFormat.format( { return listFormat.format( {
userId : e.user_id, userId : e.user_id,
username : e.user_name, username : e.user_name,
oneliner : e.oneliner, oneliner : e.oneliner,
ts : e.timestamp.toString(), // :TODO: allow custom TS formatting - see e.g. last_callers.js ts : e.timestamp.format(tsFormat),
} ); } );
})); }));
@ -221,6 +222,10 @@ function OnelinerzModule(options) {
const oneliner = formData.value.oneliner.trim(); // remove any trailing ws const oneliner = formData.value.oneliner.trim(); // remove any trailing ws
self.storeNewOneliner(oneliner, err => { self.storeNewOneliner(oneliner, err => {
if(err) {
self.client.log.warn( { error : err.message }, 'Failed saving oneliner');
}
self.clearAddForm(); self.clearAddForm();
self.displayViewScreen(true); // true=cls self.displayViewScreen(true); // true=cls
}); });
@ -268,15 +273,31 @@ function OnelinerzModule(options) {
this.storeNewOneliner = function(oneliner, cb) { this.storeNewOneliner = function(oneliner, cb) {
const ts = moment().format('YYYY-MM-DDTHH:mm:ss.SSSZ'); const ts = moment().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
// :TODO: Keep max of N (e.g. 25) & change retrieval to show most recent N (height) async.series(
[
function addRec(callback) {
self.db.run( self.db.run(
`INSERT INTO onelinerz (user_id, user_name, oneliner, timestamp) `INSERT INTO onelinerz (user_id, user_name, oneliner, timestamp)
VALUES (?, ?, ?, ?);`, VALUES (?, ?, ?, ?);`,
[ self.client.user.userId, self.client.user.username, oneliner, ts ], [ self.client.user.userId, self.client.user.username, oneliner, ts ],
err => { callback
return cb(err); );
},
function removeOld(callback) {
// keep 25 max most recent items - remove the older ones
self.db.run(
`DELETE FROM onelinerz
WHERE id IN (
SELECT id
FROM onelinerz
ORDER BY id DESC
LIMIT -1 OFFSET 25
);`,
callback
);
} }
],
cb
); );
}; };
} }

Binary file not shown.

View File

@ -84,6 +84,29 @@
} }
} }
loginOnelinerz: {
config: {
listFormat: "|00|11{username:<12}|08: |03{oneliner:<59.58}"
}
0: {
mci: {
VM1: { height: 10 }
TM2: {
focusTextStyle: first lower
}
}
}
1: {
mci: {
ET1: { width: 60 }
TL2: { width: 60 }
TM3: {
focusTextStyle: first lower
}
}
}
}
mainMenuUserStats: { mainMenuUserStats: {
mci: { mci: {
UN1: { width: 17 } UN1: { width: 17 }
@ -336,6 +359,12 @@
} }
} }
} }
ercClient: {
config: {
//chatEntryFormat: "|00|08[|03{bbsTag}|08] |10{userName}|08: |02{message}"
}
}
} }
} }
} }