Compare commits

...

2 Commits

Author SHA1 Message Date
j
b42b14eed8 export csv 2018-12-05 17:18:57 +01:00
j
2b81162fbf fix preset lookup 2018-12-05 14:16:30 +01:00
2 changed files with 45 additions and 1 deletions

View File

@ -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>

View File

@ -376,7 +376,9 @@ function updateShiftStatus() {
if (response.result) {
if (response.result.status) {
current_position = response.result.status;
var preset = presets[parseInt($('select[name=preset-editor]').val(), 10)];
var preset = presets.filter(function(p) {
return p.id == parseInt($('select[name=preset-editor]').val(), 10)
})[0];
preset_offset['azimuth'] = preset['position']['azimuth'] - current_position['azimuth'];
preset_offset['elevation'] = preset['position']['elevation'] - current_position['elevation'];
preset_offset['absoluteZoom'] = preset['position']['absoluteZoom'] - current_position['absoluteZoom'];
@ -487,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) {