summaryrefslogtreecommitdiff
path: root/includes/js/dojox/encoding/easy64.js
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/encoding/easy64.js
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadsemanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2
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
Diffstat (limited to 'includes/js/dojox/encoding/easy64.js')
-rw-r--r--includes/js/dojox/encoding/easy64.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/includes/js/dojox/encoding/easy64.js b/includes/js/dojox/encoding/easy64.js
new file mode 100644
index 0000000..824ff3e
--- /dev/null
+++ b/includes/js/dojox/encoding/easy64.js
@@ -0,0 +1,50 @@
+if(!dojo._hasResource["dojox.encoding.easy64"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.encoding.easy64"] = true;
+dojo.provide("dojox.encoding.easy64");
+
+(function(){
+ var c = function(input, length, result){
+ for(var i = 0; i < length; i += 3){
+ result.push(
+ String.fromCharCode((input[i] >>> 2) + 33),
+ String.fromCharCode(((input[i] & 3) << 4) + (input[i + 1] >>> 4) + 33),
+ String.fromCharCode(((input[i + 1] & 15) << 2) + (input[i + 2] >>> 6) + 33),
+ String.fromCharCode((input[i + 2] & 63) + 33)
+ );
+ }
+ };
+
+ dojox.encoding.easy64.encode = function(input){
+ // summary: encodes input data in easy64 string
+ // input: Array: an array of numbers (0-255) to encode
+ var result = [], reminder = input.length % 3, length = input.length - reminder;
+ c(input, length, result);
+ if(reminder){
+ var t = input.slice(length);
+ while(t.length < 3){ t.push(0); }
+ c(t, 3, result);
+ for(var i = 3; i > reminder; result.pop(), --i);
+ }
+ return result.join(""); // String
+ };
+
+ dojox.encoding.easy64.decode = function(input){
+ // summary: decodes the input string back to array of numbers
+ // input: String: the input string to decode
+ var n = input.length, r = [], b = [0, 0, 0, 0], i, j, d;
+ for(i = 0; i < n; i += 4){
+ for(j = 0; j < 4; ++j){ b[j] = input.charCodeAt(i + j) - 33; }
+ d = n - i;
+ for(j = d; j < 4; b[++j] = 0);
+ r.push(
+ (b[0] << 2) + (b[1] >>> 4),
+ ((b[1] & 15) << 4) + (b[2] >>> 2),
+ ((b[2] & 3) << 6) + b[3]
+ );
+ for(j = d; j < 4; ++j, r.pop());
+ }
+ return r;
+ };
+})();
+
+}