diff --git a/public/javascripts/views/sheet.js b/public/javascripts/views/sheet.js
index 81c34c4..e1e42cb 100644
--- a/public/javascripts/views/sheet.js
+++ b/public/javascripts/views/sheet.js
@@ -265,7 +265,7 @@ var Sheet = Backbone.View.extend({
toCSV: function() {
var that = this;
function formatValue(text) {
- return /[";\n]/.test(text)
+ return new RegExp("[\";"+config.csv_separator+"\\n]").test(text)
? "\"" + text.replace(/\"/g, "\"\"") + "\""
: text;
}
@@ -273,16 +273,16 @@ var Sheet = Backbone.View.extend({
var res = "";
// Headers
properties = this.groupedItems.properties().map(function(p) { return formatValue(p.name); }).values();
- res += properties.join(';')+"\n";
+ res += properties.join(config.csv_separator)+"\n";
// Items
this.groupedItems.items().each(function(item) {
var values = that.groupedItems.properties().map(function(p) {
- return formatValue(item.get(p.key));
+ return _.include(p.expectedTypes, "number") ? formatValue((item.get(p.key)+"").replace(".", ","))
+ : formatValue(item.get(p.key));
}).values();
- res += values.join(';')+"\n";
+ res += values.join(config.csv_separator)+"\n";
});
-
return res;
},
diff --git a/server.js b/server.js
index ff64436..f8735a7 100644
--- a/server.js
+++ b/server.js
@@ -284,12 +284,21 @@ function findDatasources(req, callback) {
}
+function clientConfig() {
+ return {
+ "number_format": config.number_format,
+ "csv_separator": config.csv_separator
+ };
+}
+
+
// Routes
// -----------
app.get('/', function(req, res) {
html = fs.readFileSync(__dirname+ '/templates/app.html', 'utf-8');
res.send(html.replace('{{{{seed}}}}', JSON.stringify(seed))
+ .replace('{{{{config}}}}', JSON.stringify(clientConfig()))
.replace('{{{{session}}}}', JSON.stringify(req.session)));
});
diff --git a/templates/app.html b/templates/app.html
index 8f712c6..61a79ab 100644
--- a/templates/app.html
+++ b/templates/app.html
@@ -7,6 +7,7 @@