export csv
This commit is contained in:
parent
2b81162fbf
commit
b42b14eed8
|
@ -100,6 +100,7 @@
|
|||
<li>Global Speed: <input type="text" style="width:30px" value="20" class="default_speed"><button class="set_speed">set</button></li>
|
||||
<h2>Export:</h2>
|
||||
<li><a><button class="export_sequence">export sequence</button></a></li>
|
||||
<li><a><button class="export_sequence_csv">export sequence (csv)</button></a></li>
|
||||
<li><a><button class="export_presets">export presets</button></a></li>
|
||||
<h2>Import:</h2>
|
||||
<li><input class="import_sequence" type="file">import sequence</input></li>
|
||||
|
|
|
@ -489,6 +489,47 @@ function exportSequence() {
|
|||
})
|
||||
}
|
||||
|
||||
function getPreset(id) {
|
||||
return presets.filter(function(preset) {
|
||||
return preset.id == id;
|
||||
})[0]
|
||||
}
|
||||
|
||||
function exportSequenceCSV() {
|
||||
var position = 0;
|
||||
return data.map(function(row) {
|
||||
var r = [];
|
||||
r.push(row.preset)
|
||||
var preset = getPreset(row.preset)
|
||||
r.push(preset.name)
|
||||
if (row.duration) {
|
||||
position += row.duration
|
||||
r.push(formatDuration(position))
|
||||
r.push(formatDuration(row.duration))
|
||||
} else {
|
||||
r.push('')
|
||||
r.push('')
|
||||
}
|
||||
r.push(row.speed)
|
||||
r.push(row.sleep)
|
||||
return r.join(',');
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
$('button.export_sequence_csv').on({click: function() {
|
||||
data.forEach(function(seq) {
|
||||
if (!seq.seqid) {
|
||||
seq.seqid = uuidv4()
|
||||
}
|
||||
})
|
||||
var blob = textBlob(JSON.stringify(exportSequenceCSV(), null, ' '))
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
$(this).parent().attr({
|
||||
href: url, download: 'sequence.csv'
|
||||
});
|
||||
}})
|
||||
|
||||
|
||||
$('button.export_sequence').on({click: function() {
|
||||
data.forEach(function(seq) {
|
||||
if (!seq.seqid) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user