home *** CD-ROM | disk | FTP | other *** search
Wrap
// --------------------------------------------------------------------------------- // UTILS function includeJS(file) // executes external JS immediately after script tag exit(relative to HTML location) { document.write('<script src="'+file+'"></script>'); } function innerXML(node) // returns childNodes of XML serialised to a string { var out=''; node = node.firstChild; if (node) do { out+=node.xml+'\n'; } while (node=node.nextSibling); return out; } function escape2(source) // url-friendly escaping { var i,c; var result=''; for (i=0;i<source.length;i++) {c=source.charAt(i); switch (true) { case (c==' '): result+='+'; break; case ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='.' || c=='/' || c=='\\'): result+=c; break; default: result+='%'+(Number(source.charCodeAt(i)).toString(16)).toUpperCase(); } } return result; } // --------------------------------------------------------------------------------- // HELPER SUPPORT/ORDER LINKS GENERATORS function returnLink(action, productID) // returns link for the product/action specified { var linkContent=''; linkContent+='<a href="http://flredirect.e-officedirect.com/flredirect.exe?forumname=flstudio'; linkContent+='&action='+action; linkContent+='&username='+escape2(userData[0]); // linkContent+='&applicationID='+escape2(params[2])+'; // appID not needed if (action=='buy') linkContent+='&P_code='+productID; // product code only in buy/upgrade links linkContent+='" target="_blank" class="link-common">'; return linkContent; } function returnSupportLink() // support request link (reg problems) { return returnLink('supportrequest',0); } function returnRegisterLink() // code request/register link { return returnLink('register',0); } function returnBuyLink(productID) // product buy/upgrade { return returnLink('buy',productID); } // --------------------------------------------------------------------------------- // INTERFACE // handles container interface - tabs, toolbar & canvas container = { tabs:[], openTabPanel: function () { document.write('<div class="tabPanel">'); }, closeTabPanel: function () { document.write('<div class="decRight"> </div></div>'); }, closeContainer: function () { document.write('<div style="background:url(img_fd_panels/tabPanel_bottom_bg.gif); height:32px; position:relative"><div style="position:absolute;left:0;"><img src="img_fd_panels/tabPanel_bottom_left.gif"></div><div style="text-align:right;"><img src="img_fd_panels/tabPanel_bottom_right.gif"></div></div>'); }, addTab: function (id,caption) { document.write('<div id="'+id+'_tab" myID="'+id+'" class="tabOff"><div id="'+id+'_inner" class="tabInner'+(container.tabs.length==0?"First":"")+'"><span>'+caption+'</span></div></div>'); var t = document.getElementById(id+'_tab'); container.tabs[container.tabs.length] = t; t.onclick = container.switchToMe; }, switchToMe: function() { container.switchToTab(this.myID); }, switchToTab: function (id) { for (var i=0; i<container.tabs.length; i++) { if (container.tabs[i].myID==id) { container.tabs[i].className = "tabOn"; document.getElementById(container.tabs[i].myID+'_host').style.display="block"; } else { container.tabs[i].className = "tabOff"; document.getElementById(container.tabs[i].myID+'_host').style.display="none"; } } }, openCanvas: function (id,toolbar) { var cont = ''; cont += '<div id="'+id+'_host" class="showAll" style="display:none">'; if (!toolbar) { cont += '<div class="toolbar" onclick="onkeydown();" onkeydown="container.switchRadio(this.myID)" myID="'+id+'">'; cont += '<label for="'+id+'_radio1"><input checked="checked" type="radio" id="'+id+'_radio1" name="'+id+'_radiogroup" value="radio" />Show all </label>'; cont += '<label for="'+id+'_radio2"><input type="radio" id="'+id+'_radio2" name="'+id+'_radiogroup" value="radio" />Show products I own </label>'; cont += '<label for="'+id+'_radio3"><input type="radio" id="'+id+'_radio3" name="'+id+'_radiogroup" value="radio" />Show products I do not own </label>'; cont += '</div>'; } else cont += '<div class="toolbar">'+toolbar+'</div>'; cont += '<div class="hostCore"><div class="hostCore2">'; document.write(cont); // ... content here }, closeCanvas: function () { document.write('</div></div></div>'); }, switchRadio: function (id) { var rad1 = document.getElementById(id+'_radio1').checked; var rad2 = document.getElementById(id+'_radio2').checked; var rad3 = document.getElementById(id+'_radio3').checked; switch (true) { case rad1: document.getElementById(id+'_host').className = "showAll"; break; case rad2: document.getElementById(id+'_host').className = "showOwned"; break; case rad3: document.getElementById(id+'_host').className = "showNotOwned"; break; } } } // the dynamically expandable product panels panels = { id:0, insertPanel: function(title,content,onByDefault,owned) // owned = "na" (state not available) will now show own/not-own notice { var id = panels.id++; id = 'sp'+id; var cont = ''; cont += '<div class="'+(owned?'switchOwned':'switchNotOwned')+'"><div class="switch'+(onByDefault?"On":"Off")+'" id="'+id+'_switch">'; cont += '<div class="switchHeader" ondblclick="onclick()" onselectstart="return false;" onclick="panels.switchPanel(\''+id+'\')">'; cont += '<table class="thin"><tr><td class="icon"><img id="'+id+'_icon" src="img_fd_panels/switchPanel_top_'+(!onByDefault?"show":"hide")+'icon.gif"></td><td> '+title+(owned!='na'?(owned?" <div class=\"ownText\">(you own this product)</div>":" <div class=\"notOwnText\">(you do not own this product)</div>"):'')+'</td><td class="cap"><img src="img_fd_panels/switchPanel_top_right.gif"></td></tr></table></div>'; cont += '<div id="'+id+'_core" class="core">'+content+'</div>'; cont += '<div class="switchFooter"><table class="thin"><tr><td class="icon"><img src="img_fd_panels/switchPanel_bottom_left.gif"></td><td class="cap"><img src="img_fd_panels/switchPanel_bottom_right.gif"></td></tr></table></div></div></div>'; document.write(cont); }, switchPanel: function (id) { var cN = document.getElementById(id+'_switch').className = ((document.getElementById(id+'_switch').className == 'switchOn')?'switchOff':'switchOn'); document.getElementById(id+'_icon').src = (cN!="switchOn")?"img_fd_panels/switchPanel_top_showicon.gif":"img_fd_panels/switchPanel_top_hideicon.gif"; }, insertProductPanel: function(i,owned) // makes a plugin/add-on dynamic table (based on the data.products index) { var contents=''; if (data.products[i].prodType=='smp') { contents+='<img src="img_products/sample_cds/'+data.products[i].code+'.jpg" align="left" style="margin:0 8px 8px 0">'; } else { contents+='<img src="img_products/Register '+data.products[i].name+'.gif" align="left">'; } contents+=data.products[i].description + '<br style="clear:both" />'; if (owned) { contents+='<br><br><del><b>Purchase this product</b></del> <span>You already own this product<span>'; } else { if (data.products[i].prodType=='smp') { contents+='<br><br><b>Download version</b>: click '+returnBuyLink(data.products[i].code)+'here</a> to order a downloadable version today.'; contents+='<br><b>CD version</b>: visit <a href="http://www.samplefusion.com" target="_blank">www.SampleFusion.com</a> to order this product on a CD.'; } else { contents+='<br><br><b>Purchase this product:</b> click '+returnBuyLink(data.products[i].code)+'here</a> to order today from our online shop.'; } } if (data.products[i].name=='SimSynth') { panels.insertPanel('SimSynth Live',contents, false, owned); } else { panels.insertPanel(data.products[i].name,contents, false, owned); } }, insertFLRegsPanel: function(i) // makes a "FL info" dynamic table (based on the data.flRegs index) { function onlineOrder(params) // params: isUpgrade, price, code { contents+='<p><strong>'+(params.isUpgrade?'Upgrade':'Product')+' price: $'+params.price+' USD</strong></p>'+ '<p>'+returnBuyLink(params.code)+'Click here to '+(params.isUpgrade?'upgrade':'order')+'</a></p>'; } function boxedOnlineOrder(params) // params: isUpgrade, boxPrice, onlinePrice, code, noDVD { contents+='<p><strong>'+(params.isUpgrade?'Upgrade':'Product')+' price (boxed): $'+params.onlinePrice+' USD</strong></p>'+ '<p><strong>'+(params.isUpgrade?'Upgrade':'Product')+' price (online): $'+params.boxPrice+' USD '+(params.noDVD?'(no DVD included)':'')+'</strong></p>'+ '<p>'+returnBuyLink(params.code)+'Click here to '+(params.isUpgrade?'upgrade':'order')+'</a></p>'; } // i=-1 - demo; 2, 1, 0, 999 = basic, fruityloops, producer no xxl, producer and xxl var titleEnd; // modifies the table title var contents='<table style="width:expression(document.body.offsetWidth - 60 + "px");" border="0" cellpadding="5" cellspacing="5">'; contents+='<tr valign="top">'; var cellSpan; // how many percent spans each table cell if (i==-1) cellSpan='25%'; if (i==2) cellSpan='33%'; if (i==1) cellSpan='50%'; if (i==0) cellSpan='100%'; if (i==999) cellSpan=''; if (i==999) { // user has registered Producer Edition (no upgrades, or only Lifetime Upd. upgrade for boxed) // if the edition is boxed, it means the user can buy Lifetime updates if (isBoxed) { document.write('<br><br>'+returnBuyLink(31080)+'You can purchase <span style="font-weight:bold;">Lifetime Free Updates</span> for FL Studio XXL Edition ($29).</a><br><br>'); } else { // user has all document.write('<br><br>No FL-Studio upgrades are available for your registration.'); } } else { // write the tables.. if (i==-1) { // demo: buy express titleEnd="purchases"; contents+='<td width="'+cellSpan+'" class="fl-tbl">'; contents+=data.flRegs[2].description; if (i==-1) { if (isBasic) { contents+='<p><strong>Upgrade price: $39 USD</strong></p>'+ '<p>'+returnBuyLink(31060)+'Click here to order</a></p>'; } else { contents+='<p><strong>Product price: $49 USD</strong></p>'+ '<p>'+returnBuyLink(31000)+'Click here to order</a></p>'; } } contents+='</td>'; } else { titleEnd="upgrades"; } if (i==2 || i==-1) { // demo or express contents+='<td width="'+cellSpan+'" class="fl-tbl">'; contents+=data.flRegs[1].description; if (i==-1) { // demo: buy fruityloops if (isBasic) { contents+='<p><strong>Upgrade price: $79 USD</strong></p><p>'+returnBuyLink(31070)+'Click here to order</a></p>'; } else { contents+='<p><strong>Product price: $99 USD</strong></p><p>'+returnBuyLink(31010)+'Click here to order</a></p>'; } } if (i==2) { // express: upgrade to fruityloops (from express) if (isCreative) { contents+='<p><strong>Upgrade price: $69 USD</strong></p>'+ '<p>'+returnBuyLink(31075)+'Click here to upgrade</a></p>'; } else { contents+='<p><strong>Product price: $59 USD</strong></p>'+ '<p>'+returnBuyLink(31050)+'Click here to upgrade</a></p>'; } } contents+='</td>'; } if (i!=0) { // demo, express, fl options for producer contents+='<td width="'+cellSpan+'" class="fl-tbl">'; contents+=data.flRegs[0].description; if (i==-1) { // demo: buy producer if (isBasic) { contents+= '<p><strong>Upgrade price: $129 USD</strong></p>'+ '<p>'+returnBuyLink(31071)+'Click here to order</a></p>'; } else { contents+= '<p><strong>Product price: $149 USD</strong></p>'+ '<p>'+returnBuyLink(31020)+'Click here to order</a></p>'; } } if (i==1) { // fl edition: upgrade to producer from fruityloops if (isBoxed) { // $79 contents+='<p><strong>Upgrade price (boxed): please check your local dealer</strong></p>'+ '<p><strong>Upgrade price (online): $69 USD</strong></p>'+ '<p>'+returnBuyLink(31081)+'Click here to upgrade</a></p>'; } else { contents+='<p><strong>Upgrade price: $59 USD</strong></p>'+ '<p>'+returnBuyLink(31040)+'Click here to upgrade</a></p>'; } } if (i==2) { // express: upgrade to producer from express (express can't be boxed) if (isCreative) { contents+='<p><strong>Upgrade price: $119 USD</strong></p>'+ '<p>'+returnBuyLink(31076)+'Click here to upgrade</a></p>'; } else { contents+='<p><strong>Upgrade price: $99 USD</strong></p>'+ '<p>'+returnBuyLink(31051)+'Click here to upgrade</a></p>'; } } contents+='</td>'; } // XXL contents+='<td width="'+cellSpan+'" class="fl-tbl">'; contents+=data.flDesc.xxl; if (isBoxed) { if (i==1) { // from fruityloops // $269 contents+='<p><strong>Upgrade price (boxed): please check your local dealer</strong></p>'+ '<p><strong>Upgrade price (online): click the link for more info (no DVD included)</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } else if (i==0) { // from producer // was $199 USD contents+='<p><strong>Upgrade price (boxed): please check your local dealer</strong></p>'+ '<p><strong>Upgrade price (online): click the link for more info (no DVD included)</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } else { contents+='<p><strong>Upgrade price: click the link for more info</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } } else { if (i==-1) { // buy if (isBasic) { contents+='<p><strong>Upgrade price: click the link for more info</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } else { contents+='<p><strong>Product price (boxed): $449 USD</strong></p>'+ '<p><strong>Product price (online): $339 USD (no DVD included)</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } } else { // upgrade (from any online version) contents+='<p><strong>Upgrade price: click the link for more info</strong></p>'+ '<p>'+returnBuyLink('')+'Click here to upgrade</a></p>'; } } contents+='</td>'; contents+='</tr></table>'; panels.insertPanel('Available FL-Studio '+titleEnd,contents, "na"); } } } // --------------------------------------------------------------------------------- // PARSERS function parseProductData() // read & parse the data.xml file with products and settings { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.load("data.xml"); var xmlRoot = xmlDoc.documentElement.selectSingleNode('/fddata'); var node; // reused while parsing data = {};// intentionally on root to be globally accessible // FL descriptions data.flDesc = { xxl:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_xxl"]')), producer:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_producer"]')), fl:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_fl"]')), express:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_express"]')), fl4creative:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_fl4creative"]')), express4basic:innerXML(xmlRoot.selectSingleNode('flDesc/desc[@id="desc_express4basic"]')) }; // xxl / box codes data.xxlCodes = xmlRoot.selectSingleNode('xxlCodes').text.split(','); data.boxCodes = xmlRoot.selectSingleNode('boxCodes').text.split(','); // FL registrations node = xmlRoot.selectSingleNode('flRegs').firstChild; data.flRegs = []; do { data.flRegs[data.flRegs.length] = { code:node.attributes.getNamedItem('code').nodeValue, name:node.attributes.getNamedItem('name').nodeValue, registered:false, needed:false } } while (node = node.nextSibling); // patch content in: data.flRegs[0].description = data.flDesc.producer; data.flRegs[1].description = data.flDesc.fl; data.flRegs[2].description = data.flDesc.express; // other product registrations node = xmlRoot.selectSingleNode('products').firstChild; data.products = []; do { data.products[data.products.length] = { code:node.attributes.getNamedItem('code').nodeValue, name:node.attributes.getNamedItem('name').nodeValue, prodType:node.attributes.getNamedItem('prodType').nodeValue, description:innerXML(node), registered:false, needed:false } } while (node = node.nextSibling); // create merged array with all products data.allProducts = []; for (var i=0; i<data.flRegs.length; i++) { data.allProducts[data.allProducts.length] = data.flRegs[i]; } for (var i=0; i<data.products.length; i++) { data.allProducts[data.allProducts.length] = data.products[i]; } } function readRegData() // read FL.js { // ---------------------------------------- // include reg file & decode params array if (typeof(params)=="undefined") { // -------------------- // read file var regFilePath = 'file:///'+((location.href.substring((location.href.indexOf(':') == 2)?14:7, location.href.lastIndexOf("\\") + 1)+'FL.js').replace(/:/g, '|')).replace(/\\/g, '/') ; // full FL.js location document.write('<script language="JavaScript" type="text/javascript" src="'+regFilePath+'"></script>'); } } function parseRegData() // parse reg info { if (typeof(params)=="undefined") { // -------------------- // parse base64 to params var source=((paramsSource).slice(1)).toUpperCase(); // dump "G" at start & capitalize var i=0,j=0; var base16='0123456789ABCDEF'; var buffer=source.split('G'); params = ['','','','']; // globally accessible for (i=0;i<buffer.length;i++) { params[i]=''; for (j=0;j<buffer[i].length;j+=2) { params[i]+=String.fromCharCode(16*base16.indexOf(buffer[i].charAt(j))+base16.indexOf(buffer[i].charAt(j+1))); } } } // ---------------------------------------- // parse userData array userData = ['','','','']; // globally accessible // parse userData[0]=params[1].substring(0,params[1].indexOf(':')); userData[1]=params[1].substring(params[1].indexOf(':')+1,params[1].lastIndexOf(':')); userData[2]=params[1].substring(params[1].indexOf('[')+1,params[1].indexOf(']')); userData[3]=params[1].substring(params[1].indexOf('|')+1,params[1].lastIndexOf('|')).slice('|'); } function processData() { var i,j; // scan codes var codes=userData[3].split('|'); // a little mapping job from VSTi/DXi plugin codes to the regular codes for (var i=0; i<codes.length; i++) { switch (codes[i]) { case '37110': // SSLive codes[codes.length] = '33110'; break; case '37041': // Sytrus codes[codes.length] = '37040'; break; case '37021': // DX10 codes[codes.length] = '37020'; break; case '37310': // WASP codes[codes.length] = '33300'; break; } } for (i=0;i<codes.length;i++) { // check if the code means boxed version for (j=0;j<data.boxCodes.length;j++) { if (data.boxCodes[j]==Number(codes[i])) isBoxed=true; } if (codes[i]=='21020' || codes[i]=='21420') { // creative isCreative=true; data.flRegs[2].name='FL Studio Creative Edition'; // patch the regInfo data.flRegs[1].description = data.flDesc.fl4creative; } if (codes[i]=='21000' || codes[i]=='21010') { // basic isBasic=true; data.flRegs[2].description = data.flDesc.express4basic; } // set a product registered if a code is found for (j=0;j<data.allProducts.length;j++) { if (data.allProducts[j].code==Number(codes[i])) { data.allProducts[j].registered=true; } } } // correct reg levels for special cases if (isBasic) { data.flRegs[0].registered = false; data.flRegs[1].registered = false; data.flRegs[2].registered = false; } else if (isCreative) { data.flRegs[0].registered = false; data.flRegs[1].registered = false; data.flRegs[2].registered = true; } // scan pluglist to mark needed plugins var pluglist=params[4].split(':'); for (i=0;i<pluglist.length;i++) { for (j=0;j<data.allProducts.length;j++) { if (data.allProducts[j].name.toUpperCase()==pluglist[i].toUpperCase()) { data.allProducts[j].needed=true; } } } // detect XXL installation var hits = 0; for (i=0;i<data.xxlCodes.length;i++) { for (j=0;j<data.allProducts.length;j++) { if (data.allProducts[j].code==data.xxlCodes[i] && data.allProducts[j].registered) { hits++; } } } if (hits == data.xxlCodes.length) isXXL = true; } // --------------------------------------------------------------------------------- // DEBUG UTILS function initDebugRoutines() { function debugDump() { var cont = ''; cont += '<hr><p>DEBUG INFO (parameters listed):</p>'; for (i=0;i<params.length;i++) { cont += '<br>'+i+': '+(((params[i]==undefined)||(params[i]==''))?'<b>N/A</b>':'"'+params[i]+'"'); } cont+= '<br>'+location.hash; var el = document.createElement('div'); document.getElementsByTagName('body').item(0).appendChild(el); el.innerHTML = cont; } if (allowDebugDump) { window.attachEvent("onload",debugDump); } if (allowDebugParams) { params = []; // globally accessible params[0]="FLDI"; params[1]="StanislavNVasilev54875:60846:|21420|31020|"; params[2]=""; params[3]="2"; params[4]=""; // xxl //params[1]= "StanislavNVassilev54875:60846:|31020|33110|37030|37040|33000|37050|31000|"; } } // --------------------------------------------------------------------------------- // INIT allowDebugDump = false; // dumping of received params allowDebugParams = false; // injects debug set of params initDebugRoutines(); // init flags (autodetected/set later) isCreative=false; // Express special case isBoxed=false; isBasic=false; // Demo special case isXXL = false; isDemo = false; function stage1() { parseProductData(); readRegData(); } function stage2() { parseRegData(); processData(); } // NOTE: stage1 includes loading external JS file via document.write which requires that parsing is done later while "waiting" for data, so it's split in stage2 and called later in the HTMLs // ready, steady, go... stage1(); // Dorothy, I think we're not in Kansas anymore...