update WTVBGMusic class/system
- rename getCategoryList to getCategorySongList - add proper getCategoryList which filters client usable categories - do not show empty categories to classic clients
This commit is contained in:
@@ -68,22 +68,27 @@ Choose a style name to see the songs for that style.
|
||||
<input type="hidden" autosubmit="onLeave">
|
||||
`;
|
||||
var catsListed = 0;
|
||||
var numCats = wtvbgm.categories.length;
|
||||
var categories = wtvbgm.getCategoryList();
|
||||
var numCats = categories.length;
|
||||
var divide = Math.round(numCats / 2, 0);
|
||||
Object.keys(wtvbgm.categories).forEach(function (k) {
|
||||
if (catsListed == divide) {
|
||||
data += `</td ><td width="20">
|
||||
</td><td width="198" valign="top" align="left">`;
|
||||
}
|
||||
|
||||
Object.keys(categories).forEach(function (k) {
|
||||
var pubcat = parseInt(k) + 1;
|
||||
data += `<table>
|
||||
var songsInCat = wtvbgm.getCategorySongList(pubcat);
|
||||
if (songsInCat.length > 0) {
|
||||
if (catsListed == divide) {
|
||||
data += `</td ><td width="20">
|
||||
</td><td width="198" valign="top" align="left">`;
|
||||
}
|
||||
data += `<table>
|
||||
<tbody><tr>
|
||||
<td valign="top">
|
||||
<input type="checkbox" name="enableCategory" value=${pubcat}${(wtvbgm.isCategoryEnabled(pubcat)) ? ' checked="checked"' : ''}>
|
||||
</td><td valign="bottom">
|
||||
<a href="wtv-setup:/set-bg?category=${pubcat}">${wtvbgm.categories[k]}</a><br>
|
||||
<a href="wtv-setup:/set-bg?category=${pubcat}">${categories[k]}</a><br>
|
||||
</td></tr></tbody></table>`;
|
||||
catsListed++;
|
||||
catsListed++;
|
||||
}
|
||||
});
|
||||
|
||||
data += `
|
||||
|
||||
@@ -3,7 +3,7 @@ var minisrv_service_file = true;
|
||||
var WTVBGMusic = require("./WTVBGMusic.js");
|
||||
var wtvbgm = new WTVBGMusic(minisrv_config, ssid_sessions[socket.ssid]);
|
||||
if (request_headers.query.category) {
|
||||
var musicList = wtvbgm.getCategoryList(request_headers.query.category);
|
||||
var musicList = wtvbgm.getCategorySongList(request_headers.query.category);
|
||||
var categoryName = wtvbgm.getCategoryName(request_headers.query.category);
|
||||
|
||||
headers = `200 OK
|
||||
|
||||
@@ -1077,7 +1077,8 @@ class WTVBGMusic {
|
||||
return null;
|
||||
}
|
||||
|
||||
getCategoryList(category) {
|
||||
|
||||
getCategorySongList(category) {
|
||||
if (this.session_data.hasCap("client-can-do-rmf")) {
|
||||
// use rmf list
|
||||
var musiclist = this.musiclist_rmf;
|
||||
@@ -1099,6 +1100,17 @@ class WTVBGMusic {
|
||||
return songList.filter(value => Object.keys(value).length !== 0);
|
||||
}
|
||||
|
||||
getCategoryList() {
|
||||
var categories = [];
|
||||
var self = this;
|
||||
Object.keys(self.categories).forEach(function (k) {
|
||||
var songList = self.getCategorySongList(parseInt(k) + 1);
|
||||
if (songList.length > 0) categories[k] = self.categories[k];
|
||||
});
|
||||
return categories.filter(value => Object.keys(value).length !== 0);
|
||||
}
|
||||
|
||||
|
||||
getCategoryName(category) {
|
||||
return this.categories[parseInt(category) - 1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user