//default PopupDiv properties for playlists (mainly for css appearence)
PopupDiv.popupClass = 'control component';
PopupDiv.popupCss = {
- 'border':'1px solid #999',
- 'padding':'1ex'
+ 'border': '1px solid #999',
+ 'padding': '1ex'
};
-PopupDiv.okButtonTitle = 'Ok';
-PopupDiv.okButtonClass = 'component_icon button icon_ok';
-PopupDiv.closeButtonTitle = '';
-PopupDiv.closeButtonClass = 'markersdivDelete';
+PopupDiv.okButtonTitle = 'Ok';
+PopupDiv.okButtonClass = 'component_icon button icon_ok';
+PopupDiv.closeButtonTitle = '';
+PopupDiv.closeButtonClass = 'markersdivDelete';
PopupDiv.defaultCloseOperation = 'remove';
PopupDiv.focusable = true;
PopupDiv.listItemClass = "component_icon list_item icon_playlist";
var playlistUtils = {
- playlists : [],
+ playlists: [],
- addPlaylist: function(name, id){
+ addPlaylist: function (name, id) {
this.playlists.push({
- 'name':name,
- 'id':id
+ 'name': name,
+ 'id': id
});
},
- addEditPlaylist: function(id, title, description){
+ addEditPlaylist: function (id, title, description) {
this.playlists.push({
'id': id,
'title': title,
});
},
- showAdd: function(anchorElement){
+ showAdd: function (anchorElement) {
var t = gettrans('title');
var d = gettrans('description');
var dd = {};
- dd[t]='';
- dd[d]='';
+ dd[t] = '';
+ dd[d] = '';
var playlist = this;
new PopupDiv({
- 'content':dd,
- invoker:anchorElement,
- showOk:true,
- onOk:function(data){
- if(!data[t] && !data[d]){
+ 'content': dd,
+ invoker: anchorElement,
+ showOk: true,
+ onOk: function (data) {
+ if (!data[t] && !data[d]) {
return;
}
//convert language
playlist.add({
- 'title':data[t],
- 'description':data[d]
+ 'title': data[t],
+ 'description': data[d]
});
}
}).show();
* Copied from Timeside.utils.uniqid (Timeside might NOT ALWAYS be loaded, see home.html when user is authenitcated)
*
*/
- uniqid : function() {
+ uniqid: function () {
var d = new Date();
return new String(d.getTime() + '' + Math.floor(Math.random() * 1000000)).substr(0, 18);
},
- add : function(dictionary){
+ add: function (dictionary) {
- if(dictionary.public_id===undefined){
+ if (dictionary.public_id === undefined) {
dictionary.public_id = this.uniqid();
}
- if(dictionary.user===undefined){
+ if (dictionary.user === undefined) {
dictionary.user = CURRENT_USER_NAME;
}
- json([dictionary],'telemeta.add_playlist',function(){
+ json([dictionary], 'telemeta.add_playlist', function () {
window.location.reload();
});
},
- remove: function(id){
- json([id],'telemeta.del_playlist',function(){
+ remove: function (id) {
+ json([id], 'telemeta.del_playlist', function () {
window.location.reload();
});
},
- removeResource: function(id, range_playlist){
- json([id, range_playlist],'telemeta.del_playlist_resource',function(data){
- var id = data.result;
- window.location.pathname = '/desk/lists/open-list-' + id;
+ removeResource: function (id, range_playlist) {
+ json([id, range_playlist], 'telemeta.del_playlist_resource', function (data) {
+ var id = data.result;
+ window.location.pathname = '/desk/lists/open-list-' + id;
});
},
- update : function(dictionary){
- json([dictionary],'telemeta.update_playlist',function(){
- window.location.reload();
+ update: function (dictionary) {
+ json([dictionary], 'telemeta.update_playlist', function () {
+ window.location.reload();
});
},
- showEdit: function(anchorElement, id){
+ showEdit: function (anchorElement, id) {
var t = gettrans('title');
var d = gettrans('description');
var playlist = this;
var playlists = this.playlists;
- for (var i=0; i< playlists.length; i++){
- if (playlists[i].id == id){
+ for (var i = 0; i < playlists.length; i++) {
+ if (playlists[i].id == id) {
dd[t] = playlists[i].title;
dd[d] = playlists[i].description;
}
}
new PopupDiv({
- 'content':dd,
- invoker:anchorElement,
- showOk:true,
- onOk:function(data){
- if(!data[t] && !data[d]){
- return;
- }
- //convert language
- playlist.update({
- 'public_id': id,
- 'title': data[t],
- 'description': data[d],
- });
- }
+ 'content': dd,
+ invoker: anchorElement,
+ showOk: true,
+ onOk: function (data) {
+ if (!data[t] && !data[d]) {
+ return;
+ }
+ //convert language
+ playlist.update({
+ 'public_id': id,
+ 'title': data[t],
+ 'description': data[d],
+ });
+ }
}).show();
},
/*shows the popup for adding a resource to a playlist*/
- showAddResourceToPlaylist: function(anchorElement, resourceType, objectId, optionalOkMessage){
+ showAddResourceToPlaylist: function (anchorElement, resourceType, objectId, optionalOkMessage) {
var ar = [];
var playlists = this.playlists;
- for(var i=0; i< playlists.length; i++){
+ for (var i = 0; i < playlists.length; i++) {
ar.push(playlists[i].name);
}
var pl = this;
- if(!ar.length){
+ if (!ar.length) {
pl.showAdd(anchorElement);
}
//var addFcn = this.addResourceToPlaylist;
new PopupDiv({
- invoker:anchorElement,
+ invoker: anchorElement,
content: ar,
- onOk:function(data){
+ onOk: function (data) {
var val = data.selIndex;
var callbackok = undefined;
- if(optionalOkMessage){
- callbackok = function(){
- var p =new PopupDiv({
- content : "<div class='component_icon icon_ok'>"+optionalOkMessage+"</div>",
- focusable: false
-
- });
- p.bind('show', function(){
- this.setTimeout('close',1500); //this refers to p
- });
- p.show();
+ if (optionalOkMessage) {
+ callbackok = function () {
+ localStorage['messOkPlaylist'] = optionalOkMessage;
+ localStorage['displayOkPlaylist']=true;
+ window.location.reload();
}
}
- pl.addResourceToPlaylist.apply(pl,[playlists[val].id,resourceType,objectId,callbackok]);
+ pl.addResourceToPlaylist.apply(pl, [playlists[val].id, resourceType, objectId, callbackok]);
}
}).show();
},
//resourceType can be: 'collection', 'item', 'marker'
- addResourceToPlaylist: function(playlistId,resourceType,objectId, callbackOnSuccess,callbackOnError){
+ addResourceToPlaylist: function (playlistId, resourceType, objectId, callbackOnSuccess, callbackOnError) {
var send = {
- 'public_id':this.uniqid(),
- 'resource_type':resourceType,
- 'resource_id':objectId
+ 'public_id': this.uniqid(),
+ 'resource_type': resourceType,
+ 'resource_id': objectId
};
- json([playlistId,send],'telemeta.add_playlist_resource',callbackOnSuccess,callbackOnError);
+ json([playlistId, send], 'telemeta.add_playlist_resource', callbackOnSuccess, callbackOnError);
+ },
+
+ messageOk: function () {
+ if (localStorage['displayOkPlaylist']) {
+ var p = new PopupDiv({
+ content: "<div class='component_icon icon_ok'>" + localStorage['messOkPlaylist']+ "</div>",
+ focusable: false
+
+ });
+ p.bind('show', function () {
+ this.setTimeout('close', 1500); //this refers to p
+ });
+ p.show();
+ localStorage.removeItem('displayOkPlaylist');
+ localStorage.removeItem('messOkPlaylist');
+ }
+
}