add and remove favorites
This commit is contained in:
parent
928af1f9d9
commit
6034bc24e1
28
css/main.css
28
css/main.css
@ -7,15 +7,29 @@
|
|||||||
background-position: center;
|
background-position: center;
|
||||||
display: inline;;
|
display: inline;;
|
||||||
}
|
}
|
||||||
|
|
||||||
#volumeslider{
|
#volumeslider{
|
||||||
width: 120px;
|
width: 120px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.play{background: url('../img/play.png') no-repeat;}
|
.play{background: url('../img/play.png') no-repeat;}
|
||||||
.pause{background: url('../img/pause.png') no-repeat;}
|
.pause{background: url('../img/pause.png') no-repeat;}
|
||||||
|
|
||||||
|
.icon-stationfav {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
margin-right: 5px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
position: absolute;
|
||||||
|
background-image: url('../img/fav.png');
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: contain;
|
||||||
|
background-position: center;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
/* SETTINGS */
|
/* SETTINGS */
|
||||||
#files-setting-showhidden {
|
#files-setting-showhidden {
|
||||||
@ -250,7 +264,7 @@ table td.filename .thumbnail {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
margin-left: 8px;
|
margin-left: 25px;
|
||||||
margin-top: 9px;
|
margin-top: 9px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
float: left;
|
float: left;
|
||||||
@ -263,11 +277,11 @@ table td.filename .thumbnail {
|
|||||||
table td.filename input.filename {
|
table td.filename input.filename {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
margin-top: 9px;
|
margin-top: 9px;
|
||||||
margin-left: 48px;
|
/*margin-left: 48px;*/
|
||||||
cursor: text;
|
cursor: text;
|
||||||
}
|
}
|
||||||
.has-favorites table td.filename input.filename {
|
.has-favorites table td.filename input.filename {
|
||||||
margin-left: 52px;
|
/*margin-left: 52px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:3px 8px 8px 3px; }
|
table td.filename a, table td.login, table td.logout, table td.download, table td.upload, table td.create, table td.delete { padding:3px 8px 8px 3px; }
|
||||||
@ -277,7 +291,7 @@ table td.filename .nametext, .uploadtext, .modified, .column-last>span:first-chi
|
|||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
width: 110px;
|
/*width: 110px;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO fix usability bug (accidental file/folder selection) */
|
/* TODO fix usability bug (accidental file/folder selection) */
|
||||||
@ -291,8 +305,8 @@ table td.filename .nametext {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.has-favorites #fileList td.filename a.name {
|
.has-favorites #fileList td.filename a.name {
|
||||||
left: 50px;
|
left: 0px;
|
||||||
margin-right: 50px;
|
margin-right: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide-hidden-files #fileList tr.hidden-file,
|
.hide-hidden-files #fileList tr.hidden-file,
|
||||||
@ -667,7 +681,7 @@ table.dragshadow {
|
|||||||
width:auto;
|
width:auto;
|
||||||
}
|
}
|
||||||
table.dragshadow td.filename {
|
table.dragshadow td.filename {
|
||||||
padding-left:60px;
|
/* padding-left:60px; */
|
||||||
padding-right:16px;
|
padding-right:16px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace OCA\Radio\Db;
|
namespace OCA\Radio\Db;
|
||||||
|
|
||||||
use OCP\IDb;
|
use OCP\IDBConnection;
|
||||||
use OCP\AppFramework\Db\Mapper;
|
use OCP\AppFramework\Db\Mapper;
|
||||||
|
|
||||||
class StationMapper extends Mapper {
|
class StationMapper extends Mapper {
|
||||||
|
|
||||||
public function __construct(IDb $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
parent::__construct($db, 'radio_stations', '\OCA\Radio\Db\Station');
|
parent::__construct($db, 'radio_stations', '\OCA\Radio\Db\Station');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
78
js/main.js
78
js/main.js
@ -2,23 +2,62 @@ $(function(){
|
|||||||
|
|
||||||
searchTimeout = null;
|
searchTimeout = null;
|
||||||
|
|
||||||
|
/* ==============
|
||||||
|
// EVENTS //
|
||||||
|
/===============*/
|
||||||
|
|
||||||
/* Click on a radio station (table entry) and play it */
|
/* Click on a radio station (table entry) and play it */
|
||||||
$('body').on('click', 'tr', function() {
|
$('body').on('click', '.filename', function() {
|
||||||
var stationid = $(this).attr('data-id');
|
var stationid = $(this).parent().attr('data-id');
|
||||||
play_station(stationid);
|
action_play(stationid);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
$('body').on('click', '.favpls', function() {
|
||||||
$('body').on('click', 'tr .icon', function() {
|
var stationid = $(this).parent().parent().attr('data-id');
|
||||||
alert('test');
|
action_favorite(stationid);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.icon-star').click(function (){
|
|
||||||
alert('test');
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
function play_station(stationid){
|
/* ==============
|
||||||
|
// ACTIONS //
|
||||||
|
/===============*/
|
||||||
|
|
||||||
|
function action_favorite(stationid){
|
||||||
|
var baseUrl = OC.generateUrl('/apps/radio');
|
||||||
|
var removed = false;
|
||||||
|
|
||||||
|
var stations = []
|
||||||
|
var baseUrl = OC.generateUrl('/apps/radio');
|
||||||
|
$.get(baseUrl + '/stations', function ( data ) {
|
||||||
|
for (var station in data) {
|
||||||
|
if (data[station]["stationid"] == stationid){
|
||||||
|
removed = true;
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/stations/' + data[station]["id"],
|
||||||
|
method: 'DELETE'
|
||||||
|
}).done(function(){
|
||||||
|
alert('delete row pls');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (removed == true) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
var station = {
|
||||||
|
"stationid": stationid
|
||||||
|
};
|
||||||
|
$.ajax({
|
||||||
|
url: baseUrl + '/stations',
|
||||||
|
method: 'POST',
|
||||||
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify(station)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function action_play(stationid){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "https://www.radio-browser.info/webservice/v2/json/url/"+stationid,
|
url: "https://www.radio-browser.info/webservice/v2/json/url/"+stationid,
|
||||||
@ -36,11 +75,13 @@ $(function(){
|
|||||||
function render_result(data){
|
function render_result(data){
|
||||||
$.each(data, function(i, station) {
|
$.each(data, function(i, station) {
|
||||||
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
|
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
|
||||||
<td class="filename">\
|
<td class="favcolumn">\
|
||||||
<a href="#" class="action action-favorite" onclick="station_fav();">\
|
<a href="#" class="favpls" onclick="station_fav();">\
|
||||||
<span class="icon icon-star"></span>\
|
<span class="icon-stationfav"></span>\
|
||||||
<span class="hidden-visually">Favorite</span>\
|
<span class="hidden-visually">Favorite</span>\
|
||||||
</a>\
|
</a>\
|
||||||
|
</td>\
|
||||||
|
<td class="filename">\
|
||||||
<label for="select-files-3">\
|
<label for="select-files-3">\
|
||||||
<div class="thumbnail" style="background-image:url('+station['favicon']+'); background-size: 32px;"></div>\
|
<div class="thumbnail" style="background-image:url('+station['favicon']+'); background-size: 32px;"></div>\
|
||||||
</label>\
|
</label>\
|
||||||
@ -52,14 +93,9 @@ $(function(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_station_ids(){
|
function action_load_favorites(){
|
||||||
var stations = []
|
var stations = []
|
||||||
var baseUrl = OC.generateUrl('/apps/radio');
|
var baseUrl = OC.generateUrl('/apps/radio');
|
||||||
var station = {
|
|
||||||
"id": 16,
|
|
||||||
"stationid": "89920",
|
|
||||||
"active": true
|
|
||||||
};
|
|
||||||
$.get(baseUrl + '/stations', function ( data ) {
|
$.get(baseUrl + '/stations', function ( data ) {
|
||||||
for (var station in data) {
|
for (var station in data) {
|
||||||
stations.push(data[station]["stationid"]);
|
stations.push(data[station]["stationid"]);
|
||||||
@ -117,7 +153,7 @@ $(function(){
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$('li.nav-favorite').addClass('active');
|
$('li.nav-favorite').addClass('active');
|
||||||
get_station_ids();
|
action_load_favorites();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<table id="filestable" data-preview-x="32" data-preview-y="32">
|
<table id="filestable" data-preview-x="32" data-preview-y="32">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th id='headerName' class=" column-name">
|
<th id='headerName' class=" column-name" colspan="2">
|
||||||
<div id="headerName-container">
|
<div id="headerName-container">
|
||||||
<a class="name sort columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>
|
<a class="name sort columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user