/////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// // /////// // Wimpy JS /////// // Version 2.0 /////// // /////// // by Mike Gieson /////// // /////// // Available at http://www.wimpyplayer.com /////// // ©2002-2006 plaino /////// // /////// /////////////////////////////////////////////////////////////// // // This product includes software developed by Macromedia, Inc. // // Macromedia(r) Flash(r) JavaScript Integration Kit // Portions noted as part of the JavaScript Integration Kit // are Copyright (c) 2005 Macromedia, inc. All rights reserved. // http://www.macromedia.com/go/flashjavascript/ // // Macromedia(r) Flash(r) JavaScript Integration Kit Created by: // // Christian Cantrell // http://weblogs.macromedia.com/cantrell/ // mailto:cantrell@macromedia.com // // Mike Chambers // http://weblogs.macromedia.com/mesh/ // mailto:mesh@macromedia.com // // Macromedia // ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// //////////// //////////// //////////// OPTIONS //////////// //////////// //////////// ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// // // Refer to the "wimpyJS_readme.html" file for details. // wimpySwf = "getid3/wimpy.swf"; theWidth = 354; theHeight = 57; theBkgdColor = "FFFFFF"; // // You can use an external wimpyConfigs.xml file to set the remainder of the options wimpyConfigFile = ""; // ... or set them here: // wimpySkin = "getid3/skin_homepage.xml"; trackPlays = ""; voteScript = ""; defaultImage = ""; startPlayingOnload = "no"; shuffleOnLoad = ""; randomOnLoad = ""; displayDownloadButton = ""; startOnTrack = ""; autoAdvance = ""; popUpHelp = ""; scrollInfoDisplay = ""; infoDisplayTime = "yes"; bufferAudio = "5"; theVolume = "50"; limitPlaytime = ""; startupLogo = "getid3/wimpy_stlogo.jpg"; // getMyid3info = "yes"; // forceXMLplaylist="yes"; js_wimpy_returnOnComplete = "getTrackDetails"; function getTrackDetails(myReturnArg){ if(typeof(myReturnArg) == "object"){ // Put the returned array into a new variable so we can modify it var returnedArray = myReturnArg; // Remove the first element of the array and put it into a new // variable so we can determine which action Wimpyjust performed. var myAction = returnedArray.shift(); if(myAction == "wimpy_getTrackInfo"){ writeTrackInfo(returnedArray); } else if (myAction == "wimpy_returnPlaylistItem"){ writeTrackInfo(returnedArray); } else if (myAction == "wimpy_trackStarted"){ writeTrackInfo(returnedArray); } else if (myAction == "wimpy_trackDone"){ cleanTrackInfo(); } } else { /* if(myReturnArg == "wimpy_loadAndPlay"){ wimpy_getTrackInfo(); } */ } } function writeMemberImage(theDataArray) { var memberImage = ""; if (theDataArray.length == 7) { memberImage += '
'; } return memberImage; } function writeTrackDetails(theDataArray){ var trackDetails = ""; if (theDataArray.length == 7) { trackDetails = 'Now playing - "' + PHP.htmlspecialchars(theDataArray[4]) + '" by ' + PHP.htmlspecialchars(theDataArray[3]) + '.
'; trackDetails += 'Add this song to my Song Tank.
'; trackDetails += 'Send ' + PHP.htmlspecialchars(theDataArray[3]) + ' a message.
'; } return trackDetails; } function writeTrackInfo(theDataArray) { trackDetailsObj = fetch_object('trackDetails'); trackDetailsObj.innerHTML = writeTrackDetails(theDataArray); memberImageObj = fetch_object('memberImage'); memberImageObj.innerHTML = writeMemberImage(theDataArray); } function cleanTrackInfo() { trackDetailsObj = fetch_object('trackDetails'); trackDetailsObj.innerHTML = ''; memberImageObj = fetch_object('memberImage'); memberImageObj.innerHTML = ''; } ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// //////////// //////////// //////////// Do not edit below here //////////// //////////// //////////// ///////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////// randNum = (Math.round((Math.random()*1000000)+1)); function makeWimpyPlayer(thePlaylist){ thePlaylist = thePlaylist || ""; var newlineChar = "\n"; var bkgdColor; var tptBkgd_param; var writePlaylist; var altString; var queryString; var js2wimpy_param; var js2wimpy_embed; var flashCode = ''; var flashVersion = "6,0,47,0"; var myConfigs = "wimpySkin,trackPlays,voteScript,defaultImage,startPlayingOnload,shuffleOnLoad,randomOnLoad,displayDownloadButton,startOnTrack,autoAdvance,popUpHelp,scrollInfoDisplay,infoDisplayTime,bufferAudio,theVolume,js_wimpy_returnOnComplete,limitPlaytime,startupLogo"; var AmyConfigs = myConfigs.split(","); var AprintConfigs = Array(); for(i=0;i 4){ altString = '&wimpyConfigs='+wimpyConfigFile; } else { altString = "&"+myConfigs; } // myuid = new Date().getTime(); wimpyProxy = new FlashProxy(myuid, wimpySwf); js2wimpy_param = ''+newlineChar; js2wimpy_embed = 'flashvars="lcId='+myuid+'" '; // queryString = wimpySwf +'?x='+randNum+altString+writePlaylist; // flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += ''+newlineChar; flashCode += tptBkgd_param; flashCode += js2wimpy_param; flashCode += ''; document.write(flashCode); // Uncomment to trouble shoot the HTML code. //document.write('
'); } function getExtension(theFilename){ return unescape(theFilename).split("/").pop().split(".").pop().split("?").shift().toLowerCase(); // return unescape(theFilename).split("/").pop().split(".").pop().toLowerCase(); } function wimpy_play(){ wimpyProxy.call('js_wimpy_play'); } function wimpy_stop(){ wimpyProxy.call('js_wimpy_stop'); } function wimpy_pause(){ wimpyProxy.call('js_wimpy_pause'); } function wimpy_next(){ wimpyProxy.call('js_wimpy_next'); } function wimpy_prev(){ wimpyProxy.call('js_wimpy_prev'); } function wimpy_gotoTrack(trackNumber){ wimpyProxy.call('js_wimpy_gotoTrack', trackNumber); } function wimpy_clearPlaylist(){ wimpyProxy.call('js_wimpy_clearPlaylist'); } function wimpy_appendPlaylist(trackOrPlaylist, theFile, theArtist, theTitle, theHyperlink, theGraphic){ wimpyProxy.call('js_wimpy_appendPlaylist', trackOrPlaylist, theFile, theArtist, theTitle, theHyperlink, theGraphic); } function wimpy_loadAndPlay(theFile, theArtist, theTitle, theHyperlink, theGraphic){ wimpyProxy.call('js_wimpy_loadAndPlay', theFile, theArtist, theTitle, theHyperlink, theGraphic); } function wimpy_appendMultipleTracks(theFileList, theGroupTitle, theHyperlink, theGraphic){ wimpyProxy.call('js_wimpy_appendMultipleTracks', theFileList, theGroupTitle, theHyperlink, theGraphic); } // These functions return an array, and require you to use js_wimpy_returnOnComplete. function wimpy_getTrackInfo(){ wimpyProxy.call('js_wimpy_getTrackInfo'); } function wimpy_returnPlaylistItem(trackNumber){ wimpyProxy.call('js_wimpy_returnPlaylistItem', trackNumber); } ///////////////////////////////////////////////////////// ///////////////////////////////////////////////////////// /* The following code is part of the Flash / JavaScript Integration Kit: http://www.macromedia.com/go/flashjavascript/ */ function Exception(name, message){ if (name) this.name = name; if (message) this.message = message; } Exception.prototype.setName = function(name){ this.name = name; } Exception.prototype.getName = function(){ return this.name; } Exception.prototype.setMessage = function(msg){ this.message = msg; } Exception.prototype.getMessage = function(){ return this.message; } function FlashProxy(uid, proxySwfName){ this.uid = uid; this.proxySwfName = proxySwfName; this.flashSerializer = new FlashSerializer(false); } FlashProxy.prototype.call = function(){ if (arguments.length == 0) { throw new Exception("Flash Proxy Exception", "The first argument should be the function name followed by any number of additional arguments."); } var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]); if (arguments.length > 1) { var justArgs = new Array(); for (var i = 1; i < arguments.length; ++i) { justArgs.push(arguments[i]); } qs += ('&' + this.flashSerializer.serialize(justArgs)); } var divName = '_flash_proxy_' + this.uid; if(!document.getElementById(divName)) { var newTarget = document.createElement("div"); newTarget.id = divName; document.body.appendChild(newTarget); } var target = document.getElementById(divName); var ft = new FlashTag(this.proxySwfName, 1, 1); ft.setVersion('6,0,65,0'); ft.setFlashvars(qs); target.innerHTML = ft.toString(); //document.getElementById("textarea").value = divName; } FlashProxy.callJS = function(){ var functionToCall = eval(arguments[0]); var argArray = new Array(); for (var i = 1; i < arguments.length; ++i) { argArray.push(arguments[i]); } functionToCall.apply(functionToCall, argArray); } function FlashSerializer(useCdata){ this.useCdata = useCdata; } FlashSerializer.prototype.serialize = function(args){ var qs = new String(); for (var i = 0; i < args.length; ++i) { switch(typeof(args[i])) { case 'undefined': qs += 't'+(i)+'=undf'; break; case 'string': qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]); break; case 'number': qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]); break; case 'boolean': qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]); break; case 'object': if (args[i] == null) { qs += 't'+(i)+'=null'; } else if (args[i] instanceof Date) { qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime()); } else // array or object { try { qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i])); } catch (exception) { throw new Exception("FlashSerializationException", "The following error occurred during complex object serialization: " + exception.getMessage()); } } break; default: throw new Exception("FlashSerializationException", "You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined."); } if (i != (args.length - 1)) { qs += '&'; } } return qs; } FlashSerializer.prototype._serializeXML = function(obj){ var doc = new Object(); doc.xml = ''; this._serializeNode(obj, doc, null); doc.xml += ''; return doc.xml; } FlashSerializer.prototype._serializeNode = function(obj, doc, name){ switch(typeof(obj)) { case 'undefined': doc.xml += ''; break; case 'string': doc.xml += ''+this._escapeXml(obj)+''; break; case 'number': doc.xml += ''+obj+''; break; case 'boolean': doc.xml += ''; break; case 'object': if (obj == null) { doc.xml += ''; } else if (obj instanceof Date) { doc.xml += ''+obj.getTime()+''; } else if (obj instanceof Array) { doc.xml += ''; for (var i = 0; i < obj.length; ++i) { this._serializeNode(obj[i], doc, null); } doc.xml += ''; } else { doc.xml += ''; for (var n in obj) { if (typeof(obj[n]) == 'function') continue; this._serializeNode(obj[n], doc, n); } doc.xml += ''; } break; default: throw new Exception("FlashSerializationException", "You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined"); break; } } FlashSerializer.prototype._addName= function(name){ if (name != null) { return ' name="'+name+'"'; } return ''; } FlashSerializer.prototype._escapeXml = function(str){ if (this.useCdata) return ''; else return str.replace(/&/g,'&').replace(/'; flashTag += ''; flashTag += ''; flashTag += ''; if (this.flashVars != null) { flashTag += ''; } flashTag += ''; } else { flashTag += '