var menudata = {"title": "Main Menu","type": "root","items": [{ "title": "Playlists", "type": "menu", "caption": "Create, play, and organize playlists.", "items": [{ "title": "New Playlist", "type": "link", "caption": "Create a new playlist.", "action": "addPlaylist" },{ "title": "New RSS Playlist", "type": "link", "caption": "Convert RSS feed into a playlist.", "action": "addRSSPlaylist" },{'id':279840,'index':0,'type':'playlist','rss':0,'title':'Top 50','length':50,'ajax':{url:'php/getPlaylist.php',query:'id=279840'}}] },{ "title": "Friend\'s Playlists", "type": "ajaxMenu", "caption": "Browse your friend\'s playlists.", "ajaxUrl": "php/getFriends.php", "ajaxMethod": "getFriends", "ajaxParameters": "" },{ "title": "Inbox", "type": "ajaxMenu", "caption": "Browse received playlists.", "ajaxUrl": "php/getInbox.php", "ajaxMethod": "getInbox", "ajaxParameters": "" },{ "title": "Settings", "type": "menu", "caption": "Change password and customize.", "items": [{ "title": "Change Password", "type": "link", "caption": "Set a new password.", "action": "changePassword" },{ "title": "Change Profile Pic", "type": "link", "caption": "Upload or change profile picture.", "action": "changePic" },{ "title": "Skins", "type": "ajaxMenu", "caption": "Customize your Mediabox.", "ajaxUrl": "php/getSkins.php", "ajaxMethod": "getSkins", "ajaxParameters": "" } ] }]}; var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i 0) { //Jukebox.player_cover.removeChild(Jukebox.player_cover.firstChild); Jukebox.removeElement(Jukebox.player_cover.firstChild); } var wmode = ''; if (song.results) { if (true || !song.resultFisheye) { //generate element var items = new Array(); for(var i = 0 ; i < song.results.length ; i++) { var img = document.createElement('img'); img.src = song.results[i].properties.thumbUrl; img.setAttribute('width',30); img.style.height = 'auto'; items.push([img,song.results[i].properties.title,eval("fishResult = function(){song.search.resultId = "+i+";song.search.playVideo();return false;}")]) } song.resultFisheye = fishEye(items,Jukebox.player_cover,40,50,60); wmode = "wmode='transparent'"; /*song.resultFisheye.onmouseout = function() { song.fisheyeTimeout = setTimeout(function(){ fadeOut(song.resultFisheye); },100); } song.resultFisheye.onmouseover = function() { if (song.fisheyeTimeout) { clearTimeout(song.fisheyeTimeout); song.fisheyeTimeout = null; } fadeIn(song.resultFisheye); }*/ /*song.resultFisheye.onmousemove = function() { song.resultFisheye.style.overflow = ''; }*/ } //Jukebox.player_cover.appendChild(song.resultFisheye); } this.song = song; this.syncTitle(song); /* var embed=document.createElement('embed'); embed.setAttribute('wmode','transparent'); embed.setAttribute('allowScriptAccess','sameDomain'); embed.setAttribute('type','application/x-shockwave-flash'); embed.setAttribute('src',song.properties.embedUrl+''); Jukebox.player_video.appendChild(embed); */ //wmode = "wmode='transparent'"; var embedCode = ""; Jukebox.player_video.innerHTML = embedCode; if (this.timeout) { clearTimeout(this.timeout); this.timeout = null; } setTimeout(function(){Jukebox.clearSongs()},Jukebox.preroll); this.timeout = setTimeout(function(){Jukebox.addSong(Jukebox.getNextSong(song));},(song.properties.duration-1000)); var code; if (song.properties.id == undefined) { code = itemCodeGen(song.properties); } send({ url:'../jukebox/php/stats.php', query:'method=songview'+(song.properties.id != undefined?'&id='+song.properties.id:'&data='+encodeURIComponent(code.substr(1,code.length-2)))+'&embed_url='+encodeURIComponent(song.properties.embedUrl)+'&title='+encodeURIComponent(song.properties.title)+'&caption='+encodeURIComponent(song.properties.caption)+'&duration='+encodeURIComponent(song.properties.duration)+(Jukebox.viewId?'&viewId='+Jukebox.viewId:''), success:function(response) { Jukebox.viewId = parseInt(response); } }); }; Jukebox.dropSong = function() { if (Jukebox.player_video.firstChild) { //Jukebox.player_video.removeChild(Jukebox.player_video.firstChild); Jukebox.removeElement(Jukebox.player_video.firstChild); } }; Jukebox.clearSongs = function(remaining) { if (remaining == undefined) { var remaining = 1; } if (remaining == 0) { clearTimeout(this.timeout); this.timeout = null; } while (remaining < Jukebox.player_video.childNodes.length) { //Jukebox.player_video.removeChild(Jukebox.player_video.firstChild); Jukebox.removeElement(Jukebox.player_video.firstChild); } }; function getObj(item,readonly,depth) { readonly = readonly || item.readonly; depth = depth || 0; if (item.type == 'menu' || item.type == 'root') { var obj = new Menu(item); // STORE PLAYLISTS AS A PROPERTY if (item.title == 'Playlists') { Jukebox.playlists = obj.children; } } else if (item.type == 'ajaxMenu') { var obj = new AjaxMenu(item); } else if (item.type == 'playlist') { var obj = new Playlist(item); } else if (item.type == 'song') { var obj = new Song(item); } else if (item.type == 'link') { var obj = new Link(item); } if (item.type == 'root') { // arrange title box thing //moved to Jukebox.load //obj.contents.style.display = 'inline'; } else { // item.parent.contents.appendChild(obj.o); } obj.readonly = readonly; obj.properties = item; if (readonly) { obj.removeButton('edit'); obj.removeButton('delete'); if (obj.type == 'playlist') { obj.addButton('yoink',function(){obj.yoink();return false;}); } } if (item.items) { if (depth == 0) { for (var i=0;i < item.items.length;i++) { // obj.add takes in an ITEM OBJECT, not a set of properties' var tempObj = getObj(item.items[i],readonly,depth+1); obj.add(tempObj); item.items[i] = tempObj; } } else { obj.ungenerated = item.items; Jukebox.ungenerated.push(obj); } } return obj; } // JUKEBOXCONTROL Jukebox.syncTitle = function(item) { if (item) { if ( (item.type != 'song' || Jukebox.player.className == 'player_maximized') && item.type != 'link') { Jukebox.titleItem = item; Jukebox.titlebar_info_title.innerHTML = item.properties.title; if (item.properties.caption && item.properties.caption != '') { Jukebox.titlebar_info_caption.innerHTML = item.properties.caption; } else { Jukebox.titlebar_info_caption.innerHTML = ''; } Jukebox.titlebar_back.onclick = function() {item.close()}; } } else if (Jukebox.titleItem) { Jukebox.syncTitle(Jukebox.titleItem); } } // JUKEBOXSONGCONTROL Jukebox.next = function(delay) { if (!delay) { delay = 0; } setTimeout(function(){Jukebox.play(Jukebox.getNextSong(Jukebox.song))},delay); }; Jukebox.previous = function() { Jukebox.play(Jukebox.getPreviousSong(Jukebox.song)); }; Jukebox.play = function(song) { // detect if Song object, if not generate Song object if ((!song instanceof Song) && !(song instanceof Item)) { song = new Song(song); } if (song) { this.song = song; } if (!this.song) { // check to see if current window is a "playlist" if (Jukebox.item.type == 'playlist' && Jukebox.item.children.length > 0) { if (Jukebox.isShuffled()) { var randomIndex = Math.floor(Math.random()*Jukebox.item.children.length); Jukebox.play(Jukebox.item.children[randomIndex]); Jukebox.maxPlayer(); } else { Jukebox.play(Jukebox.item.children[0]); Jukebox.maxPlayer(); } } else { Jukebox.showAlert(Jukebox.dialogue.noSong,1000); } return false; } // add the song to the queue this.addSong(this.song); // clear all but one song (for preroll) this.clearSongs(); Jukebox.interface_play_wrapper.className = 'interface_stop'; Jukebox.interface_play.onclick = function(){Jukebox.stop();return false;}; }; Jukebox.getIndex = function(song) { var playlist = song.parent; for (var i=0;i 0) { playlist.shuffleList.push(temp.splice(Math.floor(Math.random()*temp.length),1)[0]); } } Jukebox.getNextSong = function(song) { if (!this.song) { return false; } var playlist = song.parent; if (!playlist) { return song; } var index = this.getIndex(song); var nextIndex = (index+1) % playlist.children.length; if (Jukebox.shuffle.className == 'shuffle shuffle_on') { if (!playlist.shuffleList || playlist.shuffleList.length != playlist.children.length) { Jukebox.shufflePlaylist(playlist); } for(var i = 0 ; i < playlist.shuffleList.length ; i++) { if (playlist.shuffleList[i] == index) { nextIndex = playlist.shuffleList[(i+1)%playlist.children.length]; break; } } } return playlist.children[nextIndex]; } Jukebox.getPreviousSong = function(song) { if (!this.song) { return false; } var playlist = song.parent; if (!playlist) { return song; } var index = this.getIndex(song); var previousIndex = (index-1+playlist.children.length) % playlist.children.length;; if (Jukebox.shuffle.className == 'shuffle shuffle_on') { if (!playlist.shuffleList || playlist.shuffleList.length != playlist.children.length) { Jukebox.shufflePlaylist(playlist); } for(var i = 0 ; i < playlist.shuffleList.length ; i++) { if (playlist.shuffleList[i] == index) { previousIndex = playlist.shuffleList[(i-1+playlist.children.length)%playlist.children.length]; break; } } } return playlist.children[previousIndex]; } Jukebox.stop = function() { Jukebox.clearSongs(0); var thumb = document.createElement('img'); thumb.src = this.song.properties.thumbUrl thumb.style.width = '100%'; thumb.style.height = '100%'; Jukebox.player_video.appendChild(thumb); Jukebox.interface_play_wrapper.className = 'interface_play'; Jukebox.interface_play.onclick = function(){Jukebox.play();return false;}; Jukebox.endSongCheck(); }; // END JUKEBOX\\\\\ function Item(type, name, caption,properties) { if (type) { this.properties = {}; if (properties) { for(var k in properties) { this.properties[k] = properties[k]; } } this.properties.type = this.properties.type || type; this.focused = false; // display, or edit mode this.mode = 'display'; this.type = type; this.name = name; this.caption = caption; this.parent = null; this.children = new Array(); this.buttons = new Array(); this.contents = document.createElement('div'); this.contents.className = 'contents'; Jukebox.display.appendChild(this.contents); //create all elements, INCLUDING arrow (hide it by default) this.o = document.createElement('div') this.o.className = 'menu_item'; this.o.item_hover = document.createElement('a'); this.o.item_hover.className = 'item_hover'; this.o.item_hover.href = ''; this.o.item_hover.onclick = function(){return false}; this.o.appendChild(this.o.item_hover); this.o.item_wrapper = document.createElement('span'); this.o.item_wrapper.className='item_wrapper'; this.o.item_hover.appendChild(this.o.item_wrapper); // VARIABLE REQUIRED NEXT LINK this.o.item_title = document.createElement('span'); this.o.item_title.className = 'item_title'; this.o.item_wrapper.appendChild(this.o.item_title); // VARIABLE REQUIRED TITLE this.o.item_title_text = document.createElement('div'); this.o.item_title_text.className = 'item_title_text'; this.o.item_title_text.innerHTML = name; this.o.item_title.appendChild(this.o.item_title_text); // VARIABLE REQUIRED, CAPTION this.o.item_title_caption = document.createElement('div'); this.o.item_title_caption.className = 'item_title_caption'; this.o.item_title_caption.innerHTML = caption; this.o.item_title.appendChild(this.o.item_title_caption); this.o.item_next_wrapper = document.createElement('span'); this.o.item_next_wrapper.className = 'item_next_wrapper'; this.o.item_wrapper.appendChild(this.o.item_next_wrapper); // VARIABLE DATE FOR NEXT LINK REQUIRED this.o.item_next = document.createElement('div'); this.o.item_next.className = 'item_next'; this.o.item_next_wrapper.appendChild(this.o.item_next); this.o.item_menu = document.createElement('span'); this.o.item_menu.className = 'item_menu'; this.o.item_wrapper.appendChild(this.o.item_menu); //off standard should be _wrapper this.o.item_menu_delete_wrapper = document.createElement('div'); this.o.item_menu_delete_wrapper.className = 'item_menu_delete'; this.o.item_menu.appendChild(this.o.item_menu_delete_wrapper); // VARIABLE DATA FOR DELETE LINK this.o.item_menu_delete = document.createElement('a'); this.o.item_menu_delete.style.display = 'none'; this.o.item_menu_delete_wrapper.appendChild(this.o.item_menu_delete); // VARIABLE DATA FOR EDIT LINK this.o.item_menu_edit_wrapper = document.createElement('div'); this.o.item_menu_edit_wrapper.className = 'item_menu_edit'; this.o.item_menu.appendChild(this.o.item_menu_edit_wrapper); // VARIABLE DATA FOR EDIT LINK this.o.item_menu_edit = document.createElement('a'); this.o.item_menu_edit.style.display = 'none'; this.o.item_menu_edit.innerHTML = 'edit'; this.o.item_menu_edit_wrapper.appendChild(this.o.item_menu_edit); // VARIABLE DATA FOR STATS LINK this.o.item_menu_stats_wrapper = document.createElement('div'); this.o.item_menu_stats_wrapper.className = 'item_menu_stats'; this.o.item_menu.appendChild(this.o.item_menu_stats_wrapper); // VARIABLE DATA FOR STATS LINK this.o.item_menu_stats = document.createElement('a'); this.o.item_menu_stats.style.display = 'none'; this.o.item_menu_stats_wrapper.appendChild(this.o.item_menu_stats); // VARIABLE DATA FOR SHARE LINK this.o.item_menu_share_wrapper = document.createElement('div'); this.o.item_menu_share_wrapper.className = 'item_menu_share'; this.o.item_menu.appendChild(this.o.item_menu_share_wrapper); // VARIABLE DATA FOR SHARE LINK this.o.item_menu_share = document.createElement('a'); this.o.item_menu_share.style.display = 'none'; this.o.item_menu_share_wrapper.appendChild(this.o.item_menu_share); // VARIABLE DATA FOR embed LINK this.o.item_menu_embed_wrapper = document.createElement('div'); this.o.item_menu_embed_wrapper.className = 'item_menu_embed'; this.o.item_menu.appendChild(this.o.item_menu_embed_wrapper); // VARIABLE DATA FOR embed LINK this.o.item_menu_embed = document.createElement('a'); this.o.item_menu_embed.style.display = 'none'; this.o.item_menu_embed.innerHTML = 'embed'; this.o.item_menu_embed_wrapper.appendChild(this.o.item_menu_embed); // VARIABLE DATA FOR link LINK this.o.item_menu_link_wrapper = document.createElement('div'); this.o.item_menu_link_wrapper.className = 'item_menu_link'; this.o.item_menu.appendChild(this.o.item_menu_link_wrapper); // VARIABLE DATA FOR link LINK this.o.item_menu_link = document.createElement('a'); this.o.item_menu_link.style.display = 'none'; this.o.item_menu_link.innerHTML = 'link'; this.o.item_menu_link_wrapper.appendChild(this.o.item_menu_link); // VARIABLE DATA FOR SHARE LINK this.o.item_menu_yoink_wrapper = document.createElement('div'); this.o.item_menu_yoink_wrapper.className = 'item_menu_yoink'; this.o.item_menu.appendChild(this.o.item_menu_yoink_wrapper); // VARIABLE DATA FOR SHARE LINK this.o.item_menu_yoink = document.createElement('a'); this.o.item_menu_yoink.innerHTML = 'yoink!'; this.o.item_menu_yoink.style.display = 'none'; this.o.item_menu_yoink_wrapper.appendChild(this.o.item_menu_yoink); var hack = this; this.addButton('delete',function(){hack.del();return false;}); this.addButton('edit',function(){hack.edit();return false;}); this.addButton('open',function(){hack.open();return false;}); if (this.properties.ajax) { this.oldOpen = this.open; this.addButton('open',function(){hack.makeRequest();return false;}); } } } Item.prototype = { makeRequest: function(hidden){ var hack = this; if (!this.properties.ajax) { if (this.oldOpen) { this.oldOpen(); } else { this.open(); } } else { if (!hidden) { Jukebox.showAlert('loading'); } send({ url:hack.properties.ajax.url, query:hack.properties.ajax.query, success:function(response){hack.handleRequest(response,hidden);} }); } }, handleRequest: function(response,hidden) { if (!hidden) { Jukebox.closeAlert(); } eval('var data = '+response+';'); this.loadData(data); if (!hidden) { if (this.oldOpen) { this.oldOpen(); } else { this.open(); } } }, loadData: function(obj) { delete(this.properties.ajax); while (this.children.length > 0) { this.remove(this.children[0]); } for(var i = 0 ; i < obj.length ; i++) { this.add(getObj(obj[i],this.readonly)); } }, add: function(item) { item.parent = this; item.parent.contents.appendChild(item.o); this.children[this.children.length] = item; this.properties.items = this.properties.items || new Array(); // this.properties.items[this.properties.items.length] = item; //force arrow to be showing (should already be created) return true; }, remove: function(item) { this.contents.removeChild(item.o); for (var i=0;i'; Jukebox.embedmedia_content_input.value = embedCode; Jukebox.showPrompt(Jukebox.embedmedia_content,'embed code'); }, stats: function() { alert('collecting data, viewable stats coming soon...'); }, share: function() { if (this.properties.id !== undefined) { var hack=this; send({ url:'php/share.php', query:'type='+encodeURIComponent(hack.type)+'&method=share'+'&id='+hack.properties.id, success:hack.shareHandler }); } }, shareHandler: function(response) { var sharekey = response; Jukebox.sharemedia_content_share.value = 'http://www.yoinkd.com/share.php?key='+sharekey; Jukebox.sharemedia_content_embed.value = 'coming soon...'; Jukebox.showPrompt(Jukebox.sharemedia_content,'share media'); }, canContain: function(item) { return true; }, addButton: function(methodname,funcDef) { if (methodname == 'delete') { this.o.item_menu_delete.onclick = funcDef; this.o.item_menu_delete.style.display = ''; } else if (methodname == 'edit') { this.o.item_menu_edit.onclick = funcDef; this.o.item_menu_edit.style.display = ''; } else if (methodname == 'stats') { this.o.item_menu_stats.onclick = funcDef; this.o.item_menu_stats.style.display = ''; } else if (methodname == 'share') { this.o.item_menu_share.onclick = funcDef; this.o.item_menu_share.style.display = ''; } else if (methodname == 'link') { this.o.item_menu_link.onclick = funcDef; this.o.item_menu_link.style.display = ''; } else if (methodname == 'embed') { this.o.item_menu_embed.onclick = funcDef; this.o.item_menu_embed.style.display = ''; } else if (methodname == 'yoink') { this.o.item_menu_yoink.onclick = funcDef; this.o.item_menu_yoink.style.display = ''; } else if (methodname == 'open') { this.o.item_title.onclick = funcDef; this.o.item_next.onclick = funcDef; if (this.type == 'song' || this.type == 'link') { // should instead switch classname as opposed to background position this.o.item_next.style.backgroundPosition='-100 -100'; } else { this.o.item_next.style.backgroundPosition='0 0'; } } //add button to the right }, removeButton: function(methodname) { if (methodname == 'delete') { this.o.item_menu_delete.style.display = 'none'; } else if (methodname == 'edit') { this.o.item_menu_edit.style.display = 'none'; } }, setIcon: function(imgurl) { if (!this.o.item_thumb) { this.o.item_thumb = document.createElement('img'); this.o.item_thumb.className = 'item_thumb'; this.o.item_thumb.setAttribute('src',imgurl); this.o.item_title.insertBefore(this.o.item_thumb,this.o.item_title.firstChild); } else { this.o.item_thumb.setAttribute('src',imgurl); } }, generateChildren: function() { if (this.ungenerated) { for(var i = 0 ; i < this.ungenerated.length ; i++) { this.add(getObj(this.ungenerated[i],this.readonly)); } this.ungenerated = false; } }, open: function() { this.generateChildren(); Swoosh.slideLeft(this.contents, this.parent.contents); Jukebox.item = this; Jukebox.syncTitle(this); if (this.properties.type == 'playlist') { send({ url:'php/stats.php', query:'method=playlistview&id='+this.properties.id }); } }, close: function() { if (this.properties.type != 'root') { Swoosh.slideRight(this.parent.contents, this.contents); Jukebox.item = this.parent; Jukebox.syncTitle(this.parent); } }, edit: function() { if (this.mode == 'display') { this.mode = 'edit'; // add a check to ensure no double edits this.o.item_title_input = document.createElement('input'); this.o.item_title_input.className = 'item_title_text'; this.o.item_title_input.maxLength = 45; // weird hack to force inheritance of style this.o.item_title_input.setAttribute('id',''); this.o.item_title_input.setAttribute('type','text'); this.o.item_title_input.style.backgroundColor = 'transparent'; this.o.item_title_input.value = this.o.item_title_text.innerHTML; this.o.item_title.insertBefore(this.o.item_title_input,this.o.item_title_text); var hack = this; this.o.item_title_input.onkeydown = function(event){return hack.editKeyHandler(event,hack.o.item_title_input);}; this.o.item_title_input.onblur = function(){hack.onEditBlur(hack.o.item_title_input);}; this.o.item_title_input.onfocus = function(){hack.onEditFocus(hack.o.item_title_input);}; this.o.item_title_text.style.display = 'none'; } if (this.o.item_title_input) { var hack = this; setTimeout(function(){hack.o.item_title_input.select();},10); } }, editKeyHandler: function(event,obj) { event = event || window.event; switch (event.keyCode) { case 13: this.save(); break; case 9: if (obj == this.o.item_title_input && this.o.item_caption_input) { this.o.item_caption_input.select(); } else { this.save(); } break; default: return true; } return false; }, onEditBlur: function(obj) { this.focused = false; var hack = this; setTimeout(function(){hack.editBlurHandler(obj);},0); }, editBlurHandler: function(obj) { if (this.focused) { } else { this.save(); } this.focused = false; return false; }, onEditFocus: function(obj) { this.focused = true; }, save: function() { Jukebox.syncTitle(); this.mode = 'display'; var item = this; var changed = false; if (item.o.item_title_input) { item.properties.title = item.o.item_title_input.value; item.o.item_title.removeChild(item.o.item_title_input); item.o.item_title_input = null; changed = true; } item.o.item_title_text.innerHTML = item.properties.title; item.o.item_title_text.style.display = 'block'; if (item.o.item_caption_input) { item.properties.caption = item.o.item_caption_input.value; item.o.item_title.removeChild(item.o.item_caption_input); item.o.item_caption_input = null; changed = true; } item.o.item_title_caption.innerHTML = item.properties.caption; item.o.item_title_caption.style.display = 'block'; var type = this.type; var method; var qs = ''; if (this.properties.id !== undefined) { method = 'update'; qs += (qs.length != 0?'&':'') + 'id='+this.properties.id; } else { method = 'add'; qs += (qs.length != 0?'&':'') + 'index='; if (!this.parent) { return false; } var idx = -1; for(var i = 0 ; i < this.parent.children.length ; i++) { if (this.parent.children[i] == this) { break; } if (this.parent.children[i].properties.index !== undefined) { idx = this.parent.children[i].properties.index; } } this.properties.index = (this.parent.properties.ajax?-1:(idx!=-1?idx+1000:0)); qs += this.properties.index; if (type == 'song') { if (this.parent.properties.id === undefined) { return false; } qs += (qs.length != 0?'&':'') + 'id='+this.parent.properties.id; } } if (this.type == 'playlist') { qs += (qs.length != 0?'&':'') + 'data='+encodeURIComponent(this.properties.title); } else if (this.type == 'song') { // reset thumbnail this.setIcon("http://www.yoinkd.com/jukebox/php/image.php?type=embedurl&id="+encodeURIComponent(this.properties.embedUrl)+'&thumbUrl='+encodeURIComponent(this.properties.thumbUrl)); qs += (qs.length != 0?'&':'') + 'embedUrl='+encodeURIComponent(this.properties.embedUrl); qs += (qs.length != 0?'&':'') + 'thumbUrl='+encodeURIComponent(this.properties.thumbUrl); delete(this.code); var tempIdx; var tempId; if (this.properties.id !== undefined) { tempId = this.properties.id; delete(this.properties.id); } if (this.properties.index !== undefined) { tempIdx = this.properties.index; delete(this.properties.index); } var code = itemCodeGen(this.properties); if (tempIdx !== undefined) { this.properties.index = tempIdx; } if (tempId !== undefined) { this.properties.id = tempId; } qs += (qs.length != 0?'&':'') + 'data='+encodeURIComponent(code.substr(1,code.length-2)); } qs += (qs.length != 0?'&':'') + 'type='+encodeURIComponent(type)+'&method='+encodeURIComponent(method); var scopedThis = this; send({ url:'php/save.php', query:qs, success:function(response){if(method=='add'){scopedThis.properties.id=parseInt(response);}} }); return false; } }; Jukebox.genPlaylists = function() { var toGen = Jukebox.root.children[0].children.slice(2); var playlists = ''; for(var i = 0 ; i < toGen.length ; i++) { if (playlists.length > 0) { playlists += ','; } playlists += itemCodeGen(toGen[i]); } return playlists; } function Menu(properties) { if (properties) { //this.properties = properties; Item.call(this,'menu',properties.title,properties.caption,properties); //this.properties['type'] = this.properties['type'] || this.type; this.removeButton('delete'); this.removeButton('edit'); } } Menu.prototype = new Item(); function AjaxMenu(properties) { Menu.call(this,properties); this.properties['type'] = this.properties['type'] || this.type; if (this.properties.thumbUrl) { this.setIcon(this.properties.thumbUrl); } this.loaded = false; var hack = this; this['oldOpen'] = this.open; this.addButton('open',function(){hack.makeRequest();return false;}); } AjaxMenu.prototype = new Menu(); AjaxMenu.prototype.makeRequest = function() { if (this.loaded) { this.oldOpen(); return false; } else { Jukebox.showAlert('loading'); } var hack = this; send({ url:hack.properties.ajaxUrl, query:'method='+encodeURIComponent(hack.properties.ajaxMethod)+hack.properties.ajaxParameters, success:function(response){eval("var items = "+response+";");hack.handleRequest(items)} }); } AjaxMenu.prototype.handleRequest = function(data) { Jukebox.closeAlert(); var items=data; if (!this.loaded && this.properties.ajaxMethod == 'getSkins') { if (Jukebox.playerType == 'mediabox') { for (var i = 0 ; i < items.length ; i++) { items[i].type = 'link'; items[i].action = 'loadSkin'; this.add(getObj(items[i],true)); } this.loaded = true; } else { Jukebox.showAlert(Jukebox.dialogue.widgetSkins,10000); } } if (this.properties.ajaxMethod == 'getInbox') { this.loaded = true; for (var i = 0;i= 0 ; i--) { scopedThis.add(getObj(obj.list[i],true)); var j = 0; while (scopedThis.children.length > maxItems) { if (scopedThis.children[j] != Jukebox.song) { scopedThis.remove(scopedThis.children[j]); } else { j++; } } } scopedThis.contents.scrollTop = scopedThis.contents.scrollHeight; } liveFunc(items); this.loaded = true; setInterval(function(){ send({ url:'php/friendsLiveList.php', query:'time='+encodeURIComponent(time), success:function(response) { eval("var items = "+response+";"); liveFunc(items); } }); },5000); } else if (!this.loaded && this.properties.ajaxMethod == 'getFriends') { this.loaded = true; if (this.parent.properties.title == 'Main Menu') { var properties = {}; properties.type = 'link'; properties.title = Jukebox.titles.addFriends; properties.caption = Jukebox.captions.addFriends; properties.action = 'addFriends'; var addfriends = new Link(properties); this.add(addfriends); var properties = {}; properties.type = 'ajaxMenu'; properties.title = Jukebox.titles.friendsLiveList; properties.caption = Jukebox.captions.friendsLiveList; properties.ajaxUrl = 'php/friendsLiveList.php'; properties.ajaxMethod = 'friendsLiveList'; properties.ajaxParameters = ''; var friendslivelist = new AjaxMenu(properties); this.add(friendslivelist); } if (items) { for (var i = 0;i 1) { Jukebox.play(Jukebox.getNextSong(Jukebox.song)); } else { //unload player song (may want to abstract into jukebox function) } } oldRemove.call(this,item); this.properties.caption = this.children.length + ' videos'; this.o.item_title_caption.innerHTML = this.properties.caption; Jukebox.syncTitle(); }; var oldAdd = this['add']; this['add'] = function(item) { var properties = copyArray(item.properties); var song = new Song(properties); //var song = item; oldAdd.call(this,song); if (!this.properties.ajax) { this.properties.caption = this.children.length + ' videos'; } else { this.properties.caption = this.children.length + this.properties.length + ' videos'; } this.o.item_title_caption.innerHTML = this.properties.caption; return song; } } Playlist.prototype = new Item(); Playlist.prototype.canContain = function(item) { return item.type == 'song'; }; Playlist.prototype.yoink = function() { var hack = this; send({ url:'../jukebox/php/yoinkPlaylist.php', query:(this.properties.id == undefined?'pid='+encodeURIComponent(this.properties.pid):'id='+encodeURIComponent(this.properties.id)), success:function(response) { eval("var playlist = "+response+";"); if (playlist) { Jukebox.showAlert(hack.properties.title + Jukebox.dialogue.yoinkPlaylist,3000); playlist = getObj(playlist); Jukebox.root.children[0].add(playlist); } } }); } Playlist.prototype.move = function(fromIndex,toIndex) { }; Playlist.prototype.codeGen = function() { return itemCodeGen(this.properties); } Playlist.prototype.checkForOrderChanges = function() { var diffStart = -1; for(var i = 0 ; i < this.contents.childNodes.length ; i++) { if (diffStart == -1) { if (this.contents.childNodes[i] != this.children[i].o) { diffStart = i; if (this.contents.childNodes[i+1] == this.children[i].o) { //means that something was inserted for(var j = diffStart ; j < this.children.length ; j++) { if (this.children[j].o == this.contents.childNodes[i]) { alert(j + " moved up to "+i); var toMove = this.children.splice(j,1)[0]; this.children.splice(i,0,toMove); break; } } } else if (this.contents.childNodes[i] == this.children[i+1].o) { //something was moved down for(var j = diffStart ; j < this.contents.childNodes.length ; j++) { if (this.contents.childNodes[j] == this.children[i].o) { alert(i + " moved down to "+(j+1)); var toMove = this.children.splice(i,1)[0]; this.children.splice(j,0,toMove); break; } } } break; } } } if (diffStart != -1) { alert('there were changes'); var songs = new Array(); var indexes = new Array(); for(var i = 0 ; i < this.children.length ; i++) { var min; var max; if (i == this.children.length - 1) { if (i > 0) { if (this.children[i-1].properties.index >= this.children[i].properties.index) { this.children[i].properties.index = this.children[i-1].properties.index + 1000; songs.push(this.children[i].properties.id); indexes.push(this.children[i].properties.index); } } break; } if (i == 0) { min = -1; } else { min = this.children[i-1].properties.index; } max = this.children[i+1].properties.index; alert('s: '+this.children[i].properties.title+' min: '+min+' max: '+max+' current: '+this.children[i].properties.index); if (this.children[i].properties.index <= min) { var newIndex; if (max > min) { newIndex = Math.ceil((max+min)/2); } else if (i+2 < this.children.length && this.children[i+2].properties.index > min) { newIndex = Math.ceil((this.children[i+2].properties.index+min)/2); } else { newIndex = min + 1000; } this.children[i].properties.index = newIndex; songs.push(this.children[i].properties.id); indexes.push(this.children[i].properties.index); } } if (songs.length > 0) { send({ url:'../jukebox/php/save.php', query:'method=reorder&songs='+songs.join(';')+'&indexes='+indexes.join(';') }); } else { alert('wtf no changes?'); } } } function copyArray(what) { array_copy = new Array(); for (var i in what) { array_copy[i] = what[i]; } return array_copy; } function Song(properties) { this.parent = null; /*this.properties = {}; for(var k in properties) { this.properties[k] = properties[k]; }*/ var name = properties.title; var caption = properties.caption; Item.call(this,'song',name,caption,properties); //this.properties['type'] = this.properties['type'] || this.type; this.setIcon("http://www.yoinkd.com/jukebox/php/image.php?type=embedurl&id="+encodeURIComponent(this.properties.embedUrl)+'&thumbUrl='+encodeURIComponent(this.properties.thumbUrl)); //this.setIcon(this.properties.thumbUrl); var hack = this; this.addButton('link',function(){hack.link();return false;}); this.addButton('embed',function(){hack.embed();return false;}); var oldEdit = this['edit']; this['edit'] = function() { this.o.item_caption_input = document.createElement('input'); this.o.item_caption_input.className = 'item_title_caption'; this.o.item_caption_input.maxLength = 45; // weird hack to force inheritance of style this.o.item_caption_input.setAttribute('id',''); this.o.item_caption_input.setAttribute('type','text'); this.o.item_caption_input.style.backgroundColor = 'transparent'; this.o.item_caption_input.value = this.o.item_title_caption.innerHTML; this.o.item_title.insertBefore(this.o.item_caption_input,this.o.item_title_caption); var hack = this; this.o.item_caption_input.onkeydown = function(event){return hack.editKeyHandler(event,hack.o.item_caption_input);}; this.o.item_caption_input.onblur = function(){hack.onEditBlur(hack.o.item_caption_input);}; this.o.item_caption_input.onfocus = function(){hack.onEditFocus(hack.o.item_caption_input);}; this.o.item_title_caption.style.display = 'none'; oldEdit.call(this); } } Song.prototype = new Item(); Song.prototype.canContain = function(item) { return false; }; Song.prototype.open = function() { var playlist = this.parent; var index = this.properties.index; if (playlist) { Jukebox.play(this); Jukebox.maxPlayer(); } }; Song.prototype.close = function() { Jukebox.togglePlayer(); } Song.prototype.codeGen = function() { return itemCodeGen(this.properties); } function Link(properties) { // properties or an object? // maybe do properties['object'] = object; //this.properties = properties; // or check "typeof" // if (this.properties.type != 'link') { // this.item = properties; // } Item.call(this,'link',properties.title,properties.caption,properties); if (this.properties.thumbUrl) { this.setIcon(this.properties.thumbUrl); } //this.properties['type'] = this.properties['type'] || this.type; this.removeButton('delete'); this.removeButton('edit'); } Link.prototype = new Item(); Link.prototype.canContain = function(item) { return false; }; Link.prototype.open = function() { if (this.properties.action == 'addPlaylist') { var properties = new Object(); properties.title = Jukebox.titles.newPlaylist; var playlist = new Playlist(properties); this.parent.add(playlist); scrollToBottom(this.o.parentNode); playlist.edit(); } else if (this.properties.action == 'addRSSPlaylist') { Jukebox.showPrompt(Jukebox.addrssplaylist_content,Jukebox.prompts.addRSSPlaylist); } else if (this.properties.action == 'addFriends') { // WORKING MARKER Jukebox.showPrompt(Jukebox.addfriends_content,Jukebox.prompts.addFriends); //window.open('http://www.yoinkd.com/f8/add/','f8add','status=no,width=600px,height=400px'); return false; } else if (this.properties.action == 'addPlaylistToPrompt') { var properties = new Object(); properties.title = Jukebox.titles.untitledPlaylist; var playlist = new Playlist(properties); Jukebox.root.children[0].add(playlist); playlist.save(); var playlistLink = new Link(playlist.properties); playlistLink.properties.action = 'addToPlaylist'; playlistLink.item = playlist; this.o.parentNode.appendChild(playlistLink.o); scrollToBottom(this.o.parentNode.parentNode); } else if (this.properties.action == 'addToPlaylist') { var playlist = this.item; for (var i=0;i"+reducePhrase(30,title,'...')+" to"); } Jukebox.showPrompt = function(o,title) { Jukebox.minPlayer(); Jukebox.closePrompt(); Jukebox.closeAlert(); //this may change in accordance with design headers/footers while (Jukebox.prompt_content.childNodes.length > 0) { //Jukebox.prompt_content.removeChild(Jukebox.prompt_content.lastChild); Jukebox.removeElement(Jukebox.prompt_content.lastChild); } if (o) { Jukebox.prompt_content.appendChild(o); } if (title) { Jukebox.prompt_title.innerHTML = title; } Jukebox.prompt_wrapper.style.display = 'inline'; Jukebox.appear(Jukebox.prompt_wrapper); } Jukebox.closePrompt = function(callback) { Jukebox.vanish(Jukebox.prompt_wrapper,callback); } Jukebox.showAlert = function(text,delay) { Jukebox.minPlayer(); Jukebox.alert.innerHTML = text; Jukebox.appear(Jukebox.alert_wrapper); if (delay) { setTimeout(Jukebox.closeAlert,delay); } } Jukebox.closeAlert = function() { // CHECK ME Jukebox.vanish(Jukebox.alert_wrapper); } Jukebox.appear = function(o,callback) { Swoosh.appear(o,callback); } Jukebox.vanish = function(o,callback) { o.style.display = 'none'; Swoosh.vanish(o,callback); } Jukebox.copyText = function(inElement) { if (inElement.createTextRange) { var range = inElement.createTextRange(); if (range) range.execCommand('Copy'); } else { var flashcopier = 'flashcopier'; if(!document.getElementById(flashcopier)) { var divholder = document.createElement('div'); divholder.id = flashcopier; document.body.appendChild(divholder); } document.getElementById(flashcopier).innerHTML = ''; var divinfo = ''; document.getElementById(flashcopier).innerHTML = divinfo; } } Jukebox.removeElement = function(dom) { if (!Jukebox.dummyNode) { Jukebox.dummyNode = document.createElement('div'); } Jukebox.dummyNode.appendChild(dom); Jukebox.dummyNode.innerHTML = ''; } Jukebox.dialogue = {}; Jukebox.dialogue.noSong = 'No Current Song'; Jukebox.dialogue.confirmDelete = 'Are you sure you want to delete'; Jukebox.dialogue.widgetSkins = 'to use skins, check out the full player at http://www.yoinkd.com'; Jukebox.dialogue.duplicateVideo = 'Duplicate video in playlist'; Jukebox.dialogue.changeSkin = 'Hotswapping skin, please wait...'; Jukebox.dialogue.mismatchedPasswords = "Your new passwords don't match!"; Jukebox.dialogue.changedPassword = 'Password Changed'; Jukebox.dialogue.wrongPassword = 'Incorrect Password'; Jukebox.dialogue.unknownAction = 'Unknown Action'; Jukebox.dialogue.yoinkPlaylist = " has been yoink'd to your playlists"; Jukebox.prompts = {}; Jukebox.prompts.changePassword = 'Change Password'; Jukebox.prompts.changePic = 'Change Profile Pic'; Jukebox.prompts.addFriends = 'Find Friends'; Jukebox.prompts.addRSSPlaylist = 'Create RSS Playlist'; Jukebox.titles = {}; Jukebox.captions = {}; Jukebox.titles.addFriends = 'Find Friends'; Jukebox.captions.addFriends = "Via Facebook or e-mail."; Jukebox.titles.friendsLiveList = 'Friends Live List'; Jukebox.captions.friendsLiveList = 'Real-time yoinks from your friends.'; Jukebox.titles.newPlaylist = 'Enter Playlist Title'; Jukebox.titles.untitledPlaylist = 'Untitled Playlist'; // add RSS playlist Jukebox.addrssplaylist_content = document.createElement('div'); Jukebox.addrssplaylist_info = document.createElement('div'); Jukebox.addrssplaylist_info.className = 'addrssplaylist_info'; Jukebox.addrssplaylist_info.innerHTML = 'Enter the URL of an RSS Feed below, and click "RSS Feed -> Playlist" to convert it to a video playlist.
Learn more here and get sample RSS feeds »

'; Jukebox.addrssplaylist_content.appendChild(Jukebox.addrssplaylist_info); Jukebox.addrssplaylist_form = document.createElement('form'); Jukebox.addrssplaylist_form.className = 'addrssplaylist_form'; Jukebox.addrssplaylist_form.onsubmit = function(){Jukebox.addRSSPlaylist(Jukebox.addrssplaylist_input.value);return false}; Jukebox.addrssplaylist_content.appendChild(Jukebox.addrssplaylist_form); Jukebox.addrssplaylist_input = document.createElement('input'); Jukebox.addrssplaylist_input.setAttribute('id',''); Jukebox.addrssplaylist_input.setAttribute('type','text'); Jukebox.addrssplaylist_input.className = 'addrssplaylist_input'; Jukebox.addrssplaylist_form.appendChild(Jukebox.addrssplaylist_input); Jukebox.addrssplaylist_submit = document.createElement('input'); Jukebox.addrssplaylist_submit.className = 'addrssplaylist_submit'; Jukebox.addrssplaylist_submit.setAttribute('type','submit'); Jukebox.addrssplaylist_submit.value = 'RSS Feed -> Playlist'; Jukebox.addrssplaylist_form.appendChild(Jukebox.addrssplaylist_submit); Jukebox.addRSSPlaylist = function(url) { send({ url:'php/addRSSPlaylist.php', query:'url='+encodeURIComponent(url), success:Jukebox.addRSSPlaylistOnComplete }); } Jukebox.addRSSPlaylistOnComplete = function(response) { eval("var playlist = "+response+";"); if (playlist) { playlist = getObj(playlist); Jukebox.root.children[0].add(playlist); Jukebox.closePrompt(); } else { Jukebox.showAlert('invalid RSS feed url',2000); } } // add friends prompt Jukebox.addfriends_content = document.createElement('div'); // e-mail entry Jukebox.addFriendsByEmail = function() { var friends = Jukebox.addfriends_textarea.value; friends = friends.replace(/ /g,','); friends = friends.replace(/\r/g,','); friends = friends.replace(/\n/g,','); friends = friends.split(/,+/g); var friendsString = ''; for (var i=0;i 6) { var maxResults = 6; } else { var maxResults = this.gVideo.results.length; } var searchResults = new Playlist({'title':'Search Results'}); for (var i=0;i 0) { var result = GWeb.results[0]; // may want to iterate over all results in the future, if google is sucking // for (var i=0;i 1 && data[1].match('Lyrics')) { var artist = String.trim(data[0]); var title = String.trim(data[1].replace('Lyrics','')); if (artist == normalizedQuery) { info['type'] = 'artist'; info['artist'] = normalizedQuery; } else { info['artist'] = artist; info['title'] = title; } } else if (data.length == 1) { // alert(data[0]); info['type'] = 'artist'; } else { info['type'] = 'invalid'; } } // metrolyrics.com else if (sourceUrl.match('metrolyrics.com')) { var data = String.firstUpper(title.toLowerCase()); data = data.split('-',2); var normalizedQuery = String.trim(String.firstUpper(query.toLowerCase())); if (data.length > 1 && data[1].match('Lyrics!')) { var artist = String.trim(data[0].replace('Lyrics','')); var title = String.trim(data[1].replace('Lyrics!','')); if (artist == normalizedQuery) { info['type'] = 'artist'; info['artist'] = normalizedQuery; } else { info['artist'] = artist; info['title'] = title; } } else if (String.trim(data[0].replace('Lyrics','')) == normalizedQuery) { info['type'] = 'artist'; info['artist'] = normalizedQuery; } else { info['type'] = 'invalid'; } } //check legitimacy of result compared to query if (info['artist'] && info['title']) { var haystack = info['artist'] + ' ' + info['title']; haystack = haystack.replace(''',"'"); var needles = normalizedQuery.split(' '); var numerator = 0; var denominator = needles.length; // need to fix urldecoding problem apostrophes don't make it through for (var i=0;i]+)>)/ig,""); } function SearchGWeb(query) { } function playFromWeb() { // determine youtube video id var results = GWeb.results; if (results[resultID]) { var url = results[resultID].unescapedUrl; // parse video id var video_id = url.split('/'); video_id = video_id[video_id.length-1].split('='); video_id = video_id[video_id.length-1]; alert(video_id); getYoutubeData(video_id); } else { alert('no more results'); } } function getXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } var XmlRpc = getXmlHttpObject(); var XmlRpcs = new Array(); var XmlSending = false; function send(params) { if (!XmlSending) { try { XmlRpc.onreadystatechange = null; XmlRpc.abort(); }catch(e){}; XmlSending = true; XmlRpc.open("POST", params.url, true); XmlRpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); XmlRpc.onreadystatechange = function(){ try { if (XmlRpc.readyState == 4) { if (XmlRpc.status == 200) { try { XmlSending = false; if (params.success) { setTimeout(function(){params.success(XmlRpc.responseText);},0); } if (XmlRpcs.length > 0) { next = XmlRpcs.shift(); if (next) { setTimeout(function(){send(next)},0); } } }catch(e) {/*alert("An Error has occurred. Please send the following output to bugs@yoinkd.com:\n"+e);*/} } else { XmlSending = false; setTimeout(function(){send(params)},5000); } } }catch(e){ XmlSending = false; setTimeout(function(){send(params)},5000); } }; XmlRpc.send(params.query||''); } else { XmlRpcs.push(params); } } function Swoosh() { } Swoosh.appear = function(o,callback) { o.style.display = 'inline'; if (callback) { callback(); } return; var startHeight = ($(o).height()*.9); var startWidth = ($(o).width()*.9); var endHeight = $(o).height(); var endWidth = $(o).width(); // $(o).css('height',startHeight); // $(o).css('width',startWidth); o.style.display = 'none'; o.style.zIndex = '10000'; o.style.height = startHeight + 'px'; o.style.width = startWidth + 'px'; // if (callback) { $(o).animate({height: endHeight,width: endWidth,opacity: 'show'}, 125, 'easein',callback); // } // else { // $(o).animate({height: endHeight,width: endWidth,opacity: 'show'}, 150, 'easein'); // } } Swoosh.vanish = function(o,callback) { o.style.display = 'none'; if (callback) { callback(); } return; var endHeight = ($(o).height()*.9); var endWidth = ($(o).width()*.9); var startHeight = $(o).height(); var startWidth = $(o).width(); $(o).css('height',startHeight); $(o).css('width',startWidth); // if (callback) { $(o).animate({height: endHeight,width: endWidth,opacity: 'hide'}, 125, 'easein',callback); // } // else { // $(o).animate({height: endHeight,width: endWidth,opacity: 'hide'}, 150, 'easein'); // } } Swoosh.slideSpeed = 400; Swoosh.slideLeft = function(newMenu,oldMenu,callback) { newMenu.style.left = Jukebox.w; newMenu.style.top = '0px'; newMenu.style.display = 'inline'; // newMenu.style.overflow = 'hidden'; // oldMenu.style.overflow = 'hidden'; var oldCallback = callback; callback = function() { // newMenu.style.overflow = 'auto'; // oldMenu.style.overflow = 'auto'; if (oldCallback) { oldCallback(); } } oldMenu.style.zIndex = 1; newMenu.style.zIndex = 2; $(newMenu).animate({left:-1}, Swoosh.slideSpeed, 'easeout',callback); $(oldMenu).animate({left:-Jukebox.w}, Swoosh.slideSpeed, 'easeout',callback); } Swoosh.slideRight = function(newMenu,oldMenu,callback) { newMenu.style.left = -Jukebox.w; newMenu.style.top = '0px'; newMenu.style.display = 'inline'; // newMenu.style.overflow = 'hidden'; // oldMenu.style.overflow = 'hidden'; var oldCallback = callback; callback = function() { // newMenu.style.overflow = 'auto'; // oldMenu.style.overflow = 'auto'; if (oldCallback) { oldCallback(); } } oldMenu.style.zIndex = 1; newMenu.style.zIndex = 2; $(newMenu).animate({left:-1}, Swoosh.slideSpeed, 'easeout',callback); $(oldMenu).animate({left: Jukebox.w}, Swoosh.slideSpeed, 'easeout',callback); } function fishEye(itemArray,parent,maxWidth,itemWidth,proximity) { // elements of the form [dom,title,onclick] var outer = document.createElement('div'); outer.className = 'fisheye'; outer.style.bottom = '0px'; var container = document.createElement('div'); container.className = 'fisheyeContainer'; outer.appendChild(container); var dom,title,onclick; for(var i = 0 ; i < itemArray.length ; i++) { dom = itemArray[i][0]; title = itemArray[i][1]; onclick = itemArray[i][2]; var link = document.createElement('a'); link.setAttribute('href','#'); link.className = 'fisheyeItem'; link.onclick = onclick; container.appendChild(link); var span = document.createElement('span'); span.innerHTML = title; link.appendChild(span); link.appendChild(dom); } parent.appendChild(outer); setTimeout(function(){ $(outer).Fisheye( { maxWidth: maxWidth, items: 'a', itemsText: 'span', container: '.fisheyeContainer', itemWidth: itemWidth, proximity: proximity, alignment : 'left', valign: 'bottom', halign : 'center' } );},0); return outer; } fadeSteps = 50; fadeInt = 10; fadePause = 500; function getOpacity(obj) { if (obj.style.opacity) { return parseFloat(obj.style.opacity); } else { return 1; } } function setOpacity(obj,opacity) { obj.style.opacity = opacity; obj.style.filter = 'alpha(opacity='+(opacity * 100)+')'; obj.style.MozOpacity = opacity; } function fadeIn(obj,funcToRun) { var i; var fadeData = new Array(); var currentOpacity = getOpacity(obj); for(i = parseInt(currentOpacity * fadeSteps) ; i < fadeSteps ; i++) { fadeData.push([i/fadeSteps,i*fadeInt]); } fadeHelper(obj,fadeData,funcToRun,i*fadeInt); } function fadeOut(obj,funcToRun) { var i; var fadeData = new Array(); var currentOpacity = getOpacity(obj); for(i = parseInt(fadeSteps *currentOpacity) ; i >= 0 ; i--) { fadeData.push([i/fadeSteps,(fadeSteps - i)*fadeInt]); } fadeHelper(obj,fadeData,funcToRun,(fadeSteps - i)*fadeInt); } function fadeHelper(obj,fadeData,funcToRun,funcTime) { if (fadeData.length == 0) { if (funcToRun) { setTimeout(funcToRun,funcTime); } return; } var fadeEntry = fadeData.shift(); setTimeout(function(){setOpacity(obj,fadeEntry[0]);},fadeEntry[1]); fadeHelper(obj,fadeData,funcToRun,funcTime); } Jukebox.account = document.createElement('div'); Jukebox.account.className = 'account'; Jukebox.account.style.position = 'absolute'; Jukebox.appendChild(Jukebox.account); Jukebox.account_title = document.createElement('div'); Jukebox.account_title.className = 'account_title'; Jukebox.account.appendChild(Jukebox.account_title); Jukebox.account_title_loggedout = document.createElement('div'); Jukebox.account_title_loggedout.className = 'account_title_loggedout'; Jukebox.account_title.appendChild(Jukebox.account_title_loggedout); Jukebox.account_title_login = document.createElement('a'); Jukebox.account_title_login.href = ''; Jukebox.account_title_login.className = 'account_title_login'; Jukebox.account_title_login.innerHTML = 'login'; Jukebox.account_title_login.onclick = function(){Jukebox.showLogin();return false;}; Jukebox.account_title_loggedout.appendChild(Jukebox.account_title_login); Jukebox.account_title_fp = document.createElement('a'); Jukebox.account_title_fp.href = 'http://www.yoinkd.com/forgotpassword.php'; Jukebox.account_title_fp.target = '_blank'; Jukebox.account_title_fp.className = 'account_title_forgot_password'; Jukebox.account_title_fp.innerHTML = 'forgot password?'; Jukebox.account_title_loggedout.appendChild(Jukebox.account_title_fp); Jukebox.account_title_or = document.createElement('span'); Jukebox.account_title_or.innerHTML = ' or '; Jukebox.account_title_loggedout.appendChild(Jukebox.account_title_or); Jukebox.account_title_create = document.createElement('a'); Jukebox.account_title_create.href = ''; Jukebox.account_title_create.className = 'account_title_create'; Jukebox.account_title_create.innerHTML = 'create account'; Jukebox.account_title_create.onclick = function(){Jukebox.showCreate();return false;}; Jukebox.account_title_loggedout.appendChild(Jukebox.account_title_create); Jukebox.account_title_close = document.createElement('a'); Jukebox.account_title_close.href = ''; Jukebox.account_title_close.className = 'account_title_close'; Jukebox.account_title_close.innerHTML = 'close'; Jukebox.account_title_close.onclick = function(){Jukebox.closeLogin();return false;}; Jukebox.account_title_loggedout.appendChild(Jukebox.account_title_close); Jukebox.account_title_loggedin = document.createElement('div'); Jukebox.account_title_loggedin.className = 'account_title_loggedin'; Jukebox.account_title_loggedin.style.display = 'none'; Jukebox.account_title.appendChild(Jukebox.account_title_loggedin); Jukebox.account_title_status = document.createElement('a'); Jukebox.account_title_status.href = ''; Jukebox.account_title_status.className = 'account_title_status'; Jukebox.account_title_status.onclick = function(){return false;}; Jukebox.account_title_loggedin.appendChild(Jukebox.account_title_status); Jukebox.account_title_logout = document.createElement('a'); Jukebox.account_title_logout.href = ''; Jukebox.account_title_logout.className = 'account_title_logout'; Jukebox.account_title_logout.innerHTML = 'logout'; Jukebox.account_title_logout.onclick = function(){Jukebox.logout();return false;}; Jukebox.account_title_loggedin.appendChild(Jukebox.account_title_logout); Jukebox.account_content = document.createElement('div'); Jukebox.account_content.className = 'account_content'; Jukebox.account.appendChild(Jukebox.account_content); Jukebox.account_content_form = document.createElement('form'); Jukebox.account_content_form.className = 'account_content_form'; Jukebox.account_content_form.onsubmit = function(){Jukebox.submitAccount();return false}; Jukebox.account_content.appendChild(Jukebox.account_content_form); Jukebox.account_content_emailimage = document.createElement('div'); Jukebox.account_content_emailimage.className = 'account_content_emailimage'; Jukebox.account_content_form.appendChild(Jukebox.account_content_emailimage); Jukebox.account_content_email = document.createElement('input'); Jukebox.account_content_email.setAttribute('type','input'); Jukebox.account_content_email.setAttribute('name','email'); Jukebox.account_content_email.tabIndex = 1; Jukebox.account_content_email.className = 'account_content_email'; Jukebox.account_content_form.appendChild(Jukebox.account_content_email); Jukebox.account_content_passwordimage = document.createElement('div'); Jukebox.account_content_passwordimage.className = 'account_content_passwordimage'; Jukebox.account_content_form.appendChild(Jukebox.account_content_passwordimage); Jukebox.account_content_password = document.createElement('input'); Jukebox.account_content_password.setAttribute('type','password'); Jukebox.account_content_password.setAttribute('name','password'); Jukebox.account_content_password.tabIndex = 2; Jukebox.account_content_password.className = 'account_content_password'; Jukebox.account_content_password.value = ''; Jukebox.account_content_form.appendChild(Jukebox.account_content_password); Jukebox.account_content_confirmpasswordimage = document.createElement('div'); Jukebox.account_content_confirmpasswordimage.className = 'account_content_confirmpasswordimage'; Jukebox.account_content_form.appendChild(Jukebox.account_content_confirmpasswordimage); Jukebox.account_content_confirmpassword = document.createElement('input'); Jukebox.account_content_confirmpassword.setAttribute('type','password'); Jukebox.account_content_confirmpassword.setAttribute('name','confirmpassword'); Jukebox.account_content_confirmpassword.tabIndex = 3; Jukebox.account_content_confirmpassword.className = 'account_content_confirmpassword'; Jukebox.account_content_confirmpassword.value = ''; Jukebox.account_content_form.appendChild(Jukebox.account_content_confirmpassword); Jukebox.account_content_submit = document.createElement('input'); Jukebox.account_content_submit.setAttribute('type','submit'); Jukebox.account_content_submit.className = 'account_content_form_loginsubmit'; Jukebox.account_content_submit.value = ''; Jukebox.account_content_form.appendChild(Jukebox.account_content_submit); $(function(){ Jukebox.account_h = 160; Jukebox.account_title_h = $(Jukebox.account_title).height(); Jukebox.account_title_h = 20; Jukebox.account_content_h = (Jukebox.account_h-Jukebox.account_title_h); Jukebox.account.style.bottom = '-' + (Jukebox.account_h-Jukebox.account_title_h) + 'px'; Jukebox.account.style.height = Jukebox.account_h + 'px'; Jukebox.account_title_close.style.display = 'none'; }) Jukebox.showLogin = function() { Jukebox.account_title_close.style.display = 'inline'; Jukebox.account_content_confirmpasswordimage.style.display = 'none'; Jukebox.account_content_confirmpassword.style.display = 'none'; Jukebox.account_content_submit.className = 'account_content_form_loginsubmit'; Jukebox.account_content_submit.value = 'login'; $(Jukebox.account).animate({bottom:-(Jukebox.account_content_h*.25)}, 300, 'expoout'); setTimeout(function(){Jukebox.account_content_email.select();},100); Jukebox.accountMode = 'login'; Jukebox.account_title_fp.style.display = 'none'; } Jukebox.showCreate = function() { Jukebox.account_title_close.style.display = 'inline'; Jukebox.account_content_confirmpasswordimage.style.display = 'inline'; Jukebox.account_content_confirmpassword.style.display = 'inline'; Jukebox.account_content_submit.className = 'account_content_form_createsubmit'; Jukebox.account_content_submit.value = 'create account'; $(Jukebox.account).animate({bottom:0}, 300, 'expoout'); setTimeout(function(){Jukebox.account_content_email.select();},100); Jukebox.accountMode = 'create'; Jukebox.account_title_fp.style.display = 'none'; } Jukebox.closeLogin = function() { Jukebox.account_title_close.style.display = 'none'; Jukebox.account_content_password.value = ''; Jukebox.account_content_confirmpassword.value = ''; $(Jukebox.account).animate({bottom:-(Jukebox.account_h-Jukebox.account_title_h)}, 300, 'expoout'); Jukebox.accountMode = false; Jukebox.account_title_fp.style.display = ''; } Jukebox.closeCreate = function() { Jukebox.account_title_close.style.display = 'none'; Jukebox.account_content_password.value = ''; Jukebox.account_content_confirmpassword.value = ''; Jukebox.account_content_confirmpasswordimage.style.display = 'none'; Jukebox.account_content_confirmpassword.style.display = 'none'; $(Jukebox.account).animate({bottom:-(Jukebox.account_h-Jukebox.account_title_h)}, 300, 'expoout'); Jukebox.accountMode = false; Jukebox.account_title_fp.style.display = ''; } Jukebox.checkPassword = function(password) { if (password.length < 5) { Jukebox.showAlert("your password should be longer than 4 characters",5000); return false; } return true; } Jukebox.submitAccount = function() { Jukebox.showAlert('logging in...'); var email = Jukebox.account_content_email.value; Jukebox.user = {}; Jukebox.user.email = email; var password = Jukebox.account_content_password.value; if (!email.match(/\./) || !email.match(/\@/) || email.replace(' ','') == '') { Jukebox.showAlert("that's not an email address",5000); Jukebox.account_content_email.select(); return false; } if (Jukebox.accountMode == 'create') { var confirmpassword = Jukebox.account_content_confirmpassword.value; if (password != confirmpassword) { Jukebox.showAlert("your passwords don't match",5000); Jukebox.account_content_password.value = ''; Jukebox.account_content_confirmpassword.value = ''; Jukebox.account_content_password.select(); return false; } if (!Jukebox.checkPassword(password)) { Jukebox.account_content_confirmpassword.value = ''; Jukebox.account_content_password.select(); return false; } } Jukebox.account_content_password.value = ''; Jukebox.account_content_confirmpassword.value = ''; send({ url:'php/account.php', query:'method='+encodeURIComponent(Jukebox.accountMode)+'&email='+encodeURIComponent(email)+'&password='+encodeURIComponent(password), success:Jukebox.login }); } Jukebox.login = function (response) { Jukebox.closeAlert(); if (Jukebox.accountMode == 'login') { var loginData; eval("loginData = "+response+";"); if (loginData) { // skin loading seems to be duplicated with loadSkin in core.php if (Jukebox.playerType == 'mediabox') { document.getElementById('skin').href = loginData.cssPath; } var playlists = loginData.playlists; var toRemove = Jukebox.root.children[0].children.slice(2); for(var i = 0 ; i < toRemove.length ; i++) { toRemove[i].parent.remove(toRemove[i]); } for(var i = 0 ; i < playlists.length ; i++) { Jukebox.root.children[0].add(getObj(playlists[i])); } Jukebox.user.loggedIn = true; Jukebox.updateStatus(); Jukebox.closeLogin(); } else { Jukebox.showAlert('incorrect username or password',5000); Jukebox.account_content_password.select(); } } else if (Jukebox.accountMode == 'create') { var response; eval("response = "+response+";"); if (response) { Jukebox.user.loggedIn = true; Jukebox.updateStatus(); Jukebox.closeCreate(); } else { Jukebox.showAlert('email already in use, forgot your password?',5000); } } } Jukebox.logout = function() { Jukebox.showAlert('logging out'); var logoutUrl = 'index.php?logout=true'; if (Jukebox.playerType != 'mediabox') { logoutUrl = logoutUrl + '&type=' + Jukebox.playerType; } window.location.href = logoutUrl; } $(function(){ // Jukebox.dimmer = document.createElement('div'); // Jukebox.dimmer.className = 'dimmer'; // Jukebox.dimmer.onclick = function(){Jukebox.hideDimmer()}; // Jukebox.appendChild(Jukebox.dimmer); // //Jukebox.dimmer_message = document.createElement('div'); //Jukebox.dimmer_message.className = 'dimmer_message'; //Jukebox.dimmer_message.onclick = function(){Jukebox.hideDimmer()}; //Jukebox.dimmer_message.innerHTML = "You are not logged in.

Please login or create an account below,

or click screen for demo."; //Jukebox.appendChild(Jukebox.dimmer_message); }) Jukebox.hideDimmer = function() { Jukebox.dimmer.style.display = 'none'; Jukebox.dimmer_message.style.display = 'none'; } Jukebox.showDimmer = function() { Jukebox.dimmer.style.display = 'inline'; Jukebox.dimmer_message.style.display = 'inline'; } Jukebox.updateStatus = function() { if (Jukebox.user.loggedIn) { // COMBINE THESE ALL INTO A SINGLE DIV Jukebox.account_title_loggedin.style.display = 'inline'; Jukebox.account_title_loggedout.style.display = 'none'; //Jukebox.hideDimmer(); // COMBINE THIS INTO A SINGLE DIV Jukebox.account_title_status.innerHTML = "Logged in as "; } else { //Jukebox.showDimmer(); //Jukebox.dimmer.style.display = 'inline'; } }