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

View file

@ -1,115 +1,115 @@
/*global $, poll_job*/
/* global $, poll_job */
var form = {
MAX_MINS: 5*60, // 5 hours
get_values: function() {
var name = $('#name').val();
var start = $('#from-date').datepicker('getDate');
if(start !== null) {
start.setHours($('#from-hour').val());
start.setMinutes($('#from-min').val());
}
var end = $('#to-date').datepicker('getDate');
if(end !== null) {
end.setHours($('#to-hour').val());
end.setMinutes($('#to-min').val());
}
return { name: name, start: start, end: end };
},
check: function() {
"use strict";
var errs = [];
function err(msg, element) {
errs.unshift({ msg: msg, el: element});
}
var v = form.get_values();
if(v.name === '') {
err("Nome mancante", $('#name'));
}
if(v.start === null) {
err("Start unspecified");
}
if(v.end === null) {
err("End unspecified");
}
if(v.end <= v.start) {
err("Inverted from/to ?");
}
if( (v.end - v.start) / (1000*60) > form.MAX_MINS) {
err("Too long");
}
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");
});
MAX_MINS: 5 * 60, // 5 hours
get_values: function () {
var name = $('#name').val()
var start = $('#from-date').datepicker('getDate')
if (start !== null) {
start.setHours($('#from-hour').val())
start.setMinutes($('#from-min').val())
}
var end = $('#to-date').datepicker('getDate')
if (end !== null) {
end.setHours($('#to-hour').val())
end.setMinutes($('#to-min').val())
}
return { name: name, start: start, end: end }
},
check: function () {
'use strict'
var errs = []
function err (msg, element) {
errs.unshift({ msg: msg, el: element})
}
var v = form.get_values()
if (v.name === '') {
err('Nome mancante', $('#name'))
}
if (v.start === null) {
err('Start unspecified')
}
if (v.end === null) {
err('End unspecified')
}
if (v.end <= v.start) {
err('Inverted from/to ?')
}
if ((v.end - v.start) / (1000 * 60) > form.MAX_MINS) {
err('Too long')
}
return errs
}
}
$(function() {
"use strict";
$( "#from-date" ).datepicker({
defaultDate: "+0d",
changeMonth: true,
numberOfMonths: 1,
maxDate: new Date(),
onClose: function( selectedDate ) {
if($('#to-date').val() === '') {
$('#to-date').datepicker("setDate", selectedDate);
}
$("#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();
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')
})
}
$('#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'));
});
});
$(function () {
'use strict'
$('#from-date').datepicker({
defaultDate: '+0d',
changeMonth: true,
numberOfMonths: 1,
maxDate: new Date(),
onClose: function (selectedDate) {
if ($('#to-date').val() === '') {
$('#to-date').datepicker('setDate', selectedDate)
}
$('#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: */

View file

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

View file

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

View file

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