diff --git a/bin/websocket.js b/bin/websocket.js index 45c9e2f..cf0f49e 100644 --- a/bin/websocket.js +++ b/bin/websocket.js @@ -79,6 +79,7 @@ class websocket { io.emit("callback.dataUpdate", self.getIndexFile()); }); + client.on("moveSong", (oldIndex, newIndex) => { let song = self.serverOptions.showData.songs.splice(oldIndex, 1); self.serverOptions.showData.songs.splice(newIndex, 0, song[0]); @@ -129,6 +130,16 @@ class websocket { io.emit("update", self.serverOptions); }) + client.on("newShow", () => { + self.serverOptions.currentShow = ""; + self.serverOptions.showData = { + name: "", + titles: [], + songs: [] + } + client.emit("updateAll", self.serverOptions); + }); + client.on("loadShow", (file) => { try { if (fs.existsSync("./data/shows/" + file)) { diff --git a/public/images/sort_asc.png b/public/images/sort_asc.png new file mode 100644 index 0000000..e1ba61a Binary files /dev/null and b/public/images/sort_asc.png differ diff --git a/public/images/sort_asc_disabled.png b/public/images/sort_asc_disabled.png new file mode 100644 index 0000000..fb11dfe Binary files /dev/null and b/public/images/sort_asc_disabled.png differ diff --git a/public/images/sort_both.png b/public/images/sort_both.png new file mode 100644 index 0000000..af5bc7c Binary files /dev/null and b/public/images/sort_both.png differ diff --git a/public/images/sort_desc.png b/public/images/sort_desc.png new file mode 100644 index 0000000..0e156de Binary files /dev/null and b/public/images/sort_desc.png differ diff --git a/public/images/sort_desc_disabled.png b/public/images/sort_desc_disabled.png new file mode 100644 index 0000000..c9fdd8a Binary files /dev/null and b/public/images/sort_desc_disabled.png differ diff --git a/public/javascripts/admin.js b/public/javascripts/admin.js index dd894bf..38dc19c 100644 --- a/public/javascripts/admin.js +++ b/public/javascripts/admin.js @@ -61,6 +61,7 @@ $(function () { action: function (text, value) { switch (value) { case "new": + socket.emit("newShow"); break; case "open": openShow(); @@ -145,7 +146,29 @@ function renameShow() { function openShow() { $('.fileAction').text("Open"); $("#dialogFilename").val(""); - $.getJSON("/ajax/shows", function (json) { + $('#showContent').DataTable().destroy(); + $('#showContent').DataTable({ + paging: false, + ajax: '/ajax/shows', + columns: [ + { data: "file" } + ], + "initComplete": function () { + var api = this.api(); + api.$('td').click(function () { + $("#dialogFilename").val(this.innerHTML); + }); + } + }); + + $('#showDialog').modal({ + blurring: true, + onApprove: function () { + socket.emit("loadShow", $("#dialogFilename").val()); + } + }).modal('show'); + + /*$.getJSON("/ajax/shows", function (json) { let data = ``; for (let elem of json) { data += ` @@ -163,57 +186,94 @@ function openShow() { socket.emit("loadShow", $("#dialogFilename").val()); } }).modal('show'); + }); - + */ } function saveShow() { $('.fileAction').text("Save"); $("#dialogFilename").val(""); - $.getJSON("/ajax/shows", function (json) { - let data = ``; - for (let elem of json) { - data += ` -
- -
-
${elem}
-
-
`; + $('#showContent').DataTable().destroy(); + $('#showContent').DataTable({ + paging: false, + scrollCollapse: true, + ajax: '/ajax/shows', + columns: [ + { data: "file" } + ], + "initComplete": function () { + var api = this.api(); + api.$('td').click(function () { + $("#dialogFilename").val(this.innerHTML); + }); } - $("#showContent").html(data); - $('#showDialog').modal({ - blurring: true, - onApprove: function () { - socket.emit("saveShow", $("#dialogFilename").val()); - } - }).modal('show'); }); + $('#showDialog').modal({ + blurring: true, + onApprove: function () { + socket.emit("saveShow", $("#dialogFilename").val()); + } + }).modal('show'); } function importSongs() { - $.getJSON("/ajax/songs", function (json) { - let data = ``; - for (let elem of json) { - data += ` -
-
-
Edit
-
Import
- -
- -
- ${elem.title} (${elem.artist}) -
- -
`; - } - $("#songContent").html(data); - $('#songDialog').modal({ - blurring: true - }).modal('show'); + /* $.getJSON("/ajax/songs", function (json) { + let data = ``; + for (let elem of json) { + data += ` +
+
+
Edit
+
Import
+
+ +
+ ${elem.title} (${elem.artist}) +
+ +
`; + } + $("#songContent").html(data);*/ + + $('#songContent').DataTable().destroy(); + $('#songContent').DataTable({ + paging: false, + scrollCollapse: true, + pageLength: 25, + lengthChange: false, + info: false, + ajax: '/ajax/songs', + columns: [ + { data: "title" }, + { data: "artist" }, + { data: "file" }, + ], + "columnDefs": [ + { + // The `data` parameter refers to the data for the cell (defined by the + // `data` option, which defaults to the column being worked with, in + // this case `data: 0`. + "render": function (data, type, row) { + return ` +
Edit
+
Import
+ `; + }, + "targets": 2 + }, + ] + /*"initComplete": function () { + var api = this.api(); + api.$('td').click(function () { + $("#dialogFilename").val(this.innerHTML); + }); + } */ }); + + $('#songDialog').modal({ + blurring: true + }).modal('show'); } diff --git a/public/javascripts/dataTables.semanticui.min.js b/public/javascripts/dataTables.semanticui.min.js new file mode 100644 index 0000000..fa4f882 --- /dev/null +++ b/public/javascripts/dataTables.semanticui.min.js @@ -0,0 +1,15 @@ +/*! + DataTables Bootstrap 3 integration + ©2011-2015 SpryMedia Ltd - datatables.net/license +*/ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var e=a.length,d=0;d<'right aligned eight wide column'f>><'row dt-table'<'sixteen wide column'tr>><'row'<'seven wide column'i><'right aligned nine wide column'p>>>", +renderer:"semanticUI"});a.extend(d.ext.classes,{sWrapper:"dataTables_wrapper dt-semanticUI",sFilter:"dataTables_filter ui input",sProcessing:"dataTables_processing ui segment",sPageButton:"paginate_button item"});d.ext.renderer.pageButton.semanticUI=function(f,l,B,C,m,u){var v=new d.Api(f),D=f.oClasses,n=f.oLanguage.oPaginate,E=f.oLanguage.oAria.paginate||{},h,k,w=0,z=function(q,x){var y,F=function(p){p.preventDefault();a(p.currentTarget).hasClass("disabled")||v.page()==p.data.action||v.page(p.data.action).draw("page")}; +var r=0;for(y=x.length;r",{"class":D.sPageButton+" "+k,id:0===B&&"string"=== +typeof g?f.sTableId+"_"+g:null,href:"#","aria-controls":f.sTableId,"aria-label":E[g],"data-dt-idx":w,tabindex:f.iTabIndex}).html(h).appendTo(q),f.oApi._fnBindAction(t,{action:g},F),w++)}}};try{var A=a(l).find(c.activeElement).data("dt-idx")}catch(q){}z(a(l).empty().html('