-
Notifications
You must be signed in to change notification settings - Fork 2
/
dj_manage_albums.html
205 lines (190 loc) · 7.05 KB
/
dj_manage_albums.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{% extends "base.html" %}
{% block title %}Manage Albums{% endblock %}
{% block extra_scripts %}
<script type='text/javascript'>
var newalbumlookup = "";
var oldalbumlookup = "";
var newalbumtimeout = null;
var oldalbumtimeout = null;
$(function() {
$('#manual-album-form').submit(addManualAlbum);
$("#album-lookup").keyup(function(e) {
if ($("#album-lookup").val() == "") {
$("#add-album-update").slideUp("slow");
} else if ($("#album-lookup").val() != newalbumlookup || e.keyCode == 13) {
clearTimeout(newalbumtimeout);
newalbumlookup = $("#album-lookup").val();
newalbumtimeout = setTimeout("amazonlookup(\"" + newalbumlookup + "\")", 300);
}
});
});
function amazonlookup(keywords) {
$.get('/ajax/albuminfo',
{
'keywords': keywords,
},
function(data) {
$("#add-album-results").slideUp("fast",function() {
$("#add-album-results").html(data.updatehtml);
$("#add-album-list li").click(addAmazonAlbum);
});
$("#add-album-update").slideDown("slow");
$("#add-album-results").slideDown("fast");
});
};
function addAmazonAlbum() {
$(this).addClass("album-processing")
$.post("/dj/albums",
{
'ajax': 1,
'asin': $(this).attr("id"),
'action': "add",
},
function(data) {
if (data.err) {
this.removeClass("album-processing");
alert(data.err);
} else {
$(this).removeClass("album-processing");
$("#add-album-update").hide("slow");
$("#amazon_msgbox").append(
'<div class="alert alert-success alert-block">'
+'<a class="close" data-dismiss="alert" href="#">'
+'×</a>'
+'<h4 class="alert-heading">Success!</h4>'
+data.msg+'</div>');
}
});
}
function addManualAlbum() {
$(this).addClass("album-processing");
$.post("/dj/albums",
{
'ajax': 1,
'action': 'manual',
'title': $("#manual-title").val(),
'artist': $("#manual-artist").val(),
'cover_url': $("#manual-url").val(),
'track-list': $("#manual-track-list").val(),
},
function(data) {
if (parseInt(data.result) != 0) {
$("#manual-album-form").removeClass("album-processing");
$("#manual_msgbox").append(
'<div class="alert alert-error alert-block">'
+'<a class="close" data-dismiss="alert"'
+'href="#">'
+'×</a>'
+'<h4 class="alert-heading">Bzzt!</h4>'
+data.msg+'</div>');
} else {
$("#manual-album-form").removeClass("album-processing");
$("#manual_msgbox").append(
'<div class="alert alert-success alert-block">'
+'<a class="close" data-dismiss="alert" href="#">'
+'×</a>'
+'<h4 class="alert-heading">Success!</h4>'
+data.msg+'</div>');
$("#manual-album-form").clearForm();
$("#manual-cover-preview-image").attr("src", '/static/images/noalbumart.png');
}
});
return false;
}
function toggleNew() {
var checkbox = this.getElementsByTagName("input");
var li = $(this);
if (li.hasClass("newalbum")) {
li.removeClass("newalbum").addClass("workingalbum");
$.post("/dj/albums/", { 'action': "makeOld", 'key': li.attr("id") },
function(data) {
li.removeClass("workingalbum").addClass("oldalbum");
$(checkbox).attr("checked", false);
$("#msgbox").html(data.msg);
}
);
} else if (li.hasClass("oldalbum")) {
li.removeClass("oldalbum").addClass("workingalbum");
$.post("/dj/albums/", { 'action': "makeNew", 'key': li.attr("id") },
function(data) {
li.removeClass("workingalbum").addClass("newalbum");
$(checkbox).attr("checked", true);
$("#msgbox").html(data.msg);
}
);
}
}
$(function() {
$("#manage-albums-list li").click(toggleNew);
$("#manual-url").change(function() {
$("#manual-cover-preview-image").attr("src", $(this).val());
});
});
</script>
{% endblock %}
{% block top_row %}
<div class="span12">
<h1>Album Management</h1>
<hr>
</div>
{% endblock %}
{% block left_column %}
<div id='add-album'>
<h2>Add Album from Amazon</h2>
<div>
<form class="form-search">
<input type='text' class="span7 search-query"
id='album-lookup' placeholder="Search Amazon">
</form>
<div class="row">
<div class="span8">
<div id='add-album-update' class="well">
<h3>Search Results</h3>
<div id='add-album-results'>
</div>
</div>
</div>
</div>
</div>
<div id="amazon_msgbox"></div>
<div id='new-albums'>
<h2>On the New Shelf</h2>
{% if new_album_html %}
{{ new_album_html|safe }}
{% else %}
{% include "dj_manage_new_albums_list.html"}
{% endif %}
</div>
</div>
{% endblock %}
{% block right_column %}
<div id='add-album-manual'>
<h2>Add Album Manually</h2>
<form id='manual-album-form' action='/dj/albums' method='post'>
<input type='hidden' name='action' value='manual'>
<label for='manual-title'>Title
<input type='text' name='title' id='manual-title' >
</label>
<label for='manual-artist'>Artist
<input type='text' class='artist-autocomplete' name='artist'
id='manual-artist'>
</label>
<div id='manual-cover-preview'>
<label for='manual-url'>URL to artwork
<input type='text' name='cover_url' id='manual-url'
value='/static/images/noalbumart.png'>
</label>
<img src='/static/images/noalbumart.png'
id='manual-cover-preview-image' >
</div>
<label>Track List
<textarea id='manual-track-list' name='track-list'
class="span4"
style="height: 120pt"></textarea>
</label>
<input id='manual-album-submit'
class="btn btn-primary"
type='submit' name='submit' value='Add'>
</form>
</div>
{% endblock %}