From 23b04a58bc2ef9a59352d74bae383bba7edefe49 Mon Sep 17 00:00:00 2001 From: boyska Date: Sat, 16 Nov 2019 12:58:45 +0100 Subject: [PATCH] remove useless js things --- server/static/js/new.js | 18 +- server/static/js/old.js | 4 +- server/static/js/reclibrary.js | 321 --------------------------------- 3 files changed, 12 insertions(+), 331 deletions(-) delete mode 100644 server/static/js/reclibrary.js diff --git a/server/static/js/new.js b/server/static/js/new.js index e4245d9..cb95883 100644 --- a/server/static/js/new.js +++ b/server/static/js/new.js @@ -1,4 +1,4 @@ -/* global $, config, RecAPI, poll_job, _ */ +/* global $, _, config, RecAPI, poll_job, time_changer_dialog */ // TODO: move to a separate file(?) $.widget('ror.countclock', { @@ -97,14 +97,17 @@ $.widget('ror.ongoingrec', { }) view.on('click', '.rec-failed', function (evt) { $('
').html($('
').text(widget.options.errormsg))
-      .dialog({modal: true, title: 'Dettaglio errori',
+      .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 () {
+          },
+          Cancel: function () {
             $(this).dialog('close')
           }
         }
@@ -130,10 +133,11 @@ $.widget('ror.ongoingrec', {
     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',
+              rec.starttime !== null
+      ? config.date_read(rec.starttime)
+      : null).on('countclockchange',
               function (evt, data) {
-                count_widg = this
+                var count_widg = this
                 console.log(this)
                 console.log(rec.starttime, data.since.getTime() / 1000)
                 rec.starttime = data.since.getTime() / 1000
@@ -183,7 +187,6 @@ function add_new_rec () {
   // progress()
   return RecAPI.create()
   .done(function (res) {
-    /* global show_ongoing */
     // passa alla seconda schermata
     $('#rec-inizia').remove()
     $('#rec-normal').show()
@@ -253,7 +256,6 @@ function show_ongoing (ongoing_recs) {
 
 $(function () {
   'use strict'
-  /* global getKeys */
   // TODO: get-ongoing
   RecAPI.get_ongoing()
   .done(function (recs) {
diff --git a/server/static/js/old.js b/server/static/js/old.js
index 5532af5..d4df9bd 100644
--- a/server/static/js/old.js
+++ b/server/static/js/old.js
@@ -1,4 +1,4 @@
-/* global $, poll_job */
+/* global $, poll_job, error_dialog */
 
 var form = {
   MAX_MINS: 5 * 60, // 5 hours
@@ -20,7 +20,7 @@ var form = {
     'use strict'
     var errs = []
     function err (msg, element) {
-      errs.unshift({ msg: msg, el: element})
+      errs.unshift({msg: msg, el: element})
     }
     var v = form.get_values()
     if (v.name === '') {
diff --git a/server/static/js/reclibrary.js b/server/static/js/reclibrary.js
deleted file mode 100644
index cbd408b..0000000
--- a/server/static/js/reclibrary.js
+++ /dev/null
@@ -1,321 +0,0 @@
-/* global $ */
-
-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_logarea (code) { return 'logarea-' + 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 }
-
-var txt_start = 'Inizia'
-var txt_stop = 'Ferma'
-var txt_download = 'Scarica'
-
-var srvaddr = '/'
-
-var almostone = false
-var noplusbotton = true
-
-var rec_name_default = ''
-
-/*
-TODO: cambiare logica
-Quando premo il primo tasto, faccio la crazione,
-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 = '
' - - if (butflag) { - str = str + '' - str = str + '' - str = str + '' - str = str + '' - } - - str = str + '' - str = str + '' - str = str + '' - str = str + '' - - if (!butflag) { - str = str + '' - } - /* - str = str + ""; - str = str + ""; - str = str + " "; - */ - str = str + '
' - - return str -} - -/** -* GetActive Recs -**/ - -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 + '
') - }) - - console.log('Req OK: ' + data) - // console.log("request"+ req); - ChangeState(recid, trx_downbut(recid), trx_endbut(recid)) - }) -} - -/** - * New record - **/ -function rec_new () { - var myDate = new Date() - console.log('New ID ' + myDate.getTime()) - var recid = 'rec-' + myDate.getTime() - - console.log('[rec_new] New Rec ' + recid) - - $('#buttonscontainer').append('
') - $('#' + rs_trxarea(recid)).append('
') - 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) - - $('#' + trx_stopbut(recid)).hide() - $('#' + trx_downbut(recid)).hide() - $('#' + trx_endbut(recid)).hide() - - console.log('[rec_new ' + recid + '] Form OK') - - $('#' + rs_buttonarea(recid)).append('') - - // INSERT AND POPULATE BUTTON AREA - $('#' + rs_trxarea(recid)).append('
Nuova trasmissione
') - - // Bind the Delete Links - $('#' + rs_dellink(recid)).click(function () { - console.log('Remove ' + rs_trxarea(recid) + '[ID' + recid + ']') - // $("#"+rs_trxarea(recid)).remove(); - recDelete(recid, rs_trxarea(recid)) - }) - - // FORM SUBMIT: THE REC IS STOPPEND AND MUST BE PROCESSED - $('#' + formid).submit(function (event) { - // Immediately, mark the end time (stop action) - 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: ' + tmpname + '
') - } else { break } - } - - event.preventDefault() - - // Update data (send to server) in order to save some information - recUpdate(recid) - - 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 - - // Bind the START button - $('#' + 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) - }) // End of START button - - console.log('New form has been built.') -} - -/* Delete Record */ -function recDelete (recid, targetarea) { - var formid = rs_formid(recid) - var dataString = 'recid=' + recid - - 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) - - 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) - } - }) - }) -} - -/* New Record */ -function recNew (recid) { - var formid = rs_formid(recid) - var dataString = $('#' + formid).serialize() - - console.log('New rec: ' + 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
(recid:' + recid + ')
') - $('#' + trx_logarea(recid)).append('Inizio: ' + $('#' + rs_inputstart(recid)).val() + '
') - } - if (key == 'error') { - $('#' + trx_logarea(recid)).html('Errore: impossibile creare una nuova registrazione' + val + ' ') - } - }) - }) - return request -} - -/* Update Record */ -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 + ')') - - if (key == 'message') { - var str = '' - str += 'RecID ' + recid + '
' - str += 'nome ' + $('#' + rs_trxname(recid)).val() + '
' - str += 'Inizio ' + $('#' + rs_inputstart(recid)).val() + '
' - str += 'Fine ' + $('#' + rs_inputend(recid)).val() + '
' - - $('#' + trx_logarea(recid)).html(str) - // if all elements have been recorded - if ($('#' + rs_trxname(recid)).val() != '') { - $('#' + trx_logarea(recid)).append('In Elaborazione') - } - } - - if (key == 'error') { - $('#' + trx_logarea(recid)).append('Error:' + val + '
') - } - }) // end of each - }) // end of request.done -} - -/* - * - * AJAX REQUEST - * - */ -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) - } - }) - - 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: CHANGE STATE (gui) -*/ -function ChangeState (recid, from, to) { - console.log('ChangeState: ' + from + ' --> ' + to) - - $('#' + from).css('display', 'none') - $('#' + to).css('display', 'inline') - - // take the date - var displayDate = getnow() - - if (from == trx_startbut(recid)) { - $('#' + rs_inputstart(recid)).val(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_downbut(recid)) { - $('input[type=submit]').attr('disabled', 'disabled') - console.log("ChangeState: set '" + rs_inputend(recid) + "' to " + displayDate) - } -} // End function ChangeState - -// vim: set ts=4 sw=4 et: