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