SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Tool to un-minimized these codes?

    I have these codes below,

    Code:
    (function(){var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var d=window.Crypto={};var a=d.util={rotl:function(h,g){return(h<<g)|(h>>>(32-g));},rotr:function(h,g){return(h<<(32-g))|(h>>>g);},endian:function(h){if(h.constructor==Number){return a.rotl(h,8)&16711935|a.rotl(h,24)&4278255360;}for(var g=0;g<h.length;g++){h[g]=a.endian(h[g]);}return h;},randomBytes:function(h){for(var g=[];h>0;h--){g.push(Math.floor(Math.random()*256));}return g;},bytesToWords:function(h){for(var k=[],j=0,g=0;j<h.length;j++,g+=8){k[g>>>5]|=h[j]<<(24-g%32);}return k;},wordsToBytes:function(i){for(var h=[],g=0;g<i.length*32;g+=8){h.push((i[g>>>5]>>>(24-g%32))&255);}return h;},bytesToHex:function(g){for(var j=[],h=0;h<g.length;h++){j.push((g[h]>>>4).toString(16));j.push((g[h]&15).toString(16));}return j.join("");},hexToBytes:function(h){for(var g=[],i=0;i<h.length;i+=2){g.push(parseInt(h.substr(i,2),16));}return g;},bytesToBase64:function(h){if(typeof btoa=="function"){return btoa(e.bytesToString(h));}for(var g=[],l=0;l<h.length;l+=3){var m=(h[l]<<16)|(h[l+1]<<8)|h[l+2];for(var k=0;k<4;k++){if(l*8+k*6<=h.length*8){g.push(c.charAt((m>>>6*(3-k))&63));}else{g.push("=");}}}return g.join("");},base64ToBytes:function(h){if(typeof atob=="function"){return e.stringToBytes(atob(h));}h=h.replace(/[^A-Z0-9+\/]/ig,"");for(var g=[],j=0,k=0;j<h.length;k=++j%4){if(k==0){continue;}g.push(((c.indexOf(h.charAt(j-1))&(Math.pow(2,-2*k+8)-1))<<(k*2))|(c.indexOf(h.charAt(j))>>>(6-k*2)));}return g;}};d.mode={};var b=d.charenc={};var f=b.UTF8={stringToBytes:function(g){return e.stringToBytes(unescape(encodeURIComponent(g)));},bytesToString:function(g){return decodeURIComponent(escape(e.bytesToString(g)));}};var e=b.Binary={stringToBytes:function(j){for(var g=[],h=0;h<j.length;h++){g.push(j.charCodeAt(h));}return g;},bytesToString:function(g){for(var j=[],h=0;h<g.length;h++){j.push(String.fromCharCode(g[h]));}return j.join("");}};})();(function(){var f=Crypto,a=f.util,b=f.charenc,e=b.UTF8,d=b.Binary;var c=f.MD5=function(i,g){var h=a.wordsToBytes(c._md5(i));return g&&g.asBytes?h:g&&g.asString?d.bytesToString(h):a.bytesToHex(h);};c._md5=function(y){if(y.constructor==String){y=e.stringToBytes(y);}var k=a.bytesToWords(y),n=y.length*8,v=1732584193,u=-271733879,t=-1732584194,s=271733878;for(var p=0;p<k.length;p++){k[p]=((k[p]<<8)|(k[p]>>>24))&16711935|((k[p]<<24)|(k[p]>>>8))&4278255360;}k[n>>>5]|=128<<(n%32);k[(((n+64)>>>9)<<4)+14]=n;var q=c._ff,h=c._gg,w=c._hh,o=c._ii;for(var p=0;p<k.length;p+=16){var g=v,r=u,j=t,x=s;v=q(v,u,t,s,k[p+0],7,-680876936);s=q(s,v,u,t,k[p+1],12,-389564586);t=q(t,s,v,u,k[p+2],17,606105819);u=q(u,t,s,v,k[p+3],22,-1044525330);v=q(v,u,t,s,k[p+4],7,-176418897);s=q(s,v,u,t,k[p+5],12,1200080426);t=q(t,s,v,u,k[p+6],17,-1473231341);u=q(u,t,s,v,k[p+7],22,-45705983);v=q(v,u,t,s,k[p+8],7,1770035416);s=q(s,v,u,t,k[p+9],12,-1958414417);t=q(t,s,v,u,k[p+10],17,-42063);u=q(u,t,s,v,k[p+11],22,-1990404162);v=q(v,u,t,s,k[p+12],7,1804603682);s=q(s,v,u,t,k[p+13],12,-40341101);t=q(t,s,v,u,k[p+14],17,-1502002290);u=q(u,t,s,v,k[p+15],22,1236535329);v=h(v,u,t,s,k[p+1],5,-165796510);s=h(s,v,u,t,k[p+6],9,-1069501632);t=h(t,s,v,u,k[p+11],14,643717713);u=h(u,t,s,v,k[p+0],20,-373897302);v=h(v,u,t,s,k[p+5],5,-701558691);s=h(s,v,u,t,k[p+10],9,38016083);t=h(t,s,v,u,k[p+15],14,-660478335);u=h(u,t,s,v,k[p+4],20,-405537848);v=h(v,u,t,s,k[p+9],5,568446438);s=h(s,v,u,t,k[p+14],9,-1019803690);t=h(t,s,v,u,k[p+3],14,-187363961);u=h(u,t,s,v,k[p+8],20,1163531501);v=h(v,u,t,s,k[p+13],5,-1444681467);s=h(s,v,u,t,k[p+2],9,-51403784);t=h(t,s,v,u,k[p+7],14,1735328473);u=h(u,t,s,v,k[p+12],20,-1926607734);v=w(v,u,t,s,k[p+5],4,-378558);s=w(s,v,u,t,k[p+8],11,-2022574463);t=w(t,s,v,u,k[p+11],16,1839030562);u=w(u,t,s,v,k[p+14],23,-35309556);v=w(v,u,t,s,k[p+1],4,-1530992060);s=w(s,v,u,t,k[p+4],11,1272893353);t=w(t,s,v,u,k[p+7],16,-155497632);u=w(u,t,s,v,k[p+10],23,-1094730640);v=w(v,u,t,s,k[p+13],4,681279174);s=w(s,v,u,t,k[p+0],11,-358537222);t=w(t,s,v,u,k[p+3],16,-722521979);u=w(u,t,s,v,k[p+6],23,76029189);v=w(v,u,t,s,k[p+9],4,-640364487);s=w(s,v,u,t,k[p+12],11,-421815835);t=w(t,s,v,u,k[p+15],16,530742520);u=w(u,t,s,v,k[p+2],23,-995338651);v=o(v,u,t,s,k[p+0],6,-198630844);s=o(s,v,u,t,k[p+7],10,1126891415);t=o(t,s,v,u,k[p+14],15,-1416354905);u=o(u,t,s,v,k[p+5],21,-57434055);v=o(v,u,t,s,k[p+12],6,1700485571);s=o(s,v,u,t,k[p+3],10,-1894986606);t=o(t,s,v,u,k[p+10],15,-1051523);u=o(u,t,s,v,k[p+1],21,-2054922799);v=o(v,u,t,s,k[p+8],6,1873313359);s=o(s,v,u,t,k[p+15],10,-30611744);t=o(t,s,v,u,k[p+6],15,-1560198380);u=o(u,t,s,v,k[p+13],21,1309151649);v=o(v,u,t,s,k[p+4],6,-145523070);s=o(s,v,u,t,k[p+11],10,-1120210379);t=o(t,s,v,u,k[p+2],15,718787259);u=o(u,t,s,v,k[p+9],21,-343485551);v=(v+g)>>>0;u=(u+r)>>>0;t=(t+j)>>>0;s=(s+x)>>>0;}return a.endian([v,u,t,s]);};c._ff=function(i,h,o,l,g,k,j){var m=i+(h&o|~h&l)+(g>>>0)+j;return((m<<k)|(m>>>(32-k)))+h;};c._gg=function(i,h,o,l,g,k,j){var m=i+(h&l|o&~l)+(g>>>0)+j;return((m<<k)|(m>>>(32-k)))+h;};c._hh=function(i,h,o,l,g,k,j){var m=i+(h^o^l)+(g>>>0)+j;return((m<<k)|(m>>>(32-k)))+h;};c._ii=function(i,h,o,l,g,k,j){var m=i+(o^(h|~l))+(g>>>0)+j;return((m<<k)|(m>>>(32-k)))+h;};c._blocksize=16;})();(function(window){DC.Currency={DOLLAR:"$",USD:"US$",GBP:"&pound;",EUR:"&euro;",YEN:"&yen;",AUD:"AU$",BRL:"R$",CAD:"C$",CZK:"Kč",DKK:"kr",HKD:"HK$",HUF:"Ft",ILS:"₪",MYR:"RM",MXN:"Mex$",NOK:"Kr",NZD:"NZ$",PHP:"PHP$",PLN:"zł",SGD:"SG$",SEK:"kr",CHF:"CHF",TWD:"TW$",THB:"THB$",TRY:"TL",getCurrencySymbol:function(currency){switch(currency){case"GBP":return"&pound;";case"EUR":return"&euro;";case"YEN":return"&yen;";case"AUD":return"AU$";default:return"$";}}};}(window));(function(window){window.DC.cart=DC.cart||{};DC.cart.Cart={width:300,height:200,widget:null,autoOpenWhenAdd:false,autoCleanCart:true,openNewCheckOutWindow:false,language:"en",currency:"USD",header:"",footer:"",paypalOptions:{},themeColor:undefined,themeDarkColor:undefined,cartOpened:false,onItemAdd:DC.NOOP,onItemupRemove:DC.NOOP,onCartUpdate:DC.NOOP,onValidateAddress:DC.NOOP,onCheckOut:DC.NOOP,_currentSection:"cart",_widget:null,_cartController:null,_container:null,_cartView:null,_addressView:null,_paymentView:null,init:function(options){var self=this;$.extend(this,options);if(this.language){DC.cart.lang=DC.cart["lang_"+this.language];}else{DC.cart.lang=DC.cart.lang_en;}if(this.widget){this._widget=this.widget;this._widget.addClass("cartWidget");this._widget.click(function(){log(self._container.y);if(self.cartOpened){self.closeCart();}else{self.openCart();}});}this._container=new DC.cart.ContatinerView({styles:"cart",width:this.width,height:this.height,onLeftButtonClick:function(){if(self._currentSection=="cart"){self.closeCart();}else{if(self._currentSection=="address"){self._changeSection("cart");}else{if(self._currentSection=="payment"){if(self._cartController.needShipping){self._changeSection("address");}else{self._changeSection("cart");}}}}},onRightButtonClick:function(){if(self._currentSection=="cart"){if(self._cartController.needShipping){self._changeSection("address");}else{self._changeSection("payment");}}else{if(self._currentSection=="address"){self._cartController.address=self._addressView.getShipping();if(!self._cartController.address){return;}self.onValidateAddress(self._cartController.address);self._changeSection("payment");}}}});this._cartView=new DC.cart.CartView({width:280,onUpdate:function(e){},onItemUpdate:function(ids,qtys){self._cartController.updateItemQty(ids,qtys);},onItemRemove:function(item){self._cartController.removeItem(item.id);}});this._addressView=new DC.cart.AddressView();this._paymentView=new DC.cart.PaymentView();this._container.setHeader(this.header);this._container.setFooter(this.footer);this._cartController=new DC.cart.CartController({currency:this.currency,paymentOptions:this.paymentOptions,paypalOptions:this.paypalOptions,openNewCheckOutWindow:this.openNewCheckOutWindow,onUpdate:function(cart){self._updateCartView(cart);self.onCartUpdate(cart);},onItemAdd:function(item){self.onItemAdd(item);
    },onItemupRemove:function(item){self.onItemRemove(item);},onCheckout:function(cart){if(self.autoCleanCart){cart.clean();}self.onCheckOut(cart);self._changeSection("cart");self.closeCart();}});this._changeSection("cart");this._container.attachTo("body");this._container.setSize(this.width,this.height);this._container.ui.css({top:0,left:($(window).width()-this.width)/2});this._container.setVisible(false);$(window).resize(function(){self._container.ui.css({left:($(window).width()-self.width)/2});});},_updateCartView:function(cart){this._container.setNeedShipping(cart.needShipping);if(this._currentSection=="cart"){if(cart.count<=0){this._container.rightButton.setEnabled(false);this._container.setTitle(DC.cart.lang["label_noitem"]);}else{this._container.rightButton.setEnabled(true);this._container.setTitle(DC.cart.lang["label_item_info"].replace("%S",cart.count));}if(this._container.visible){this._cartView.update(cart);}}this._updateContainerButton();if(this._widget){var content=$('<div class="amount">'+DC.Currency[cart.currency]+cart.subTotal.toFixed(2)+'</div><div class="badge">'+DC.cart.lang["cartwidget"].replace("%S",cart.count)+"</div>");content.hide();this._widget.empty();this._widget.append(content);content.fadeIn();}this._updateStyles();},_changeSection:function(section){if(section=="cart"){this._container.setContent(this._cartView);this._container.setTitle(DC.cart.lang["label_item_info"].replace("%S",this._cartController.count));this._container.rightButton.setVisible(true);this._container.setSection(1);}else{if(section=="address"){this._container.setContent(this._addressView);var shipping_info=DC.cart.lang["label_shipping_info"].replace("%S",DC.Currency[this._cartController.currency]+this._cartController.shipping);this._container.setTitle(shipping_info);this._container.rightButton.setVisible(true);this._container.setSection(2);}else{if(section=="payment"){this._paymentView.updatePayment(this._cartController);this._container.setContent(this._paymentView);this._container.setTitle(DC.cart.lang["label_payment_info"]);this._container.rightButton.setVisible(false);this._container.setSection(3);}}}this._currentSection=section;this._updateStyles();this._updateContainerButton();},_updateContainerButton:function(){if(this._cartController){if(this._currentSection=="cart"){this._container.leftButton.setText(DC.cart.lang["button_cancel"]);if(this._cartController.needShipping){this._container.rightButton.setText(DC.cart.lang["button_shipping"]);}else{this._container.rightButton.setText(DC.cart.lang["button_billing"]);}}else{if(this._currentSection=="address"){this._container.leftButton.setText(DC.cart.lang["button_cart"]);this._container.rightButton.setText(DC.cart.lang["button_billing"]);}else{if(this._currentSection=="payment"){if(this._cartController.needShipping){this._container.leftButton.setText(DC.cart.lang["button_shipping"]);}else{this._container.leftButton.setText(DC.cart.lang["button_cart"]);}}}}}},_updateStyles:function(){log(this.themeColor);if(this.themeColor){$(".dc_ui.cart .button").css("background-color",this.themeColor);$(".dc_ui.cart .button.disabled").css("background-color","");$(".dc_ui.cart .step").css("background-color","");$(".dc_ui.cart .step.selected").css("background-color",this.themeColor);$(".cartWidget").css("background-color",this.themeColor);}if(this.themeDarkColor){$(".dc_ui.cart .step .tag").css("background-color","");$(".dc_ui.cart .step.selected .tag").css("background-color",this.themeDarkColor);$(".dc_ui.cart .total_label .amount").css("color",this.themeDarkColor);}},openCart:function(){this.cartOpened=true;this._container.setVisible(true);this._updateCartView(this._cartController);this._container.setSize();this._container.setXY(0,-this.height-60,0);this._container.setXY(0,0,0.5);},closeCart:function(){this.cartOpened=false;var self=this;this._container.setXY(0,-this.height-60,0.5,function(){self._container.setVisible(false);});},add:function(data){if(this.autoOpenWhenAdd){this.openCart();}this._cartController.addItem(data);},remove:function(id){this._cartController.removeItem(id);},clean:function(){this._cartController.clean();},updateQty:function(id,qty){this._cartController.updateItemQty([id],[qty]);}};DC.cart.Cart=Class.extend(DC.cart.Cart);}(window));(function(window){DC.cart.Item={id:undefined,name:"no name",thumbnail:null,description:"item description",type:"DUMMY",currency_symbol:"$",currency:"DOLLAR",price:0,shipping:undefined,shipping2:undefined,qty:0,total:0,weight:0,allowMultiple:true,init:function(data){if(data.id=="undefined"||data.id==undefined){data.id=Crypto.MD5(data.name);}if(data.price!=undefined){data.price=parseFloat(data.price);}if(data.shipping!=undefined){data.shipping=parseFloat(data.shipping);}if(data.shipping2!=undefined){data.shipping2=parseFloat(data.shipping2);}if(typeof data.allowMultiple=="string"&&(data.allowMultiple.toLowerCase()=="false"||data.allowMultiple.toLowerCase()=="no")){data.allowMultiple=false;}if(data.allowMultiple==false||data.allowMultiple==0){data.allowMultiple=false;}$.extend(this,data);}};window.DC.cart.Item=Class.extend(DC.cart.Item);DC.cart.CartEvent={items:null,init:function(type,items){this._super(type);this.items=items;}};window.DC.cart.CartEvent=DC.Event.extend(DC.cart.CartEvent);$.extend(DC.cart.CartEvent,{ADD:"cart_add",REMOVE:"cart_remove",UPDATE:"cart_update"});DC.cart.CartController={id:"DEFAULT_NAME",version:"0.1",items:null,currency:"DOLLAR",needShipping:false,shipping:0,address:null,count:0,paypalOptions:null,paymentOptions:null,total:0,subTotal:0,openNewCheckOutWindow:false,_storage:null,onUpdate:DC.NOOP,onItemAdd:DC.NOOP,onItemRemove:DC.NOOP,onCheckout:DC.NOOP,init:function(options){if(options){$.extend(this,options);}this._storage=new DC.CookieStorage({id:this.id,version:this.version+"_"+this.currency});this.items={};var tempItems=this._storage.get("cart");if(tempItems){for(var i in tempItems){var item=tempItems[i];this.items[item.id]=new DC.cart.Item(item);}}this._updateCount();this.onUpdate(this);},_update:function(){this._updateCount();this._storage.set("cart",this.items);this.onUpdate(this);},_updateCount:function(){var count=0;this.needShipping=false;this.total=0;this.subTotal=0;this.shipping=0;for(var idx in this.items){if(this.items[idx]){if(this.items[idx].shipping!=undefined){this.needShipping=true;this.shipping+=this.items[idx].shipping;if(this.items[idx].shipping2!=undefined){this.needShipping=true;this.shipping+=this.items[idx].shipping2*(this.items[idx].qty-1);}}var tt=this.items[idx].qty*this.items[idx].price;if(tt>0){this.subTotal=this.subTotal+tt;}count++;}}this.total=this.subTotal+this.shipping;this.count=count;},addItem:function(item){var tempitem;if(item.id=="undefined"||item.id==undefined){item.id=Crypto.MD5(item.name);}if(this.items[item.id]){tempitem=this.items[item.id];tempitem.currency=this.currency;}else{tempitem=new DC.cart.Item(item);this.items[item.id]=tempitem;}tempitem.currency=this.currency;if(tempitem.allowMultiple){if(item.qtys==undefined){if(item.qtyInput){if($("#"+item.qtyInput)){tempitem.qty+=Number($("#"+item.qtyInput).val());}}else{tempitem.qty=tempitem.qty+1;}}else{tempitem.qty=tempitem.qty+item.qtys;}}else{tempitem.qty=1;}tempitem.total=tempitem.qty*item.price;if(tempitem.qty>0){this.onItemAdd(tempitem);this._update();}else{this.items[item.id]=null;}},removeItem:function(id){if(id!=undefined){this.updateItemQty([id],[0]);}},updateItemQty:function(ids,qtys){if(ids&&qtys){for(var i in ids){var id=ids[i];var qty=qtys[i];if(this.items[id]&&qty!=undefined){var tempitem=this.items[id];if(qty>0){tempitem.qty=qty;}else{this.onItemRemove(tempitem);delete this.items[id];}}}}this._update();},getAllItems:function(){var a=[];for(var idx in this.items){if(this.items[idx]){a.push(this.items[idx]);}}return a;},getItemsForPurchase:function(){var a=[];for(var idx in this.items){if(this.items[idx]){a.push({"qty":this.items[idx].qty,"id":this.items[idx].id,"class":this.items[idx]["class"]});}}return a;},clean:function(){log("clean");this.items={};
    this._update();},getPaymentButton:function(){if(this.paymentOptions!=null){return this.getURLPaymentButton();}return this.getPaypalButton();},getURLPaymentButton:function(){var self=this;var items="";var address="";var i=1;for(var idx in this.items){var item=this.items[idx];items+='<input type="hidden" name="item_name_'+i+'" value="'+item.name+'">';items+='<input type="hidden" name="amount_'+i+'" value="'+item.price+'">';items+='<input type="hidden" name="item_number_'+i+'" value="'+item.id+'">';items+='<input type="hidden" name="quantity_'+i+'" value="'+item.qty+'">';if(item.shipping>0){items+='<input type="hidden" name="shipping_'+i+'" value="'+item.shipping+'">';}if(item.shipping2>0){items+='<input type="hidden" name="shipping2_'+i+'" value="'+item.shipping2+'">';}if(item.weight>0){items+='<input type="hidden" name="weight_'+i+'" value="'+item.weight*qty+'">';}i++;}var address_key={"city":"city","country":"country","firstname":"first_name","lastname":"last_name","line1":"address1","line2":"address2","phone":"night_ phone_b","zip":"zip"};if(this.needShipping&&this.address){for(var n in this.address){address+='<input type="hidden" name="'+address_key[n]+'" value="'+this.address[n]+'">';}}address+='<input type="hidden" name="currency_code" value="'+this.currency+'">';for(var p in this.paypalOptions){if(p!="server"){address+='<input type="hidden" name="'+p+'" value="'+this.paymentOptions[p]+'">';}}if(this.paymentOptions.submitButton==undefined){this.paymentOptions.submitButton='<div class="float button mask" style="width: 98px; height: 22px;"><p>Check Out</p></div>';}var target="";if(this.openNewCheckOutWindow){target='target="_blank"';}var id=this.id+"_SUBMIT_BUTTON";var button=$('<form id="'+id+'" action="'+this.paymentOptions.server+'" method="post" '+target+">"+items+address+this.paymentOptions.submitButton+"</form>");button.click(function(e){$("#"+id).trigger("submit");self.onCheckout(self);});return button;},getPaypalButton:function(){var self=this;var items="";var address="";var i=1;for(var idx in this.items){var item=this.items[idx];items+='<input type="hidden" name="item_name_'+i+'" value="'+item.name+'">';items+='<input type="hidden" name="amount_'+i+'" value="'+item.price+'">';items+='<input type="hidden" name="item_number_'+i+'" value="'+item.id+'">';items+='<input type="hidden" name="quantity_'+i+'" value="'+item.qty+'">';if(item.shipping>0){items+='<input type="hidden" name="shipping_'+i+'" value="'+item.shipping+'">';}if(item.shipping2>0){items+='<input type="hidden" name="shipping2_'+i+'" value="'+item.shipping2+'">';}if(item.weight>0){items+='<input type="hidden" name="weight_'+i+'" value="'+item.weight*qty+'">';}i++;}var address_key={"city":"city","country":"country","firstname":"first_name","lastname":"last_name","line1":"address1","line2":"address2","phone":"night_ phone_b","zip":"zip"};if(this.needShipping&&this.address){for(var n in this.address){address+='<input type="hidden" name="'+address_key[n]+'" value="'+this.address[n]+'">';}}address+='<input type="hidden" name="currency_code" value="'+this.currency+'">';for(var p in this.paypalOptions){if(p!="server"){address+='<input type="hidden" name="'+p+'" value="'+this.paypalOptions[p]+'">';}}if(this.paypalOptions.server==undefined){this.paypalOptions.server="https://www.paypal.com/cgi-bin/webscr";}var target="";if(this.openNewCheckOutWindow){target='target="_blank"';}var id=this.id+"_SUBMIT_BUTTON";var button=$('<form id="'+id+'" action="'+this.paypalOptions.server+'" method="post" '+target+'><input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="'+this.paypalOptions.business+'">'+items+address+'<img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/></form>');button.click(function(e){$("#"+id).trigger("submit");self.onCheckout(self);});return button;},getfreeItems:function(){var f=true;for(var idx in this.items){if(this.items[idx].price!=0){f=false;break;}}if(f){f=(this.total()<=0);}return f;}};DC.cart.CartController=Class.extend(DC.cart.CartController);}(window));(function(window){DC.cart.ContatinerView={leftButton:null,rightButton:null,_header:null,_footer:null,_content:null,_headerContainer:null,_title:null,_titleContainer:null,_step1:null,_step2:null,_step3:null,_contentContainer:null,_controlContainer:null,_headerWidth:100,_haveAddress:false,onRightButtonClick:DC.NOOP,onLeftButtonClick:DC.NOOP,createChildren:function(){this._super();var self=this;this._header=new DC.Container({styles:"header",width:this.width,height:0});this._footer=new DC.Container({styles:"footer",width:this.width,height:0});this._step1=new DC.Text({styles:"step selected",text:'<div class="tag">'+DC.cart.lang["step1"]+"</div> "+DC.cart.lang["step1_text"]});this._step2=new DC.Text({styles:"step",text:'<div class="tag">'+DC.cart.lang["step2"]+"</div> "+DC.cart.lang["step2_text"]});this._step3=new DC.Text({styles:"step",text:'<div class="tag">'+DC.cart.lang["step3"]+"</div> "+DC.cart.lang["step3_text"]});this._headerContainer=new DC.HBox({gap:0,styles:"header_container",width:this.width});this._headerContainer.addChild(this._step1);this._headerContainer.addChild(this._step2);this._headerContainer.addChild(this._step3);this._title=new DC.Text({styles:"title",text:"<This is title"});this._titleContainer=new DC.Container({styles:"title_container",width:this.width});this._titleContainer.addChild(this._title);this._contentContainer=new DC.Container({styles:"content_container",width:this.width});this._controlContainer=new DC.Container({styles:"control_container",width:this.width});this.leftButton=new DC.Button({styles:"left_button",text:"Left",onClick:function(){self.onLeftButtonClick();}});this.rightButton=new DC.Button({styles:"right_button",text:"Right",onClick:function(){self.onRightButtonClick();}});this._controlContainer.addChild(this.leftButton);this._controlContainer.addChild(this.rightButton);this.addClass("cartcontainer");},createComplete:function(){this._super();this.addChild(this._header);this.addChild(this._headerContainer);this.addChild(this._titleContainer);this.addChild(this._contentContainer);this.addChild(this._controlContainer);this.addChild(this._footer);},setSize:function(w,h){var hh=this.defaultHeight-$(".cartcontainer > .header").height()-$(".cartcontainer > .footer").height()-$(".cartcontainer > .title_container").height()-$(".cartcontainer > .control_container").height()-$(".cartcontainer > .header_container").height();if(hh>0){this._contentContainer.setSize(this.width,hh);}this._super(w,h);this._header.setSize();this._footer.setSize();if(this._haveAddress){this._headerWidth=this.innerWidth/3;}else{this._headerWidth=this.innerWidth/2;}this._step1.setSize(this._headerWidth);this._step2.setSize(this._headerWidth);this._step3.setSize(this._headerWidth);this._headerContainer.setSize(this.innerWidth);if(this._content){this._content.setSize(this._contentContainer.width,this._contentContainer.height);}},setNeedShipping:function(address){this._haveAddress=address;this._headerContainer.removeAllChildren();if(address){this._headerWidth=this.innerWidth/3;this._step3.setText('<div class="tag">'+DC.cart.lang["step3"]+"</div> "+DC.cart.lang["step3_text"]);this._headerContainer.addChild(this._step1);this._headerContainer.addChild(this._step2);this._headerContainer.addChild(this._step3);}else{this._step3.setText('<div class="tag">'+DC.cart.lang["step2"]+"</div> "+DC.cart.lang["step3_text"]);this._headerWidth=this.innerWidth/2;this._headerContainer.addChild(this._step1);this._headerContainer.addChild(this._step3);}},setContent:function(content){if(this._contentContainer){if(this._content){this._contentContainer.removeChild(this._content);}this._content=content;this._contentContainer.addChild(content);this.setSize();}},setSection:function(value){this._step1.removeClass("selected");this._step2.removeClass("selected");this._step3.removeClass("selected");if(value==1){this._step1.addClass("selected");
    }else{if(value==2){this._step2.addClass("selected");}else{if(value==3){this._step3.addClass("selected");}}}},setTitle:function(value){this._title.setText(value);},setHeader:function(value){if(value&&value!=""){this._header.ui.append(value);}else{this._header.setVisible(false);}},setFooter:function(value){if(value&&value!=""){this._footer.ui.append(value);}else{this._footer.setVisible(false);}}};window.DC.cart.ContatinerView=DC.VBox.extend(DC.cart.ContatinerView);}(window));(function(window){DC.cart.CartItemRenderer={thumbnail:null,title:null,itemid:null,price:null,qty:null,delete_button:null,onItemRemove:DC.NOOP,onItemUpdate:DC.NOOP,createChildren:function(){this._super();var self=this;this.leftContainer=new DC.Container({styles:"container"});this.leftContainer.removeClass("mask");this.thumbnail=new DC.Image({styles:"thumbnail",width:30,height:30});this.title=new DC.Text({styles:"title"});this.itemid=new DC.Text({styles:"itemid"});this.leftContainer.addChild(this.thumbnail);this.leftContainer.addChild(this.title);this.leftContainer.addChild(this.itemid);this.price=new DC.Text({styles:"price"});this.qty=new DC.TextInput({styles:"qty",onChange:function(d){self.data.qty=DC.num(self.qty.value());self.dispatchEvent(new DC.cart.CartEvent(DC.cart.CartEvent.CHANGE,self.data));}});this.qty.setVisible(false);this.delete_button=new DC.Button({text:DC.cart.lang["button_delete"],styles:"delete_button",onClick:function(){self.dispatchEvent(new DC.cart.CartEvent(DC.cart.CartEvent.REMOVE,self.data));}});},createComplete:function(){this._super();this.addChild(this.leftContainer);this.addChild(this.price);this.addChild(this.qty);this.addChild(this.delete_button);},commitSize:function(){this._super();this.qty.setSize(25);if(this.data.thumbnail){this.thumbnail.setVisible(true);this.title.ui.css({left:this.thumbnail.width+10});this.itemid.ui.css({left:this.thumbnail.width+10});}else{this.thumbnail.setVisible(false);this.title.ui.css({left:""});this.itemid.ui.css({left:""});}},commitProperties:function(prop,value){switch(prop){case"data":this.title.setText(this.data.name);this.itemid.setText(this.data.id);this.thumbnail.setSource(this.data.thumbnail);this.price.setText(this.data.price);if(this.data.price==0){this.price.setText("free");}else{this.price.setText(DC.Currency[this.data.currency]+this.data.price*this.data.qty);}if(this.data.allowMultiple){this.qty.setVisible(true);this.qty.setValue(this.data.qty);}else{this.qty.setVisible(false);}break;}}};DC.cart.CartItemRenderer=DC.DataRenderer.extend(DC.cart.CartItemRenderer);DC.cart.CartView={list:null,infoContainer:null,totalLabel:null,updateButton:null,promo_label:null,promo_text:null,promo_input:null,promo_button:null,_ds:null,_updataItemsLaterList:null,onItemRemove:DC.NOOP,onItemUpdate:DC.NOOP,onPromoCode:DC.NOOP,createChildren:function(){this._super();var self=this;this._updataItemsLaterList={};this.list=new DC.Table({styles:"item_table",width:this.width,itemRenderer:DC.cart.CartItemRenderer});this._ds=new DC.DataSource();this.list.setDataSource(this._ds);this.list.addEventListener(DC.cart.CartEvent.REMOVE,function(e){self.onItemRemove(e.items);});this.list.addEventListener(DC.cart.CartEvent.CHANGE,function(e){self._saveUpdateItems(e.items.id,e.items.qty);});this.infoContainer=new DC.Container({styles:"info_container",width:this.width});this.totalLabel=new DC.Text({styles:"total_label",text:DC.cart.lang["label_total"]});this.updateButton=new DC.Button({styles:"update_button",text:DC.cart.lang["button_update"],onClick:function(){log("up");self._updateItems();}});this.addClass("cartview");},createComplete:function(){this._super();this.infoContainer.addChild(this.totalLabel);this.infoContainer.addChild(this.updateButton);this.addChild(this.list);this.addChild(this.infoContainer);},commitSize:function(){this._super();this.infoContainer.setSize(this.width);this.list.setSize(this.width,this.height-this.infoContainer.height);this.list.setXY(0,0);this.infoContainer.setXY(0,this.height-this.infoContainer.height);},_saveUpdateItems:function(id,qty){if(id!=undefined){this._updataItemsLaterList[id]=qty;}},_updateItems:function(){var ids=[];var qtys=[];for(var i in this._updataItemsLaterList){ids.push(i);qtys.push(this._updataItemsLaterList[i]);}this.onItemUpdate(ids,qtys);},update:function(cart){this._updataItemsLaterList={};if(cart.count>0){this.list.setVisible(true);this.infoContainer.setVisible(true);this.totalLabel.setText(DC.cart.lang["label_total"]+' <div class="currency">'+DC.Currency[cart.currency]+'</div><div class="amount">'+cart.subTotal.toFixed(2)+"</div>");this.totalLabel.ui.css({width:"",height:""});this.updateButton.ui.css({right:this.updateButton.width+this.totalLabel.width+10});this._ds.load(cart.getAllItems());}else{this.list.setVisible(false);this.infoContainer.setVisible(false);}}};window.DC.cart.CartView=DC.Container.extend(DC.cart.CartView);}(window));(function(window){DC.cart.AddressView={form:null,createChildren:function(){this._super();this.addClass("shippingview");this.form=new DC.Form({id:"address",gap:5,width:this.width,labelWidth:120,data:DC.cart.lang.addressform});},createComplete:function(){this._super();this.addChild(this.form);},setSize:function(w,h){this._super(w,h);this.form.setSize(this.width);},getShipping:function(){return this.form.values();}};window.DC.cart.AddressView=DC.Container.extend(DC.cart.AddressView);}(window));(function(window){DC.cart.PaymentView={payButtonContainer:null,detailContainer:null,createChildren:function(){this._super();this.addClass("paymentview");this.payButtonContainer=new DC.Container({styles:"pay_button_container",width:this.width});this.detailContainer=new DC.Text({styles:"detail_container"});},createComplete:function(){this._super();this.addChild(this.detailContainer);this.addChild(this.payButtonContainer);},setSize:function(w,h){this._super(w,h);},updatePayment:function(cart){var detail=DC.cart.lang["label_item_cost"].replace("%S",cart.count).replace("%A",DC.Currency[cart.currency]+cart.subTotal)+"<br/>";if(cart.needShipping){detail+=DC.cart.lang["label_shipping_cost"].replace("%S",DC.Currency[cart.currency]+cart.shipping)+"<br/>";}detail+=DC.cart.lang["label_total_cost"].replace("%S",DC.Currency[cart.currency]+cart.total)+"<br/>";this.detailContainer.setText(detail);this.payButtonContainer.ui.removeClass("mask");this.payButtonContainer.ui.empty();this.payButtonContainer.ui.append(cart.getPaymentButton());}};window.DC.cart.PaymentView=DC.Container.extend(DC.cart.PaymentView);}(window));(function(window){$.fn.extend({DCAJAXPaypalCart:function(options){var defaults={width:500,height:400};var options=$.extend(defaults,options);var self=this;return this.each(function(){options.widget=self;options.footer='<img src="'+DC.LOGO+'" align="right"/><div style="font-size: 0.7em;">AJAX Paypal Cart (Free Version). Develop by <a href="http://www.digicrafts.com.hk/components">Digicrafts.</a></div>';self.cart=new DC.cart.Cart(options);for(var fn in self.cart){if(typeof self.cart[fn]=="function"){var f=function(){self.cart[arguments.callee.FUNCTION_NAME].apply(self.cart,arguments);};f["FUNCTION_NAME"]=fn;self[fn]=f;}}self.addBuyButton=function(target,data){$(target).click(function(){self.cart.add(data);});};});}});}(window));
    I want to explode the codes to understand it.
    Any tools you can advice?

    Thanks in advance.
    I Love coding...
    Don't click this link.

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,312
    Mentioned
    178 Post(s)
    Tagged
    8 Thread(s)
    Try this one: http://jsbeautifier.org/

    You won't be able to reverse the short variable names etc. but it'll make the code a lot more readable.

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    @Pullo ;
    wow nice tool.
    thanks dude.
    I Love coding...
    Don't click this link.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by solidcodes View Post
    @Pullo ;
    wow nice tool.
    thanks dude.
    You can pretty print with google chrome too, live on the page that you're working with from the Chrome console. There's a pair of braces on the bottom row that does the job for you, which makes it even easier to investigate such things.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •