mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-04 00:41:56 +02:00
* Various cleanup + utility methods
This commit is contained in:
parent
d242546458
commit
f2388ceed1
6 changed files with 68 additions and 21 deletions
24
core/art.js
24
core/art.js
|
@ -368,26 +368,22 @@ function defaultEofFromExtension(ext) {
|
|||
// cb(err, mci)
|
||||
|
||||
// :TODO: display({ art : art, client : client, ...}, cb)
|
||||
function display(art, options, cb) {
|
||||
if(!art || 0 === art.length) {
|
||||
cb(new Error('Missing or empty art'));
|
||||
return;
|
||||
}
|
||||
function display(options, cb) {
|
||||
assert(
|
||||
'undefined' !== typeof options &&
|
||||
'undefined' !== typeof options.client &&
|
||||
'undefined' !== typeof options.art,
|
||||
'Missing required options');
|
||||
|
||||
if('undefined' === typeof options) {
|
||||
cb(new Error('Missing options'));
|
||||
return;
|
||||
}
|
||||
|
||||
if('undefined' === typeof options.client) {
|
||||
cb(new Error('Missing client in options'));
|
||||
if(0 === options.art.length) {
|
||||
cb(new Error('Empty art'));
|
||||
return;
|
||||
}
|
||||
|
||||
var cancelKeys = miscUtil.valueWithDefault(options.cancelKeys, []);
|
||||
var pauseKeys = miscUtil.valueWithDefault(options.pauseKeys, []);
|
||||
var pauseAtTermHeight = miscUtil.valueWithDefault(options.pauseAtTermHeight, false);
|
||||
var mciReplaceChar = miscUtil.valueWithDefault(options.mciReplaceChar, '');
|
||||
var mciReplaceChar = miscUtil.valueWithDefault(options.mciReplaceChar, ' ');
|
||||
|
||||
// :TODO: support pause/cancel & pause @ termHeight
|
||||
var canceled = false;
|
||||
|
@ -464,5 +460,5 @@ function display(art, options, cb) {
|
|||
}
|
||||
});
|
||||
|
||||
parser.parse(art);
|
||||
parser.parse(options.art);
|
||||
}
|
|
@ -12,6 +12,7 @@ exports.getThemeInfo = getThemeInfo;
|
|||
exports.getThemeArt = getThemeArt;
|
||||
exports.getRandomTheme = getRandomTheme;
|
||||
exports.initAvailableThemes = initAvailableThemes;
|
||||
exports.displayThemeArt = displayThemeArt;
|
||||
|
||||
function getThemeInfo(themeID, cb) {
|
||||
var path = paths.join(Config.paths.themes, themeID, 'theme_info.json');
|
||||
|
@ -108,4 +109,16 @@ function getThemeArt(name, themeID, options, cb) {
|
|||
cb(null, theArt.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function displayThemeArt(name, client, cb) {
|
||||
getThemeArt(name, client.user.properties.art_theme_id, function onArt(err, theArt) {
|
||||
if(err) {
|
||||
cb(err);
|
||||
} else {
|
||||
art.display( { art : theArt, client : client }, function onDisplayed(err, mci) {
|
||||
cb(err, mci);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
|
@ -10,14 +10,14 @@ var assert = require('assert');
|
|||
|
||||
exports.TickerTextView = TickerTextView;
|
||||
|
||||
TickerTextView = function(client, options) {
|
||||
function TickerTextView(client, options) {
|
||||
View.call(this, client, options);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.text = this.options.text || '';
|
||||
this.tickerStyle = this.options.tickerStyle || 'rightToLeft';
|
||||
asssert(this.tickerStyle in TickerTextView.TickerStyles);
|
||||
assert(this.tickerStyle in TickerTextView.TickerStyles);
|
||||
|
||||
// :TODO: Ticker |text| should have ANSI stripped before calculating any lengths/etc.
|
||||
// strUtil.ansiTextLength(s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue