Skip to content

Commit

Permalink
added library track player
Browse files Browse the repository at this point in the history
added ability to play an album track from an associated URL

closes #166
  • Loading branch information
eric-gilbertson authored Jul 26, 2020
1 parent b2f30a6 commit f501df7
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 134 deletions.
8 changes: 6 additions & 2 deletions css/kzsustyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@ P.zktitle A {
background-image: URL('../img/kzsu/kzsu_rinfo.gif');
}
.editorUp {
background-image: URL('../img/kzsu/kzsu_list_up.gif');
background-color: #980000;
}
.editorDown {
background-image: URL('../img/kzsu/kzsu_list_dn.gif');
background-color: #980000;
}

.playTrack DIV {
filter: invert(0.3) sepia(1) saturate(5) hue-rotate(310deg);
}
44 changes: 39 additions & 5 deletions css/zoostyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,22 @@ TD.label-form {
.editorUp {
top: 0px;
width: 220px;
height: 10px;
height: 16px;
border: 0px;
background-image: URL('../img/list_up.gif');
color: #ffffff;
font-family: courier;
font-weight: 900;
background-color: #2530a7;
}
.editorDown {
top: 0px;
width: 220px;
height: 10px;
height: 16px;
border: 0px;
background-image: URL('../img/list_dn.gif');
font-family: courier;
font-weight: 900;
color: #ffffff;
background-color: #2530a7;
}
.editorChooser {
width: 220px;
Expand All @@ -259,6 +265,34 @@ TD.label-form {
scrollbar-width: none;
}

.trackEditor {
width: 100%;
}

.trackEditor TH {
font-size: 10pt;
text-align: left;
vertical-align: bottom;
line-height: 10px;
}

.trackTable TD.playTrack {
vertical-align: top;
}

.playTrack DIV {
filter: invert(59%) sepia(98%) saturate(1900%) hue-rotate(204deg) brightness(94%) contrast(88%); /* #828ae3 see https://codepen.io/sosuke/pen/Pjoqqp */
width: 18px;
height: 18px;
background-size: 18px;
background-image: URL("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiB3aWR0aD0iNDgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTAgMGg0OHY0OEgweiIgZmlsbD0ibm9uZSIvPjxwYXRoIGQ9Ik0yMCAzM2wxMi05LTEyLTl2MTh6bTQtMjlDMTIuOTUgNCA0IDEyLjk1IDQgMjRzOC45NSAyMCAyMCAyMCAyMC04Ljk1IDIwLTIwUzM1LjA1IDQgMjQgNHptMCAzNmMtOC44MiAwLTE2LTcuMTgtMTYtMTZTMTUuMTggOCAyNCA4czE2IDcuMTggMTYgMTYtNy4xOCAxNi0xNiAxNnoiLz48L3N2Zz4=");
}

.playTrack A:hover {
filter: saturate(10); /* doesn't work here in webkit */
text-decoration: none;
}

/* layout */
DIV.box {
width: 900px;
Expand Down Expand Up @@ -456,7 +490,7 @@ TH.sec {
.success {
color: #006600;
}
.text {
.text, .urlValue {
padding: 2px;
border: 1px solid #3b0000;
}
Expand Down
47 changes: 47 additions & 0 deletions db/convert_v2_9_0_to_v2_10_0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2020 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* version 3, along with this program. If not, see
* http://www.gnu.org/licenses/
*/

/**
* IMPORTANT NOTE:
*
* Run this script ONLY if you are converting an existing Zookeeper Online
* v2_9_0 database for use with the current codebase.
*
* If you are creating a new database, run zkdbSchema.sql and then populate
* the resulting db using the various bootstrap scripts as appropriate.
*/

--
-- Database: `zkdb`
--

SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8mb4;

ALTER TABLE `tracknames` ADD COLUMN `url` varchar(2083) NOT NULL DEFAULT '';
ALTER TABLE `colltracknames` ADD COLUMN `url` varchar(2083) NOT NULL DEFAULT '';

SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT;
SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS;
SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;
2 changes: 2 additions & 0 deletions db/zkdbSchema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ CREATE TABLE IF NOT EXISTS `colltracknames` (
`tag` int(11) DEFAULT NULL,
`track` varchar(80) DEFAULT NULL,
`artist` varchar(80) DEFAULT NULL,
`url` varchar(2083) NOT NULL DEFAULT '',
`seq` smallint(6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `tag` (`tag`),
Expand Down Expand Up @@ -344,6 +345,7 @@ CREATE TABLE IF NOT EXISTS `tracknames` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tag` int(11) DEFAULT NULL,
`track` varchar(80) DEFAULT NULL,
`url` varchar(2083) NOT NULL DEFAULT '',
`seq` smallint(6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `tag` (`tag`),
Expand Down
39 changes: 21 additions & 18 deletions engine/impl/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@ public function insertUpdateAlbum(&$album, $tracks, $label) {
// Album
$title = trim($album["album"]);
$artist = trim($album["artist"]);
$iscoll = "0";
if(!$album["location"])
$album["location"] = "L";
if(array_key_exists("coll", $album) && $album["coll"]) {
$artist = "[coll]: $title";
$iscoll = "1";
} else $iscoll = "0";
}

$newAlbum = !$album["tag"];

Expand Down Expand Up @@ -175,6 +176,10 @@ public function insertUpdateAlbum(&$album, $tracks, $label) {

// Tracks
if($tracks || $newAlbum) {
// We delete from both tracknames and colltracknames
// because someone could have toggled the 'compilation'
// checkbox; this ensures no stale track names remain
// in the other table.
$query = "DELETE FROM colltracknames WHERE tag=?";
$stmt = $this->prepare($query);
$stmt->bindValue(1, $album["tag"]);
Expand All @@ -183,25 +188,23 @@ public function insertUpdateAlbum(&$album, $tracks, $label) {
$stmt = $this->prepare($query);
$stmt->bindValue(1, $album["tag"]);
$stmt->execute();
//echo "DEBUG: affected rows: ".$stmt->rowCount()."<BR>";

//echo "DEBUG: query=$query<BR>";

for($i=1; $tracks && array_key_exists($i, $tracks); $i++) {
if($iscoll) {
$query = "INSERT INTO colltracknames (tag, seq, track, " .
"artist) VALUES (?, ?, ?, ?)";
$stmt = $this->prepare($query);
$stmt->bindValue(3, trim($tracks[$i]["track"]));
$stmt->bindValue(4, trim($tracks[$i]["artist"]));
} else {
$query = "INSERT INTO tracknames (tag, seq, track) ".
"VALUES (?, ?, ?)";
$stmt = $this->prepare($query);
$stmt->bindValue(3, trim($tracks[$i]));
}
$trackRow = $tracks[$i];
$trackName = trim($trackRow['track']);
$trackUrl = trim($trackRow['url']);
$query = "INSERT INTO tracknames (tag, seq, track, url) VALUES (?, ?, ?, ?)";
if ($iscoll)
$query = "INSERT INTO colltracknames (tag, seq, track, url, artist) VALUES (?, ?, ?, ?, ?)";

$stmt = $this->prepare($query);
$stmt->bindValue(1, $album["tag"]);
$stmt->bindValue(2, $i);
//echo "DEBUG: query=$query<BR>";
$stmt->bindValue(3, $trackName);
$stmt->bindValue(4, $trackUrl);
if ($iscoll)
$stmt->bindValue(5, trim($trackRow["artist"]));

$stmt->execute();
}
}
Expand Down Expand Up @@ -302,7 +305,7 @@ public function getAlbum($tag) {
}

public function getTracks($tag, $isColl) {
$table = $isColl?"colltracknames":"tracknames";
$table = $isColl?"colltracknames":"tracknames";
$query = "SELECT * FROM $table WHERE tag = ? ORDER BY seq";
$stmt = $this->prepare($query);
$stmt->bindValue(1, $tag);
Expand Down
4 changes: 4 additions & 0 deletions js/editor.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ $().ready(function() {
}
for(var j=next; j>focus; j--) {
$("INPUT[name='track" + j + "' i]").val($("INPUT[name='track" + (j-1) + "' i]").val());
$("INPUT[name='trackUrl" + j + "' i]").val($("INPUT[name='trackUrl" + (j-1) + "' i]").val());
if(coll) {
$("INPUT[name='artist" + j + "' i]").val($("INPUT[name='artist" + (j-1) + "' i]").val());
}
}
$("INPUT[name='track" + focus + "' i]").val("");
$("INPUT[name='trackUrl" + focus + "' i]").val("");
if(coll) {
$("INPUT[name='artist" + focus + "' i]").val("");
}
Expand All @@ -228,11 +230,13 @@ $().ready(function() {
var last = nextTrack()-1;
for(var j=focus; j<last; j++) {
$("INPUT[name='track" + j + "' i]").val($("INPUT[name='track" + (j+1) + "' i]").val());
$("INPUT[name='trackUrl" + j + "' i]").val($("INPUT[name='trackUrl" + (j+1) + "' i]").val());
if(coll) {
$("INPUT[name='artist" + j + "' i]").val($("INPUT[name='artist" + (j+1) + "' i]").val());
}
}
$("INPUT[name='track" + last + "' i]").val("");
$("INPUT[name='trackUrl" + last + "' i]").val("");
if(coll) {
$("INPUT[name='artist" + last + "' i]").val("");
}
Expand Down
Loading

0 comments on commit f501df7

Please sign in to comment.