From e44a7e37b6c7b5961adaffc62b9042b8d442938e Mon Sep 17 00:00:00 2001 From: mensonge Date: Thu, 13 Nov 2008 09:49:11 +0000 Subject: New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f --- includes/js/dojox/encoding/base64.js | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 includes/js/dojox/encoding/base64.js (limited to 'includes/js/dojox/encoding/base64.js') diff --git a/includes/js/dojox/encoding/base64.js b/includes/js/dojox/encoding/base64.js new file mode 100644 index 0000000..916e119 --- /dev/null +++ b/includes/js/dojox/encoding/base64.js @@ -0,0 +1,66 @@ +if(!dojo._hasResource["dojox.encoding.base64"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.encoding.base64"] = true; +dojo.provide("dojox.encoding.base64"); + +(function(){ + var p="="; + var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var dxe=dojox.encoding; + + dxe.base64.encode=function(/* byte[] */ba){ + // summary + // Encode an array of bytes as a base64-encoded string + var s=[], l=ba.length; + var rm=l%3; + var x=l-rm; + for (var i=0; i>>18)&0x3f)); + s.push(tab.charAt((t>>>12)&0x3f)); + s.push(tab.charAt((t>>>6)&0x3f)); + s.push(tab.charAt(t&0x3f)); + } + // deal with trailers, based on patch from Peter Wood. + switch(rm){ + case 2:{ + var t=ba[i++]<<16|ba[i++]<<8; + s.push(tab.charAt((t>>>18)&0x3f)); + s.push(tab.charAt((t>>>12)&0x3f)); + s.push(tab.charAt((t>>>6)&0x3f)); + s.push(p); + break; + } + case 1:{ + var t=ba[i++]<<16; + s.push(tab.charAt((t>>>18)&0x3f)); + s.push(tab.charAt((t>>>12)&0x3f)); + s.push(p); + s.push(p); + break; + } + } + return s.join(""); // string + }; + + dxe.base64.decode=function(/* string */str){ + // summary + // Convert a base64-encoded string to an array of bytes + var s=str.split(""), out=[]; + var l=s.length; + while(s[--l]==p){ } // strip off trailing padding + for (var i=0; i>>16)&0xff); + out.push((t>>>8)&0xff); + out.push(t&0xff); + } + // strip off any null bytes + while(out[out.length-1]==0){ out.pop(); } + return out; // byte[] + }; +})(); + +} -- cgit v1.2.3