diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/encoding/ascii85.js | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-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/ascii85.js')
-rw-r--r-- | includes/js/dojox/encoding/ascii85.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/includes/js/dojox/encoding/ascii85.js b/includes/js/dojox/encoding/ascii85.js new file mode 100644 index 0000000..c54bb72 --- /dev/null +++ b/includes/js/dojox/encoding/ascii85.js @@ -0,0 +1,63 @@ +if(!dojo._hasResource["dojox.encoding.ascii85"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dojox.encoding.ascii85"] = true; +dojo.provide("dojox.encoding.ascii85"); + +(function(){ + var c = function(input, length, result){ + var i, j, n, b = [0, 0, 0, 0, 0]; + for(i = 0; i < length; i += 4){ + n = ((input[i] * 256 + input[i+1]) * 256 + input[i+2]) * 256 + input[i+3]; + if(!n){ + result.push("z"); + }else{ + for(j = 0; j < 5; b[j++] = n % 85 + 33, n = Math.floor(n / 85)); + } + result.push(String.fromCharCode(b[4], b[3], b[2], b[1], b[0])); + } + }; + + dojox.encoding.ascii85.encode = function(input){ + // summary: encodes input data in ascii85 string + // input: Array: an array of numbers (0-255) to encode + var result = [], reminder = input.length % 4, length = input.length - reminder; + c(input, length, result); + if(reminder){ + var t = input.slice(length); + while(t.length < 4){ t.push(0); } + c(t, 4, result); + var x = result.pop(); + if(x == "z"){ x = "!!!!!"; } + result.push(x.substr(0, reminder + 1)); + } + return result.join(""); // String + }; + + dojox.encoding.ascii85.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, 0], i, j, t, x, y, d; + for(i = 0; i < n; ++i){ + if(input.charAt(i) == "z"){ + r.push(0, 0, 0, 0); + continue; + } + for(j = 0; j < 5; ++j){ b[j] = input.charCodeAt(i + j) - 33; } + d = n - i; + if(d < 5){ + for(j = d; j < 4; b[++j] = 0); + b[d] = 85; + } + t = (((b[0] * 85 + b[1]) * 85 + b[2]) * 85 + b[3]) * 85 + b[4]; + x = t & 255; + t >>>= 8; + y = t & 255; + t >>>= 8; + r.push(t >>> 8, t & 255, y, x); + for(j = d; j < 5; ++j, r.pop()); + i += 4; + } + return r; + }; +})(); + +} |