setSelectedMenu();\r
});\r
\r
-//function to communicate with the server\r
-//param: the data to be sent or retrieved. Recognized types: \r
-// string, boolean number, dictionary of recognized types (including sub-dictionaries) and\r
-// arrays of recognized types (including sub-arrays). param will be converted to string, escaping quotes newlines\r
-// and backslashes if necessary.\r
-//method: the json method, eg "telemeta.update_marker"\r
-//onSuccesFcn(data, textStatus, jqXHR)\r
+//****************************************************************************\r
+//global function to senbd/retrieve data with the server\r
+//\r
+//param: the data to be sent or retrieved.\r
+// param will be converted to string, escaping quotes newlines and backslashes if necessary.\r
+// param can be a javascript string, boolean, number, dictionary and array.\r
+// If dictionary or array, it must contain only the above mentioned recognized types.\r
+// So, eg, {[" a string"]} is fine, {[/asd/]} not\r
+//\r
+//method: the json method, eg "telemeta.update_marker". See base.py\r
+//\r
+//onSuccesFcn(data, textStatus, jqXHR) OPTIONAL\r
// A function to be called if the request succeeds.\r
// The function gets passed three arguments:\r
// The data returned from the server, formatted according to the dataType parameter;\r
// a string describing the status;\r
// and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object\r
-//showAlertError: if true, on error a msg dialog box is shown\r
-var json = function(param,method,onSuccessFcn,showAlertOnError){\r
+//\r
+//onErrorFcn(jqXHR, textStatus, errorThrown) OPTIONAL. --If missing, default dialog error is shown--\r
+// A function to be called if the request fails.\r
+// The function receives three arguments:\r
+// The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object,\r
+// a string describing the type of error that occurred and\r
+// an optional exception object, if one occurred.\r
+// Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror".\r
+//****************************************************************************\r
+\r
+var json = function(param,method,onSuccessFcn,onErrorFcn){\r
//this function converts a javascript object to a string\r
var toString_ = function(string){\r
if(typeof string == "string"){\r
}\r
},\r
error: function(jqXHR, textStatus, errorThrown){\r
- if(showAlertOnError){\r
- var details = "\n(no further info available)";\r
- if(jqXHR) {\r
- details="\nThe server responded witha status of "+jqXHR.status+" ("+\r
- jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText;\r
- }\r
- alert("ERROR: Failed to save"+details);\r
+ if(onErrorFcn){\r
+ onErrorFcn(jqXHR, textStatus, errorThrown);\r
+ return;\r
+ }\r
+ //default:\r
+ var details = "\n(no further info available)";\r
+ if(jqXHR) {\r
+ details="\nThe server responded witha status of "+jqXHR.status+" ("+\r
+ jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText;\r
}\r
+ alert("ERROR: Failed to save"+details);\r
+ \r
}\r
});\r
\r
divsToDelete:null,\r
toggleBind: function(element, functionE){\r
var clickNamespace = "click.popup__";\r
- var keydownNamespace = "keydown.popup__";\r
+ var keydownNamespace = "keyup.popup__";\r
element.unbind(clickNamespace);\r
element.unbind(keydownNamespace);\r
if(functionE){\r
height: max(20, (windowH + wdow.scrollTop() -position.top- shadowOffset))\r
}\r
//position div and size:\r
- var divPadding = {left: div.outerWidth()-div.width(), top:div.outerHeight()-div.height()}; //setting width on a div means the width(),\r
+ var divPadding = {\r
+ left: div.outerWidth()-div.width(),\r
+ top:div.outerHeight()-div.height()\r
+ }; //setting width on a div means the width(),\r
//but calculations here are made according to outerWidth(true), so we need this variable (se below)\r
\r
div.css({\r
});\r
div.show(300, function(){ //400: basically in between fast (200) and slow (600)\r
//position div shadow:\r
- divShadow.css({\r
+ divShadow.css({\r
'top': (position.top+shadowOffset),\r
'left': (position.left+shadowOffset),\r
'width': div.outerWidth(true),\r
p.hide();\r
return false;\r
};\r
+ \r
var onOk= function(){\r
if(callbackOnOk){\r
var ret = {};\r
var inputs = table.find("input");\r
- for(var ipt in inputs){\r
- var i = $(ipt);\r
- ret[i.attr('name')] = i.val();\r
- }\r
+ $J.each(inputs, function(key,value){\r
+ var v = $J(value);\r
+ ret[v.attr('name')] = v.val();\r
+ });\r
callbackOnOk(ret);\r
return false;\r
}else{\r
-var playlist = {
+var playlistUtils = {
// add : function(event){
//
dictionary.user = CURRENT_USER_NAME;
}
- json(dictionary,'telemeta.add_playlist',function(){
+ json([dictionary],'telemeta.add_playlist',function(){
window.location.reload();
- },true);
+ });
},
remove: function(id){
json([id],'telemeta.del_playlist',function(){
window.location.reload();
- },true);
+ });
},
removeResource: function(id){
json([id],'telemeta.del_playlist_resource',function(){
window.location.reload();
- },true);
+ });
},
//resourceType can be: 'collection', 'item', 'marker'
- addToPlaylist: function(elementInvoker, playlistId,resourceType,objectId){
+ addToPlaylist: function(playlistId,resourceType,objectId){
var send = {
'public_id':uniqid(),
'resource_type':resourceType,
var p = popup;
p.show(jQuery('<div/>').html('<a style="border:0" class="mediaitem_button mediaitem_button_ok">Ok</span>'));
setTimeout(function(){p.hide()},600);
- },true);
+ });
}
-// ,add:function(title){
-// if(title instanceof String)
-//
-// var pl = [{"public_id":new Date().getTime(), "title":title, "description":"", user:"admin"}];
-// json(pl,'telemeta.add_playlist',alert('done'),true);
-//}
}
-//varf();
-//function varf(){
-// playlist.add('myplaylist');
-//}
-
{% block extra_javascript %}
<script src="{% url telemeta-js "swfobject.js" %}" type="text/javascript"></script>
+<script src="{% url telemeta-timeside "src/playlist.js" %}" type="text/javascript"></script>
+<script>
+ jQuery(document).ready(function(){
+ var content = $('#_popup_add_to_playlist').clone(true,true);
+ $('#_add_to_playlist').click(function(e){return popup.show(content,e)});
+ });
+</script>
{% endblock %}
{% if collection %}
<a href="{% url telemeta-collection-copy collection.public_id %}" class="mediaitem_button mediaitem_button_copy">{% trans "Copy" %}</a>
{% endif %}
{% if user.is_authenticated %}
- {% trans "Add to playlist" %}
+ <a href=# id ="_add_to_playlist" class="mediaitem_button mediaitem_button_add">{% trans "Add to playlist" %}</a>
+ <div id="_popup_add_to_playlist" style="display:none">
+ {% for playlist in playlists %}
+ <a href="#" class="listItem mediaitem_button mediaitem_button_playlist"
+ onclick="playlistUtils.addToPlaylist('{{playlist.playlist.public_id}}','collection','{{collection.pk}}');">{{ playlist.playlist.title }}</a>
+ {% endfor %}
+ </div>
{% endif %}
- {% endblock tools %}
+ {% endblock tools %}
</div>
var so = new SWFObject('{% url telemeta-swf "mp3player.swf" %}','playlist','362','200','7');
so.addVariable("file","{% url telemeta-collection-xspf collection.public_id %}");
so.addVariable("displayheight","0");
+ so.addParam("wmode", "opaque");
so.write('collection_player_c');
</script>
</div>
set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}');
load_player({{ item.approx_duration.as_seconds }});
jQuery(document).ready(function(){
- var content = $('#_a_p_5638').clone(true,true);
+ var content = $('#_popup_add_to_playlist').clone(true,true);
$('#_add_to_playlist').click(function(e){return popup.show(content,e)});
});
</script>
{% if user.is_authenticated %}
<a id="_add_to_playlist" href=# class="mediaitem_button mediaitem_button_add">{% trans "Add to playlist" %}</a>
- <div id="_a_p_5638" style="display:none">
+ <div id="_popup_add_to_playlist" style="display:none">
{% for playlist in playlists %}
<a href="#" class="listItem mediaitem_button mediaitem_button_playlist"
- onclick="playlist.addToPlaylist(jQuery(this),'{{playlist.playlist.public_id}}','item','{{item.pk}}');">{{ playlist.playlist.title }}</a>
+ onclick="playlistUtils.addToPlaylist('{{playlist.playlist.public_id}}','item','{{item.pk}}');">{{ playlist.playlist.title }}</a>
{% endfor %}
</div>