Skip to content

Commit d1510dd

Browse files
committed
separate rendering from conversion in datatable
1 parent 074740d commit d1510dd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

js/cypher.datatable.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function convertResult(data) {
2222
var newRow = [];
2323
for (var col = 0; col < count; col++) {
2424
var value = convertCell(currentRow[columns[col]]);
25-
newRow[col] = value;
25+
newRow[col] = render(value);
2626
result.columns[col].sWidth = Math.max(value.length * CHAR_WIDTH, result.columns[col].sWidth);
2727
}
2828
result.data[row] = newRow;
@@ -37,6 +37,15 @@ function convertResult(data) {
3737
}
3838
return result;
3939
}
40+
function render(cell) {
41+
if (typeof cell === 'string') {
42+
if (cell.match(/^https?:/)) {
43+
if (cell.match(/(jpg|png|gif)$/i)) return '<img style="display:inline;max-height:100%" src="'+cell+'">';
44+
return '<a href="'+cell+'" target="_blank">'+cell+'</a>';
45+
};
46+
}
47+
return cell;
48+
}
4049

4150
function convertCell(cell) {
4251
if (cell == null) {
@@ -63,12 +72,6 @@ function convertCell(cell) {
6372
}
6473
return props(cell);
6574
}
66-
if (typeof cell === 'string') {
67-
if (cell.match(/^https?:/)) {
68-
if (cell.match(/(jpg|png|gif)$/i)) return '<img style="display:inline;max-height:100%" src="'+cell+'">';
69-
return '<a href="'+cell+'" target="_blank">'+cell+'</a>';
70-
};
71-
}
7275
return cell;
7376
}
7477

0 commit comments

Comments
 (0)