Commit 5d9d8cf7 authored by Remi Rampin's avatar Remi Rampin

Add link to Twitter handles

parent 83ee2c57
......@@ -45,11 +45,16 @@
<script type="text/javascript">
function format_link(link){
if (link)
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
else
function format_twitter_link(text){
if(text) {
if(text[0] !== "@") {
console.error("Invalid Twitter handle " + text);
}
var handle = text.substring(1);
return '<a href="https://twitter.com/' + handle + '" target="_blank">' + text + "</a>";
} else {
return "";
}
}
CsvToHtmlTable.init({
......@@ -58,6 +63,13 @@
allow_download: true,
csv_options: {separator: ',', delimiter: '"'},
columns: [0, 1, 2],
row_transform: function(row, idx) {
if(idx === 0) {
return row;
}
row[1] = format_twitter_link(row[1]);
return row;
},
datatables_options: {"autoWidth" : true, "paging" : false}
});
</script>
......
......@@ -11,6 +11,7 @@ CsvToHtmlTable = {
var datatables_options = options.datatables_options || {};
var custom_formatting = options.custom_formatting || [];
var columns = options.columns;
var row_transform = options.row_transform;
$("#" + el).html("<table class='table table-striped table-condensed' id='" + el + "-table'></table>");
......@@ -26,6 +27,10 @@ CsvToHtmlTable = {
});
}
if(row_transform) {
csv_data = csv_data.map(row_transform);
}
var table_head = "<thead><tr>";
for (head_id = 0; head_id < csv_data[0].length; head_id++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment