mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 15:15:34 +00:00
More refactoring and porting to React
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { term, format } from '../i18n/Language';
|
||||
|
||||
export default function comparisonBBCode(facets, builds, link) {
|
||||
|
||||
/**
|
||||
* Generate a BBCode (Forum) compatible table from comparisons
|
||||
* @param {Function} translate Translate language function
|
||||
* @param {object} formats Number Formats
|
||||
* @param {array} facets Ship Facets
|
||||
* @param {object} builds Ship builds
|
||||
* @param {string} link Link to the comparison
|
||||
* @return {string} the BBCode
|
||||
*/
|
||||
export default function comparisonBBCode(translate, formats, facets, builds, link) {
|
||||
var colCount = 2, b, i, j, k, f, fl, p, pl, l = [];
|
||||
|
||||
for (i = 0; i < facets.length; i++) {
|
||||
@@ -9,11 +18,11 @@ export default function comparisonBBCode(facets, builds, link) {
|
||||
p = f.props;
|
||||
|
||||
if (p.length == 1) {
|
||||
l.push('[th][B][COLOR=#FF8C0D]', term(f.title).toUpperCase(), '[/COLOR][/B][/th]');
|
||||
l.push('[th][B][COLOR=#FF8C0D]', translate(f.title).toUpperCase(), '[/COLOR][/B][/th]');
|
||||
colCount++;
|
||||
} else {
|
||||
for (j = 0; j < p.length; j++) {
|
||||
l.push('[th][B][COLOR=#FF8C0D]', term(f.title).toUpperCase(), '\n', term(f.lbls[j]).toUpperCase(), '[/COLOR][/B][/th]');
|
||||
l.push('[th][B][COLOR=#FF8C0D]', translate(f.title).toUpperCase(), '\n', translate(f.lbls[j]).toUpperCase(), '[/COLOR][/B][/th]');
|
||||
colCount++;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +32,7 @@ export default function comparisonBBCode(facets, builds, link) {
|
||||
|
||||
for (i = 0; i < builds.length; i++) {
|
||||
b = builds[i];
|
||||
//var href = $state.href('outfit',{shipId: b.id, code: b.code, bn: b.buildName}, {absolute: true});
|
||||
|
||||
l.push('[tr][td]', b.name, '[/td][td]', b.buildName, '[/td]');
|
||||
|
||||
for (j = 0, fl = facets.length; j < fl; j++) {
|
||||
@@ -31,7 +40,7 @@ export default function comparisonBBCode(facets, builds, link) {
|
||||
f = facets[j];
|
||||
p = f.props;
|
||||
for (k = 0, pl = p.length; k < pl; k++) {
|
||||
l.push('[td="align: right"]', format[f.fmt](b[p[k]]), ' [size=-2]', term(f.unit), '[/size][/td]');
|
||||
l.push('[td="align: right"]', formats[f.fmt](b[p[k]]), ' [size=-2]', translate(f.unit), '[/size][/td]');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user