JS: standard --fix

This commit is contained in:
boyska 2019-11-16 12:34:43 +01:00
parent 97c74d8542
commit b729eec1d1
5 changed files with 743 additions and 760 deletions

View file

@ -1,282 +1,282 @@
/*global $, config, RecAPI, poll_job, _*/ /* global $, config, RecAPI, poll_job, _ */
//TODO: move to a separate file(?) // TODO: move to a separate file(?)
$.widget("ror.countclock", { $.widget('ror.countclock', {
options: { options: {
errormsg: null, errormsg: null,
since: null, since: null,
editable:true, editable: true,
to: null to: null
}, },
_create: function() { _create: function () {
"use strict"; 'use strict'
this._update(); this._update()
//TODO: aggiungi conto secondi/minuti passati // TODO: aggiungi conto secondi/minuti passati
var widg = this; var widg = this
this.element.on('click', '.countclock-edit-time', function() { this.element.on('click', '.countclock-edit-time', function () {
if(widg.options.editable === true) { if (widg.options.editable === true) {
widg._change_starttime(widg.options.since); widg._change_starttime(widg.options.since)
} }
}); })
}, },
_change_starttime: function ( since ) { _change_starttime: function (since) {
"use strict"; 'use strict'
var widget = this; var widget = this
time_changer_dialog(since, function(newsince) { time_changer_dialog(since, function (newsince) {
widget._trigger("change", null, { since: newsince }) widget._trigger('change', null, { since: newsince })
}); })
}, },
_setOption: function(key, value) { _setOption: function (key, value) {
this.options[key] = value; this.options[key] = value
this._update(); this._update()
}, },
_update: function() { _update: function () {
"use strict"; 'use strict'
var text = ""; var text = ''
if(this.options.since !== null) { if (this.options.since !== null) {
if(this.options.to === null) { if (this.options.to === null) {
text = "Registrando da " + config.datetimeformat(this.options.since); text = 'Registrando da ' + config.datetimeformat(this.options.since)
} else { } else {
text = "Registrando da " + text = 'Registrando da ' +
config.datetimeformat(this.options.since) + config.datetimeformat(this.options.since) +
" a " + ' a ' +
config.datetimeformat(this.options.to); config.datetimeformat(this.options.to)
this.options.editable = false; this.options.editable = false
} }
} }
this.element.text(text); this.element.text(text)
if(this.options.editable) { if (this.options.editable) {
var btn = $('<span/>'); var btn = $('<span/>')
btn.addClass('pure-button pure-button-compact countclock-edit-time'); btn.addClass('pure-button pure-button-compact countclock-edit-time')
btn.css('margin-left', '0.5em'); btn.css('margin-left', '0.5em')
btn.append($('<i/>').addClass('fa fa-pencil')); btn.append($('<i/>').addClass('fa fa-pencil'))
this.element.append(btn); this.element.append(btn)
} }
} }
}); })
$.widget("ror.ongoingrec", { $.widget('ror.ongoingrec', {
options: { options: {
rec: null, rec: null,
state: 0, state: 0,
filename: null, filename: null
/*0 = ongoing, 1 = encoding, 2 = ready to download, 9 = errors*/ /* 0 = ongoing, 1 = encoding, 2 = ready to download, 9 = errors */
}, },
_create: function() { _create: function () {
"use strict"; 'use strict'
//convert a Rec into a <tr> // convert a Rec into a <tr>
var widget = this; var widget = this
var rec = this.options.rec; var rec = this.options.rec
var view = this.element.data('rec', rec).addClass('ongoing-rec').append( var view = this.element.data('rec', rec).addClass('ongoing-rec').append(
$('<td/>').addClass('pure-form').append( $('<td/>').addClass('pure-form').append(
$('<input/>').attr('type', 'text').attr('placeholder', 'Nome trasmissione') $('<input/>').attr('type', 'text').attr('placeholder', 'Nome trasmissione')
) )
).append( $('<td class="ongoingrec-time"/>').countclock()).append( ).append($('<td class="ongoingrec-time"/>').countclock()).append(
$('<td/>').append($('<a/>') $('<td/>').append($('<a/>')
.addClass('pure-button pure-button-large')) .addClass('pure-button pure-button-large'))
); )
this._update(); this._update()
view.on("change keydown paste input", "input", view.on('change keydown paste input', 'input',
_.debounce(function onNameChanged(evt) { _.debounce(function onNameChanged (evt) {
console.log('change', evt); console.log('change', evt)
var prevrec = widget.options.rec; var prevrec = widget.options.rec
prevrec.name = $(evt.target).val(); prevrec.name = $(evt.target).val()
$(evt.target).parents('tr.ongoing-rec').data('rec', prevrec); $(evt.target).parents('tr.ongoing-rec').data('rec', prevrec)
widget._trigger("change", evt, widget._trigger('change', evt,
{rec: rec, widget: widget, changed: {name: rec.name}} {rec: rec, widget: widget, changed: {name: rec.name}}
); )
}, 500)); }, 500))
view.on("click", ".rec-stop", function(evt) { view.on('click', '.rec-stop', function (evt) {
widget._trigger("stop", evt, {rec: rec, widget: widget}); widget._trigger('stop', evt, {rec: rec, widget: widget})
}); })
view.on("click", ".rec-failed", function(evt) { view.on('click', '.rec-failed', function (evt) {
$('<div/>').html($('<pre/>').text(widget.options.errormsg)) $('<div/>').html($('<pre/>').text(widget.options.errormsg))
.dialog({modal: true, title: "Dettaglio errori", .dialog({modal: true, title: 'Dettaglio errori',
buttons: { buttons: {
Retry: function() { Retry: function () {
console.log("retrying"); console.log('retrying')
widget._setOption("state", 0); widget._setOption('state', 0)
widget._trigger("retry", evt, {rec: rec, widget: widget}); widget._trigger('retry', evt, {rec: rec, widget: widget})
$(this).dialog("close"); $(this).dialog('close')
}, Cancel: function() { }, Cancel: function () {
$(this).dialog("close"); $(this).dialog('close')
} }
} }
}); })
}); })
return view; return view
}, },
_setOption: function(key, value) { _setOption: function (key, value) {
this.options[key] = value; this.options[key] = value
if(key === 'state') { if (key === 'state') {
if(value !== 9) { if (value !== 9) {
this.options.errormsg = null; this.options.errormsg = null
} }
if(value < 2) { if (value < 2) {
this.options.filename = null; this.options.filename = null
} }
} }
this._update(); this._update()
}, },
_update: function() { _update: function () {
var rec = this.options.rec; var rec = this.options.rec
this.element.find('input').val(rec.name); this.element.find('input').val(rec.name)
this.element.find(':ror-countclock').countclock("option", "since", this.element.find(':ror-countclock').countclock('option', 'since',
rec.starttime !== null ? config.date_read(rec.starttime) : rec.starttime !== null ? config.date_read(rec.starttime) :
null).on("countclockchange", null).on('countclockchange',
function(evt, data) { function (evt, data) {
count_widg = this; count_widg = this
console.log(this); console.log(this)
console.log(rec.starttime, data.since.getTime() / 1000); console.log(rec.starttime, data.since.getTime() / 1000)
rec.starttime = data.since.getTime() / 1000; rec.starttime = data.since.getTime() / 1000
RecAPI.update(rec.id, rec).done( RecAPI.update(rec.id, rec).done(
function() { function () {
$(count_widg).countclock('option', 'since', data.since); $(count_widg).countclock('option', 'since', data.since)
}).fail(console.error); }).fail(console.error)
}); })
if(this.options.state > 0) { if (this.options.state > 0) {
this.element.find(':ror-countclock').countclock("option", "to", this.element.find(':ror-countclock').countclock('option', 'to',
rec.endtime !== null ? new Date(rec.endtime*1000) : null rec.endtime !== null ? new Date(rec.endtime * 1000) : null
); )
} else { } else {
this.element.find(':ror-countclock').countclock("option", "to", null); this.element.find(':ror-countclock').countclock('option', 'to', null)
} }
this.element.find('a').removeClass( this.element.find('a').removeClass(
'pure-button-disabled rec-encoding rec-download rec-failed rec-stop'); 'pure-button-disabled rec-encoding rec-download rec-failed rec-stop')
switch(this.options.state) { switch (this.options.state) {
case 0: case 0:
this.element.find('a').addClass("rec-stop").html( this.element.find('a').addClass('rec-stop').html(
$('<i/>').addClass('fa fa-stop')).append(' Stop'); $('<i/>').addClass('fa fa-stop')).append(' Stop')
break; break
case 1: case 1:
this.element.find('a') this.element.find('a')
.addClass("pure-button-disabled rec-encoding").html( .addClass('pure-button-disabled rec-encoding').html(
$('<i/>').addClass('fa fa-clock-o')).append(' Aspetta'); $('<i/>').addClass('fa fa-clock-o')).append(' Aspetta')
break; break
case 2: case 2:
this.element.find('a').addClass("rec-download") this.element.find('a').addClass('rec-download')
.prop('href', this.options.filename) .prop('href', this.options.filename)
.html( .html(
$('<i/>').addClass('fa fa-download').css('color', 'green')) $('<i/>').addClass('fa fa-download').css('color', 'green'))
.append(' Scarica'); .append(' Scarica')
break; break
case 9: case 9:
this.element.find('a').addClass("rec-failed") this.element.find('a').addClass('rec-failed')
.html( .html(
$('<i/>').addClass('fa fa-warning')).append(' Errori'); $('<i/>').addClass('fa fa-warning')).append(' Errori')
break; break
} }
} }
}); })
function add_new_rec() { function add_new_rec () {
//progress() // progress()
return RecAPI.create() return RecAPI.create()
.done(function(res) { .done(function (res) {
/*global show_ongoing*/ /* global show_ongoing */
//passa alla seconda schermata // passa alla seconda schermata
$('#rec-inizia').remove(); $('#rec-inizia').remove()
$('#rec-normal').show(); $('#rec-normal').show()
show_ongoing([res.rec]); show_ongoing([res.rec])
}) })
.fail(function() { .fail(function () {
/*global alert*/ /* global alert */
alert("C'e' stato qualche problema nella comunicazione col server"); alert("C'e' stato qualche problema nella comunicazione col server")
}); })
} }
function gen_rec(rec, widget) { function gen_rec (rec, widget) {
"use strict"; 'use strict'
var gen_xhr = RecAPI.generate(rec); var gen_xhr = RecAPI.generate(rec)
gen_xhr.done(function(res_gen) { gen_xhr.done(function (res_gen) {
widget.option("state", 1); widget.option('state', 1)
poll_job(res_gen.job_id, function(data) { poll_job(res_gen.job_id, function (data) {
if(data.job_status !== 'DONE') { if (data.job_status !== 'DONE') {
console.error("Job failed!", data); console.error('Job failed!', data)
widget.option("errormsg", "Generation failed"); widget.option('errormsg', 'Generation failed')
widget.option("state", 9); widget.option('state', 9)
} else { } else {
widget.option("filename", res_gen.result); widget.option('filename', res_gen.result)
widget.option("state", 2); widget.option('state', 2)
} }
}); })
}); })
gen_xhr.fail(function(res_gen) { gen_xhr.fail(function (res_gen) {
var error = JSON.parse(res_gen.responseText).message; var error = JSON.parse(res_gen.responseText).message
widget.option("errormsg", error); widget.option('errormsg', error)
widget.option("state", 9); widget.option('state', 9)
}); })
return gen_xhr; return gen_xhr
} }
function stop_rec(rec, widget) { function stop_rec (rec, widget) {
"use strict"; 'use strict'
var stop_xhr = RecAPI.stop(rec); var stop_xhr = RecAPI.stop(rec)
stop_xhr.done(function(res_update) { stop_xhr.done(function (res_update) {
widget.option("rec", res_update.rec); widget.option('rec', res_update.rec)
return gen_rec(rec, widget); return gen_rec(rec, widget)
}); })
stop_xhr.fail(function(res_update) { stop_xhr.fail(function (res_update) {
var error = JSON.parse(res_update.responseText).message; var error = JSON.parse(res_update.responseText).message
widget.option("errormsg", error); widget.option('errormsg', error)
widget.option("state", 9); widget.option('state', 9)
}); })
return stop_xhr; //RecAPI.stop return stop_xhr // RecAPI.stop
} }
function show_ongoing(ongoing_recs) { function show_ongoing (ongoing_recs) {
return ongoing_recs.map(function(rec) { return ongoing_recs.map(function (rec) {
var viewrec = $('<tr/>').ongoingrec({rec: rec}); var viewrec = $('<tr/>').ongoingrec({rec: rec})
viewrec.on("ongoingrecstop", function(evt, data) { viewrec.on('ongoingrecstop', function (evt, data) {
stop_rec(data.rec, data.widget); stop_rec(data.rec, data.widget)
}).on("ongoingrecretry", function(evt, data) { }).on('ongoingrecretry', function (evt, data) {
//FIXME: bisognerebbe solo generare, senza stoppare // FIXME: bisognerebbe solo generare, senza stoppare
gen_rec(data.rec, data.widget); gen_rec(data.rec, data.widget)
}).on("ongoingrecchange", function(evt, data) { }).on('ongoingrecchange', function (evt, data) {
//TODO: aggiorna nome sul server // TODO: aggiorna nome sul server
RecAPI.update(data.rec.id, data.rec); RecAPI.update(data.rec.id, data.rec)
}); })
$('#ongoing-recs-table tbody').prepend(viewrec); $('#ongoing-recs-table tbody').prepend(viewrec)
return viewrec; return viewrec
}); })
} }
$(function() { $(function () {
"use strict"; 'use strict'
/*global getKeys*/ /* global getKeys */
//TODO: get-ongoing // TODO: get-ongoing
RecAPI.get_ongoing() RecAPI.get_ongoing()
.done(function(recs) { .done(function (recs) {
$('.add-new-rec').click(add_new_rec); $('.add-new-rec').click(add_new_rec)
console.log(recs); console.log(recs)
if(getKeys(recs).length !== 0) { if (getKeys(recs).length !== 0) {
$('#rec-inizia').remove(); $('#rec-inizia').remove()
$('#rec-normal').show(); $('#rec-normal').show()
show_ongoing(getKeys(recs).map(function(id) { console.log(id); return recs[id]; })); show_ongoing(getKeys(recs).map(function (id) { console.log(id); return recs[id] }))
} }
}); })
}); })
//POLYFILL for Object.keys // POLYFILL for Object.keys
function getKeys(obj) { function getKeys (obj) {
var keys = []; var keys = []
var key; var key
for(key in obj) { for (key in obj) {
if(obj.hasOwnProperty(key)) { if (obj.hasOwnProperty(key)) {
keys.push(key); keys.push(key)
} }
} }
return keys; return keys
} }
/* vim: set ts=2 sw=2 noet fdm=indent: */ /* vim: set ts=2 sw=2 noet fdm=indent: */

View file

@ -1,115 +1,115 @@
/*global $, poll_job*/ /* global $, poll_job */
var form = { var form = {
MAX_MINS: 5*60, // 5 hours MAX_MINS: 5 * 60, // 5 hours
get_values: function() { get_values: function () {
var name = $('#name').val(); var name = $('#name').val()
var start = $('#from-date').datepicker('getDate'); var start = $('#from-date').datepicker('getDate')
if(start !== null) { if (start !== null) {
start.setHours($('#from-hour').val()); start.setHours($('#from-hour').val())
start.setMinutes($('#from-min').val()); start.setMinutes($('#from-min').val())
} }
var end = $('#to-date').datepicker('getDate'); var end = $('#to-date').datepicker('getDate')
if(end !== null) { if (end !== null) {
end.setHours($('#to-hour').val()); end.setHours($('#to-hour').val())
end.setMinutes($('#to-min').val()); end.setMinutes($('#to-min').val())
} }
return { name: name, start: start, end: end }; return { name: name, start: start, end: end }
}, },
check: function() { check: function () {
"use strict"; 'use strict'
var errs = []; var errs = []
function err(msg, element) { function err (msg, element) {
errs.unshift({ msg: msg, el: element}); errs.unshift({ msg: msg, el: element})
} }
var v = form.get_values(); var v = form.get_values()
if(v.name === '') { if (v.name === '') {
err("Nome mancante", $('#name')); err('Nome mancante', $('#name'))
} }
if(v.start === null) { if (v.start === null) {
err("Start unspecified"); err('Start unspecified')
} }
if(v.end === null) { if (v.end === null) {
err("End unspecified"); err('End unspecified')
} }
if(v.end <= v.start) { if (v.end <= v.start) {
err("Inverted from/to ?"); err('Inverted from/to ?')
} }
if( (v.end - v.start) / (1000*60) > form.MAX_MINS) { if ((v.end - v.start) / (1000 * 60) > form.MAX_MINS) {
err("Too long"); err('Too long')
} }
return errs; return errs
} }
};
function click(widget) {
/*global RecAPI*/
var v = form.get_values();
RecAPI.fullcreate(v.name, v.start, v.end)
.done(function(res_create) {
console.log("ok, created");
RecAPI.generate(res_create.rec)
.done(function(res_gen) {
console.log("ok, generated", res_create);
//TODO: start polling
$('#download').thebutton('option', 'state', 'Wait');
poll_job(res_gen.job_id, function(data) {
if(data.job_status !== 'DONE') {
console.error("Job failed!", data);
widget.thebutton("option", "state", 'Failed');
widget.thebutton("option", "errormsg", data.exception);
} else {
widget.thebutton("option", "filename", res_gen.result);
widget.thebutton("option", "state", 'Download');
}
});
})
.fail(function() {
console.error("Oh shit, generate failed", res_create.rec);
});
})
.fail(function() {
console.error("Oh shit, fullcreate failed");
});
} }
$(function() { function click (widget) {
"use strict"; /* global RecAPI */
$( "#from-date" ).datepicker({ var v = form.get_values()
defaultDate: "+0d", RecAPI.fullcreate(v.name, v.start, v.end)
changeMonth: true, .done(function (res_create) {
numberOfMonths: 1, console.log('ok, created')
maxDate: new Date(), RecAPI.generate(res_create.rec)
onClose: function( selectedDate ) { .done(function (res_gen) {
if($('#to-date').val() === '') { console.log('ok, generated', res_create)
$('#to-date').datepicker("setDate", selectedDate); // TODO: start polling
} $('#download').thebutton('option', 'state', 'Wait')
$("#to-date").datepicker("option", "minDate", selectedDate); poll_job(res_gen.job_id, function (data) {
} if (data.job_status !== 'DONE') {
}); console.error('Job failed!', data)
$( "#to-date" ).datepicker({ widget.thebutton('option', 'state', 'Failed')
defaultDate: "+0d", widget.thebutton('option', 'errormsg', data.exception)
changeMonth: true, } else {
numberOfMonths: 1, widget.thebutton('option', 'filename', res_gen.result)
maxDate: new Date(), widget.thebutton('option', 'state', 'Download')
onClose: function( selectedDate ) { }
$("#from-date").datepicker("option", "maxDate", selectedDate); })
} })
}); .fail(function () {
$('#to-date, #from-date').datepicker($.datepicker.regional.it); console.error('Oh shit, generate failed', res_create.rec)
$('#download').thebutton(); })
})
.fail(function () {
console.error('Oh shit, fullcreate failed')
})
}
$('#download').click(function() { $(function () {
if(!$('#download').hasClass('rec-run')) { 'use strict'
return; $('#from-date').datepicker({
} defaultDate: '+0d',
var check = form.check(); changeMonth: true,
if(check.length > 0) { numberOfMonths: 1,
console.log("Errors in form", check); maxDate: new Date(),
error_dialog(check.map(function(err) { return err.msg; }).join('\n')); onClose: function (selectedDate) {
return; if ($('#to-date').val() === '') {
} $('#to-date').datepicker('setDate', selectedDate)
click($('#download')); }
}); $('#to-date').datepicker('option', 'minDate', selectedDate)
}); }
})
$('#to-date').datepicker({
defaultDate: '+0d',
changeMonth: true,
numberOfMonths: 1,
maxDate: new Date(),
onClose: function (selectedDate) {
$('#from-date').datepicker('option', 'maxDate', selectedDate)
}
})
$('#to-date, #from-date').datepicker($.datepicker.regional.it)
$('#download').thebutton()
$('#download').click(function () {
if (!$('#download').hasClass('rec-run')) {
return
}
var check = form.check()
if (check.length > 0) {
console.log('Errors in form', check)
error_dialog(check.map(function (err) { return err.msg }).join('\n'))
return
}
click($('#download'))
})
})
/* vim: set ts=2 sw=2 noet fdm=indent: */ /* vim: set ts=2 sw=2 noet fdm=indent: */

View file

@ -1,69 +1,69 @@
/*global $*/ /* global $ */
var config = { var config = {
polling_interval: 500, polling_interval: 500,
date_write: function(d) { date_write: function (d) {
return Math.floor(d.getTime() / 1000); return Math.floor(d.getTime() / 1000)
}, },
date_read: function(unix_timestamp) { date_read: function (unix_timestamp) {
return new Date(unix_timestamp * 1000); return new Date(unix_timestamp * 1000)
}, },
datetimeformat: function(d) { datetimeformat: function (d) {
if(Math.abs(new Date() - d) > (3*60*60*1000)) { if (Math.abs(new Date() - d) > (3 * 60 * 60 * 1000)) {
return d.toLocaleString(); return d.toLocaleString()
} }
return d.toLocaleTimeString(); return d.toLocaleTimeString()
} }
}; }
var RecAPI = { var RecAPI = {
create: function() { create: function () {
return $.ajax('/api/create', { return $.ajax('/api/create', {
method: 'POST', method: 'POST',
dataType: 'json' dataType: 'json'
}); })
}, },
stop: function(rec) { stop: function (rec) {
return $.post('/api/update/' + rec.id, { return $.post('/api/update/' + rec.id, {
starttime: rec.starttime starttime: rec.starttime
}); })
}, },
update: function(id, data) { update: function (id, data) {
return $.post('/api/update/' + id, data); return $.post('/api/update/' + id, data)
}, },
fullcreate: function(name, start, end) { fullcreate: function (name, start, end) {
return $.ajax( return $.ajax(
'/api/create', { '/api/create', {
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
data: { name: name, data: { name: name,
starttime: config.date_write(start), starttime: config.date_write(start),
endtime: config.date_write(end) endtime: config.date_write(end)
} }
}); })
}, },
generate: function(rec) { generate: function (rec) {
return $.post('/api/generate', { return $.post('/api/generate', {
id: rec.id id: rec.id
}); })
}, },
get_archive: function() { get_archive: function () {
return $.getJSON('/api/get/archive'); return $.getJSON('/api/get/archive')
}, },
get_ongoing: function() { get_ongoing: function () {
return $.getJSON('/api/get/ongoing'); return $.getJSON('/api/get/ongoing')
} }
}; }
function poll_job(job_id, callback) { function poll_job (job_id, callback) {
$.getJSON('/api/jobs/' + job_id) $.getJSON('/api/jobs/' + job_id)
.done(function(data) { .done(function (data) {
if(data.job_status !== 'WIP') { if (data.job_status !== 'WIP') {
console.log("polling completed for job[" + job_id + "]", data); console.log('polling completed for job[' + job_id + ']', data)
callback(data); callback(data)
} else { } else {
setTimeout(function() { poll_job(job_id, callback); }, setTimeout(function () { poll_job(job_id, callback) },
config.polling_interval); config.polling_interval)
} }
}); })
} }

View file

@ -1,33 +1,33 @@
console.log("Loading..."); console.log('Loading...')
function trx_startbut( code ) { return "startbutton-"+code; } function trx_startbut (code) { return 'startbutton-' + code }
function trx_stopbut( code ) { return "stopbutton-"+code; } function trx_stopbut (code) { return 'stopbutton-' + code }
function trx_downbut( code ) { return "downloadbutton-"+code; } function trx_downbut (code) { return 'downloadbutton-' + code }
function trx_endbut( code ) { return "endbutton-"+code; } function trx_endbut (code) { return 'endbutton-' + code }
function trx_logarea( code ) { return "logarea-"+code; } function trx_logarea (code) { return 'logarea-' + code }
function rs_button( code ) { return "button"+code; } function rs_button (code) { return 'button' + code }
function rs_trxarea( code ) { return "recarea-"+code; } function rs_trxarea (code) { return 'recarea-' + code }
function rs_trxname( code ) { return "name"; } function rs_trxname (code) { return 'name' }
function rs_buttonarea( code ) { return "butarea-"+code; } function rs_buttonarea (code) { return 'butarea-' + code }
function rs_inputstart( code ) { return "starttime"; } function rs_inputstart (code) { return 'starttime' }
function rs_inputend( code ) { return "endtime"; } function rs_inputend (code) { return 'endtime' }
function rs_formid(code) { return "form-"+code; } function rs_formid (code) { return 'form-' + code }
function rs_dellink(code) { return "dellink-"+code;} function rs_dellink (code) { return 'dellink-' + code }
function rs_id(code) { return code; } function rs_id (code) { return code }
var txt_start = "Inizia"; var txt_start = 'Inizia'
var txt_stop = "Ferma"; var txt_stop = 'Ferma'
var txt_download = "Scarica"; var txt_download = 'Scarica'
var srvaddr = "/"; var srvaddr = '/'
var almostone = false; var almostone = false
var noplusbotton = true; var noplusbotton = true
var rec_name_default = ""; var rec_name_default = ''
/* /*
TODO: cambiare logica TODO: cambiare logica
@ -38,230 +38,216 @@ per ogni altro pulsante, faccio solo e sempre UPDATE
* Perform Ajax async loading * Perform Ajax async loading
**/ **/
function newformstr ( recid , butflag=false ) function newformstr (recid, butflag = false) {
{ var formid = rs_formid(recid)
var formid = rs_formid( recid ); var str = '<form id="' + formid + '" name="' + formid + '" action="#">'
var str = "<form id=\""+formid+"\" name=\""+formid+"\" action=\"#\">";
if (butflag) { if (butflag) {
str = str + "<input type=\"button\" name=\""+trx_startbut(recid)+"\" id=\""+trx_startbut(recid)+"\" "; str = str + '<input type="button" name="' + trx_startbut(recid) + '" id="' + trx_startbut(recid) + '" '
str = str + " class=\"recbutton\" value=\"Inizia\" />"; str = str + ' class="recbutton" value="Inizia" />'
str = str + "<input type=\"button\" name=\""+trx_stopbut(recid)+"\" id=\""+trx_stopbut(recid)+"\" "; str = str + '<input type="button" name="' + trx_stopbut(recid) + '" id="' + trx_stopbut(recid) + '" '
str = str + " class=\"recbutton\" value=\"Stop\" />"; str = str + ' class="recbutton" value="Stop" />'
str = str + "<input type=\"submit\" name=\""+trx_downbut(recid)+"\" id=\""+trx_downbut(recid)+"\" "; str = str + '<input type="submit" name="' + trx_downbut(recid) + '" id="' + trx_downbut(recid) + '" '
str = str + " class=\"recbutton\" value=\"Salva\" />"; str = str + ' class="recbutton" value="Salva" />'
str = str + "<input type=\"submit\" name=\""+trx_endbut(recid)+"\" id=\""+trx_endbut(recid)+"\" "; str = str + '<input type="submit" name="' + trx_endbut(recid) + '" id="' + trx_endbut(recid) + '" '
str = str + " class=\"recbutton\" value=\"Download\" />"; str = str + ' class="recbutton" value="Download" />'
} }
str = str + "<input type=\"hidden\" id=\"recid\" name=\"recid\" value=\""+recid+"\" />"; str = str + '<input type="hidden" id="recid" name="recid" value="' + recid + '" />'
str = str + "<input type=\"text\" id=\""+rs_trxname(recid)+"\" name=\""+rs_trxname(recid)+"\" />"; str = str + '<input type="text" id="' + rs_trxname(recid) + '" name="' + rs_trxname(recid) + '" />'
str = str + "<input type=\"text\" id=\""+rs_inputstart(recid)+"\" name=\""+rs_inputstart(recid)+"\" />"; str = str + '<input type="text" id="' + rs_inputstart(recid) + '" name="' + rs_inputstart(recid) + '" />'
str = str + "<input type=\"text\" id=\""+rs_inputend(recid)+"\" name=\""+rs_inputend(recid)+"\" />"; str = str + '<input type="text" id="' + rs_inputend(recid) + '" name="' + rs_inputend(recid) + '" />'
if (! butflag) { if (!butflag) {
str = str + "<input type=\"button\" name=\""+trx_downbut(recid)+"\" id=\""+trx_downbut(recid)+"\" "; str = str + '<input type="button" name="' + trx_downbut(recid) + '" id="' + trx_downbut(recid) + '" '
str = str + " class=\"downloadbutton\" value=\"scarica\" />"; str = str + ' class="downloadbutton" value="scarica" />'
} }
/* /*
str = str + "<input type=\"text\" id=\"name\" name=\"name\" />"; str = str + "<input type=\"text\" id=\"name\" name=\"name\" />";
str = str + "<input type=\"text\" id=\"starttime\" name=\"starttime\" />"; str = str + "<input type=\"text\" id=\"starttime\" name=\"starttime\" />";
str = str + "<input type=\"text\" id=\"endtime\" name=\"endtime\" /> "; str = str + "<input type=\"text\" id=\"endtime\" name=\"endtime\" /> ";
*/ */
str = str + "</form>"; str = str + '</form>'
return str; return str
} }
/** /**
* GetActive Recs * GetActive Recs
**/ **/
function rec_active( recid ) { function rec_active (recid) {
dataString = ""; dataString = ''
var request = RecAjax("search", dataString); var request = RecAjax('search', dataString)
request.done( function(data) { request.done(function (data) {
$.each(data, function(key, val) { $.each(data, function (key, val) {
console.log("Key " + key + " > VAL " + val ); console.log('Key ' + key + ' > VAL ' + val)
$("#"+trx_logarea( recid )).append( "Key " + key + " > VAL " + val + "<br>" ); $('#' + trx_logarea(recid)).append('Key ' + key + ' > VAL ' + val + '<br>')
}); })
console.log("Req OK: "+ data); console.log('Req OK: ' + data)
// console.log("request"+ req); // console.log("request"+ req);
ChangeState(recid, trx_downbut(recid) , trx_endbut(recid)); ChangeState(recid, trx_downbut(recid), trx_endbut(recid))
}); })
} }
/** /**
* New record * New record
**/ **/
function rec_new( ) function rec_new () {
{ var myDate = new Date()
console.log('New ID ' + myDate.getTime())
var recid = 'rec-' + myDate.getTime()
var myDate = new Date() console.log('[rec_new] New Rec ' + recid)
console.log("New ID "+ myDate.getTime());
var recid = "rec-"+ myDate.getTime();
console.log("[rec_new] New Rec " + recid); $('#buttonscontainer').append('<div id="' + rs_trxarea(recid) + '" class="recarea"> </div>')
$('#' + rs_trxarea(recid)).append('<div id="' + rs_buttonarea(recid) + '" class="buttonarea"> </div>')
console.log('[rec_new' + recid + '] add div (TRXArea, ButtonArea) ok ')
$("#buttonscontainer").append( "<div id=\""+rs_trxarea(recid)+"\" class=\"recarea\"> </div>" ); var formid = rs_formid(recid)
$("#"+rs_trxarea(recid)).append( "<div id=\""+rs_buttonarea(recid)+"\" class=\"buttonarea\"> </div>" );
console.log("[rec_new"+recid+"] add div (TRXArea, ButtonArea) ok " );
var formid = rs_formid( recid ); var str = newformstr(recid, butflag = true)
$('#' + rs_buttonarea(recid)).append(str)
var str = newformstr(recid, butflag=true); $('#' + trx_stopbut(recid)).hide()
$("#"+rs_buttonarea(recid)).append( str ); $('#' + trx_downbut(recid)).hide()
$('#' + trx_endbut(recid)).hide()
$("#"+trx_stopbut(recid)).hide(); console.log('[rec_new ' + recid + '] Form OK')
$("#"+trx_downbut(recid)).hide();
$("#"+trx_endbut(recid)).hide();
console.log("[rec_new "+recid+"] Form OK"); $('#' + rs_buttonarea(recid)).append('<div class="dellinkarea" > <a href="#" id=' + rs_dellink(recid) + '> cancella</a> </div>')
$("#"+rs_buttonarea(recid)).append( "<div class=\"dellinkarea\" > <a href=\"#\" id="+rs_dellink(recid)+"> cancella</a> </div>" );
// INSERT AND POPULATE BUTTON AREA // INSERT AND POPULATE BUTTON AREA
$("#"+rs_trxarea(recid)).append( "<div id=\""+trx_logarea(recid)+"\" class=\"logarea\"> Nuova trasmissione </div>" ); $('#' + rs_trxarea(recid)).append('<div id="' + trx_logarea(recid) + '" class="logarea"> Nuova trasmissione </div>')
// Bind the Delete Links // Bind the Delete Links
$("#"+rs_dellink(recid)).click(function(){ $('#' + rs_dellink(recid)).click(function () {
console.log("Remove " + rs_trxarea(recid) + "[ID"+recid+"]"); console.log('Remove ' + rs_trxarea(recid) + '[ID' + recid + ']')
// $("#"+rs_trxarea(recid)).remove(); // $("#"+rs_trxarea(recid)).remove();
recDelete (recid,rs_trxarea(recid)); recDelete(recid, rs_trxarea(recid))
}); })
// FORM SUBMIT: THE REC IS STOPPEND AND MUST BE PROCESSED // FORM SUBMIT: THE REC IS STOPPEND AND MUST BE PROCESSED
$("#"+formid).submit(function(event){ $('#' + formid).submit(function (event) {
// Immediately, mark the end time (stop action) // Immediately, mark the end time (stop action)
ChangeState(recid, trx_downbut(recid) , trx_endbut(recid)); ChangeState(recid, trx_downbut(recid), trx_endbut(recid))
// Force a Name // Force a Name
while (true) { while (true) {
if ( $("#"+rs_trxname(recid)).val() == "" ) if ($('#' + rs_trxname(recid)).val() == '') {
{ var tmpname = prompt('Nessun nome di trasmissione!!!')
var tmpname = prompt("Nessun nome di trasmissione!!!"); $('#' + rs_trxname(recid)).val(tmpname)
$("#"+rs_trxname(recid)).val(tmpname); $('#' + trx_logarea(recid)).append('Titolo: <b>' + tmpname + '</b> <br/>')
$("#"+trx_logarea(recid)).append("Titolo: <b>"+ tmpname +"</b> <br/>"); } else { break }
} }
else { break; }
}
event.preventDefault(); event.preventDefault()
// Update data (send to server) in order to save some information // Update data (send to server) in order to save some information
recUpdate(recid); recUpdate(recid)
recStart(recid); recStart(recid)
}) // End of form SUBMIT
}); // End of form SUBMIT
// Bind the STOP button // Bind the STOP button
$("#"+trx_stopbut(recid)).click( function(event){ $('#' + trx_stopbut(recid)).click(function (event) {
event.preventDefault()
event.preventDefault(); ChangeState(recid, trx_stopbut(recid), trx_downbut(recid))
ChangeState(recid, trx_stopbut(recid) , trx_downbut(recid)); recUpdate(recid)
recUpdate(recid); }) // End of STOP button
}); // End of STOP button
// Bind the START button // Bind the START button
$("#"+trx_startbut(recid)).click( function(event){ $('#' + trx_startbut(recid)).click(function (event) {
// Immediately, mark the start time (start action) and send it to Server // Immediately, mark the start time (start action) and send it to Server
ChangeState(recid, trx_startbut(recid) , trx_stopbut(recid)); ChangeState(recid, trx_startbut(recid), trx_stopbut(recid))
event.preventDefault(); event.preventDefault()
recNew( recid ); recNew(recid)
}) // End of START button
}); // End of START button console.log('New form has been built.')
console.log("New form has been built.");
} }
/* Delete Record */ /* Delete Record */
function recDelete ( recid, targetarea ) { function recDelete (recid, targetarea) {
var formid = rs_formid( recid ); var formid = rs_formid(recid)
var dataString = "recid="+recid var dataString = 'recid=' + recid
console.log("Del rec: "+dataString); console.log('Del rec: ' + dataString)
var req_del = RecAjax("delete", dataString); var req_del = RecAjax('delete', dataString)
req_del.done (function(data) { req_del.done(function (data) {
$.each(data, function(del_key, del_val) { $.each(data, function (del_key, del_val) {
console.log("K:V " + del_key +":"+del_val ); console.log('K:V ' + del_key + ':' + del_val)
if (del_key == "message") { if (del_key == 'message') {
$("#"+targetarea).fadeOut( 200, function() { $(this).remove(); }); $('#' + targetarea).fadeOut(200, function () { $(this).remove() })
console.log("delete area "+rs_trxarea(key)); console.log('delete area ' + rs_trxarea(key))
}
} if (del_key == 'error') {
alert('Impossibile cancellare elemento:\n' + del_val)
if (del_key == "error") { }
alert("Impossibile cancellare elemento:\n" + del_val ); })
} })
});
});
} }
/* New Record */ /* New Record */
function recNew ( recid ) { function recNew (recid) {
var formid = rs_formid( recid ); var formid = rs_formid(recid)
var dataString = $("#"+formid).serialize(); var dataString = $('#' + formid).serialize()
console.log("New rec: "+dataString); console.log('New rec: ' + dataString)
var request = RecAjax("create", dataString); var request = RecAjax('create', dataString)
request.done( function(data) { request.done(function (data) {
$.each(data, function(key, val) { $.each(data, function (key, val) {
console.log("Received (K:V) ("+key+":"+val+")") ; console.log('Received (K:V) (' + key + ':' + val + ')')
if (key == "msg") { if (key == 'msg') {
$("#"+trx_logarea(recid)).html("Nuova Registrazione </br> (recid:"+recid+") </br>"); $('#' + trx_logarea(recid)).html('Nuova Registrazione </br> (recid:' + recid + ') </br>')
$("#"+trx_logarea(recid)).append("Inizio: "+ $("#"+rs_inputstart(recid)).val() +"<br/>"); $('#' + trx_logarea(recid)).append('Inizio: ' + $('#' + rs_inputstart(recid)).val() + '<br/>')
} }
if (key == "error") { if (key == 'error') {
$("#"+trx_logarea( recid )).html("Errore: impossibile creare una nuova registrazione"+val+" </ br>"); $('#' + trx_logarea(recid)).html('Errore: impossibile creare una nuova registrazione' + val + ' </ br>')
} }
})
}); })
} ); return request
return request;
} }
/* Update Record */ /* Update Record */
function recUpdate( recid ) { function recUpdate (recid) {
var formid = rs_formid( recid ); var formid = rs_formid(recid)
var dataString = $("#"+formid).serialize(); var dataString = $('#' + formid).serialize()
console.log("Sending Ajax Update request: "+ dataString); console.log('Sending Ajax Update request: ' + dataString)
//event.preventDefault(); // event.preventDefault();
var request = RecAjax("update", dataString ); var request = RecAjax('update', dataString)
request.done( function(data) { request.done(function (data) {
$.each(data, function(key, val) { $.each(data, function (key, val) {
console.log("recUpdate receive (k:v) ("+key+":"+val+")" ); console.log('recUpdate receive (k:v) (' + key + ':' + val + ')')
if (key == "message") { if (key == 'message') {
var str = ""; var str = ''
str += "<b>RecID</b> "+ recid + "</br>" str += '<b>RecID</b> ' + recid + '</br>'
str += "<b>nome</b> "+ $("#"+rs_trxname(recid)).val() + "</br>" str += '<b>nome</b> ' + $('#' + rs_trxname(recid)).val() + '</br>'
str += "<b>Inizio</b> "+ $("#"+rs_inputstart(recid)).val() + "</br>" str += '<b>Inizio</b> ' + $('#' + rs_inputstart(recid)).val() + '</br>'
str += "<b>Fine</b> "+ $("#"+rs_inputend(recid)).val() + "</br>" str += '<b>Fine</b> ' + $('#' + rs_inputend(recid)).val() + '</br>'
$("#"+trx_logarea(recid)).html( str ); $('#' + trx_logarea(recid)).html(str)
// if all elements have been recorded // if all elements have been recorded
if ($("#"+rs_trxname(recid)).val() != "") { if ($('#' + rs_trxname(recid)).val() != '') {
$("#"+trx_logarea(recid)).append( "<b>In Elaborazione</b>" ); $('#' + trx_logarea(recid)).append('<b>In Elaborazione</b>')
} }
} }
if (key == "error") { if (key == 'error') {
$("#"+trx_logarea( recid )).append( "Error:" + val +"<br>" ); $('#' + trx_logarea(recid)).append('Error:' + val + '<br>')
} }
}); // end of each }) // end of each
}); // end of request.done }) // end of request.done
} }
/* /*
@ -269,67 +255,64 @@ function recUpdate( recid ) {
* AJAX REQUEST * AJAX REQUEST
* *
*/ */
function RecAjax(apipath, dataString ) { function RecAjax (apipath, dataString) {
var srv = srvaddr + "api/" + apipath ; var srv = srvaddr + 'api/' + apipath
var request = $.ajax({ var request = $.ajax({
type: "POST", type: 'POST',
cache: false, cache: false,
url: srv, url: srv,
data: dataString, data: dataString,
dataType: "json" dataType: 'json'
}); })
request.fail(function (jqXHR, textStatus, errorThrown){ request.fail(function (jqXHR, textStatus, errorThrown) {
console.error("The following error occured: "+ jqXHR.status +"-"+ textStatus + "-" + errorThrown ); console.error('The following error occured: ' + jqXHR.status + '-' + textStatus + '-' + errorThrown)
if (jqXHR.status == 0 && jqXHR.readyState === 4) if (jqXHR.status == 0 && jqXHR.readyState === 4) {
{ alert('Errore di connessione, impossibile inviare i dati al server ' + srv)
alert("Errore di connessione, impossibile inviare i dati al server "+ srv); } else {
} else { alert('Error: ' + jqXHR.status + '\nTextStatus: ' + textStatus + '\n Ready State ' + jqXHR.readyState + '\n' + errorThrown)
alert("Error: "+jqXHR.status +"\nTextStatus: "+ textStatus + "\n Ready State "+jqXHR.readyState+"\n" + errorThrown ); }
} })
});
return request; return request
} }
/* /*
* GetNow (data parser) * GetNow (data parser)
*/ */
function getnow() function getnow () {
{ var myDate = new Date()
var myDate = new Date() var displayDate = myDate.getFullYear() + '/' + (myDate.getMonth() + 1) + '/' + myDate.getDate()
var displayDate = myDate.getFullYear() + '/' + (myDate.getMonth()+1) + '/' + myDate.getDate(); displayDate = displayDate + ' ' + myDate.getHours() + ':' + myDate.getMinutes() + ':' + myDate.getSeconds()
displayDate = displayDate +' '+ myDate.getHours()+':'+myDate.getMinutes()+':'+myDate.getSeconds(); return displayDate
return displayDate;
} }
/* /*
FUNCTION: CHANGE STATE (gui) FUNCTION: CHANGE STATE (gui)
*/ */
function ChangeState(recid, from, to) { function ChangeState (recid, from, to) {
console.log('ChangeState: ' + from + ' --> ' + to)
console.log("ChangeState: " + from + " --> " + to ); $('#' + from).css('display', 'none')
$('#' + to).css('display', 'inline')
$("#"+from).css("display", "none");
$("#"+to).css("display", "inline");
// take the date // take the date
var displayDate = getnow(); var displayDate = getnow()
if ( from == trx_startbut(recid) ) { if (from == trx_startbut(recid)) {
$("#"+rs_inputstart(recid)).val( displayDate ); $('#' + rs_inputstart(recid)).val(displayDate)
console.log("ChangeState: set "+rs_inputstart(recid)+ " to "+ displayDate ) console.log('ChangeState: set ' + rs_inputstart(recid) + ' to ' + displayDate)
} }
if ( from == trx_stopbut(recid) ) { if (from == trx_stopbut(recid)) {
$("#"+rs_inputend(recid)).val( displayDate ); $('#' + rs_inputend(recid)).val(displayDate)
console.log("ChangeState: set '"+rs_inputend(recid)+ "' to "+ displayDate ) console.log("ChangeState: set '" + rs_inputend(recid) + "' to " + displayDate)
} }
if ( from == trx_downbut(recid) ) { if (from == trx_downbut(recid)) {
$("input[type=submit]").attr("disabled", "disabled"); $('input[type=submit]').attr('disabled', 'disabled')
console.log("ChangeState: set '"+rs_inputend(recid)+ "' to "+ displayDate ); console.log("ChangeState: set '" + rs_inputend(recid) + "' to " + displayDate)
} }
} // End function ChangeState } // End function ChangeState

View file

@ -1,123 +1,123 @@
/*global $*/ /* global $ */
function time_changer_dialog(d, changed_callback) { function time_changer_dialog (d, changed_callback) {
//d is a Date object // d is a Date object
var dlg_html = '<div> \ var dlg_html = '<div> \
<form action="#"> \ <form action="#"> \
<input name="h" size="2" maxlength="2" type="number" min="0" max="23"> \ <input name="h" size="2" maxlength="2" type="number" min="0" max="23"> \
<input name="m" size="2" maxlength="2" type="number" min="0" max="59"> \ <input name="m" size="2" maxlength="2" type="number" min="0" max="59"> \
<input name="s" size="2" maxlength="2" type="number" min="0" max="59"> \ <input name="s" size="2" maxlength="2" type="number" min="0" max="59"> \
</form> \ </form> \
</div>'; </div>'
var $dlg = $( $.parseHTML(dlg_html) ); var $dlg = $($.parseHTML(dlg_html))
$('[name=h]', $dlg).val(d.getHours() ); $('[name=h]', $dlg).val(d.getHours())
$('[name=m]', $dlg).val(d.getMinutes() ); $('[name=m]', $dlg).val(d.getMinutes())
$('[name=s]', $dlg).val(d.getSeconds() ); $('[name=s]', $dlg).val(d.getSeconds())
$dlg.dialog( { $dlg.dialog({
title: "Modifica inizio", title: 'Modifica inizio',
buttons: buttons:
{ {
"Ok":function() { 'Ok': function () {
$(this).dialog( "close" ); $(this).dialog('close')
if(changed_callback === undefined) { if (changed_callback === undefined) {
return; return
} }
newd = new Date(d.getTime()); newd = new Date(d.getTime())
newd.setHours($('[name=h]', $dlg).val()); newd.setHours($('[name=h]', $dlg).val())
newd.setMinutes($('[name=m]', $dlg).val()); newd.setMinutes($('[name=m]', $dlg).val())
newd.setSeconds($('[name=s]', $dlg).val()); newd.setSeconds($('[name=s]', $dlg).val())
if(newd.getTime() === d.getTime()) { if (newd.getTime() === d.getTime()) {
console.debug("Time not changed, discarding"); console.debug('Time not changed, discarding')
return; return
} }
changed_callback(newd); //FIXME: crea data a partire dal form changed_callback(newd) // FIXME: crea data a partire dal form
}, },
"Annulla": function() { 'Annulla': function () {
$(this).dialog("close"); $(this).dialog('close')
} }
} }
}).dialog('open'); }).dialog('open')
} }
$.widget("ror.thebutton", { $.widget('ror.thebutton', {
options: { options: {
state: 'Create', state: 'Create',
filename: null, filename: null,
errormsg: null errormsg: null
}, },
_create: function() { _create: function () {
"use strict"; 'use strict'
//create an appropriate button // create an appropriate button
var widget = this; var widget = this
var state = this.options.rec; var state = this.options.rec
widget.element.addClass('pure-button'); widget.element.addClass('pure-button')
widget.element.on("click", function(evt) { widget.element.on('click', function (evt) {
/*global error_dialog*/ /* global error_dialog */
if(widget.element.hasClass("rec-failed")) { if (widget.element.hasClass('rec-failed')) {
error_dialog(widget.options.errormsg, error_dialog(widget.options.errormsg,
function() { function () {
console.log("Should retry, TODO"); console.log('Should retry, TODO')
$(this).dialog("close"); $(this).dialog('close')
widget._setOption('state', 'Create'); widget._setOption('state', 'Create')
widget.element.click(); widget.element.click()
}, },
function() { function () {
$(this).dialog("close"); $(this).dialog('close')
}); })
} }
}); })
this._update(); this._update()
}, },
_setOption: function(key, value) { _setOption: function (key, value) {
this.options[key] = value; this.options[key] = value
if(key === 'state') { if (key === 'state') {
if(this.options.state !== 'Download') { if (this.options.state !== 'Download') {
this.options.filename = null; this.options.filename = null
} }
} }
this._update(); this._update()
}, },
_update: function() { _update: function () {
this.element.removeClass('pure-button-disabled rec-run rec-create ' + this.element.removeClass('pure-button-disabled rec-run rec-create ' +
'rec-encoding rec-download rec-failed rec-stop'); 'rec-encoding rec-download rec-failed rec-stop')
switch(this.options.state) { switch (this.options.state) {
case 'Stop': case 'Stop':
this.element.addClass("rec-stop rec-run").html( this.element.addClass('rec-stop rec-run').html(
$('<i/>').addClass('fa fa-stop')).append(' Stop'); $('<i/>').addClass('fa fa-stop')).append(' Stop')
break; break
case 'Create': case 'Create':
this.element.addClass('rec-create rec-run').html( this.element.addClass('rec-create rec-run').html(
$('<i/>').addClass('fa fa-gear')).append(' Create'); $('<i/>').addClass('fa fa-gear')).append(' Create')
break; break
case 'Failed': case 'Failed':
this.element.addClass("rec-failed").html( this.element.addClass('rec-failed').html(
$('<i/>').addClass('fa fa-warning')).append(' Errori'); $('<i/>').addClass('fa fa-warning')).append(' Errori')
break; break
case 'Wait': case 'Wait':
this.element.addClass("pure-button-disabled rec-encoding") .html( this.element.addClass('pure-button-disabled rec-encoding').html(
$('<i/>').addClass('fa fa-clock-o')).append(' Wait'); $('<i/>').addClass('fa fa-clock-o')).append(' Wait')
break; break
case 'Download': case 'Download':
this.element this.element
.addClass("rec-download") .addClass('rec-download')
.prop('href', this.options.filename) .prop('href', this.options.filename)
.html( .html(
$('<i/>').addClass('fa fa-download').css('color', 'green')) $('<i/>').addClass('fa fa-download').css('color', 'green'))
.append(' Scarica'); .append(' Scarica')
break; break
} }
} }
}); })
function error_dialog(msg, retry, cancel) { function error_dialog (msg, retry, cancel) {
$('<div/>').html($('<pre/>').text(msg)) $('<div/>').html($('<pre/>').text(msg))
.dialog({modal: true, title: "Dettaglio errori", .dialog({modal: true, title: 'Dettaglio errori',
buttons: { buttons: {
Retry: retry, Retry: retry,
Cancel: cancel Cancel: cancel
} }
}); })
} }
/* vim: set ts=2 sw=2 noet fdm=indent: */ /* vim: set ts=2 sw=2 noet fdm=indent: */