src/de/uhilger/mediaz/api/JsonHelper.java | ●●●●● patch | view | raw | blame | history | |
src/de/uhilger/mediaz/api/ListHandler.java | ●●●●● patch | view | raw | blame | history | |
www/ui/data/tpl/titel_liste.tpl | ●●●●● patch | view | raw | blame | history | |
www/ui/js/app.js | ●●●●● patch | view | raw | blame | history |
src/de/uhilger/mediaz/api/JsonHelper.java
@@ -28,6 +28,7 @@ } public String jsonWithCustomType(Object o, String typeName) { /* StringBuilder sb = new StringBuilder(); sb.append("{\""); sb.append(typeName); @@ -36,6 +37,21 @@ sb.append(gson.toJson(o)); sb.append("}"); return sb.toString(); */ Gson gson = new Gson(); return embedInCustomType(gson.toJson(o), typeName); } public String embedInCustomType(String jsonStr, String typeName) { StringBuilder sb = new StringBuilder(); sb.append("{\""); sb.append(typeName); sb.append("\": "); //Gson gson = new Gson(); //sb.append(gson.toJson(o)); sb.append(jsonStr); sb.append("}"); return sb.toString(); } } src/de/uhilger/mediaz/api/ListHandler.java
@@ -51,7 +51,7 @@ String plname = elems[elems.length - 1]; FileStorage fs = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); String json = fs.readJson(FileStorage.ST_ABSPIELLISTE, plname); return json; return embedInCustomType(json, FileStorage.ST_ABSPIELLISTE); } @Override www/ui/data/tpl/titel_liste.tpl
@@ -1,12 +1,18 @@ <!-- {"Abspielliste": {"name":"spontan","titel":[{"katalogUrl":"/media/mc","name":"/A/ACDC/Highway-To-Hell02-Girls-got-rhythm.mp3"},{"katalogUrl":"/media/mc","name":"/A/ACDC/Highway-To-Hell07-Get-it-hot.mp3"},{"katalogUrl":"/media/mc","name":"/A/Aerosmith/Big-Ones12-Crazy.mp3"}]}} --> {{#Abspielliste}} <div class='entity-formular'> <div class='entity-liste-kopf'> Abspielliste {{name}} <!-- <button class='ctrl-btn' id='neu-btn' title='Neu'><i class='icon-doc'></i></button> --> </div> <ul class='entity-liste'> {{#ArrayList}} <li class='entity-eintrag'>{{.}}</li> {{/ArrayList}} {{#titel}} <li class='entity-eintrag'>{{katalogUrl}}{{name}}</li> {{/titel}} </ul> </div> {{/Abspielliste}} www/ui/js/app.js
@@ -74,19 +74,28 @@ /* ---------------- Titel einer Abspielliste ----------------- */ this.titel_liste = function() { self.http_get('../api/store/Ablageort/liste/', function (responseText) { self.vorlage_laden_und_fuellen("data/tpl/ablageort_liste.tpl", JSON.parse(responseText), function (html) { self.reset_top_buttons(); var plname = document.querySelector('#playlist').value; self.http_get('../api/alist/' + plname, function (responseText) { self.vorlage_laden_und_fuellen("data/tpl/titel_liste.tpl", JSON.parse(responseText), function (html) { document.querySelector(".zentraler-inhalt").innerHTML = html; self.addEvtListener('.entity-eintrag', 'click', function (event) { var t = event.target; self.removeClassMulti('selected'); t.classList.add('selected'); /* self.http_get('../api/store/Ablageort/' + t.textContent, function(responseText){ var ablageort = JSON.parse(responseText); self.ablageort_form(ablageort); }); */ }); /* self.addEvtListener('#neu-btn', 'click', function (event) { eval("self.ablageort_form" + "(this)"); }); */ }); }); }; @@ -165,7 +174,12 @@ this.addSelectedTitel = function() { var titelName = document.querySelector(".selected").textContent; var titel = new Titel(self.mediaPfad + titelName, self.ortPfad); var titel; if(self.mediaPfad.endsWith('/')) { titel = new Titel(self.mediaPfad + titelName, self.ortPfad); } else { titel = new Titel(self.mediaPfad + '/' + titelName, self.ortPfad); } var plname = document.querySelector('#playlist').value; self.http_put('../api/alist/' + plname, JSON.stringify(titel), function(responseText) { self.meldung_mit_timeout(responseText, 1500);