Permalink
Browse files

#34 - tidying up for IE support

  • Loading branch information...
1 parent 79252ac commit 16190453166d1c47fee965158abf04cfc711d375 @PaulKinlan committed Jun 22, 2011
View
@@ -16,11 +16,11 @@ examples/lib/webintents.debug.js: webintents.debug.js
examples/lib/webintents.min.js: webintents.min.js
ln -f webintents.min.js examples/lib/webintents.min.js
-webintents.js: ./src/release.js ./src/webintents.js ./src/json2.js
- cat ./src/webintents.js ./src/json2.js | sed 's|// __WEBINTENTS_ROOT|$(RELEASE)|' > webintents.js
+webintents.js: ./src/release.js ./src/webintents.js ./src/json2.js ./src/base64.js
+ cat ./src/webintents.js ./src/json2.js ./src/base64.js | sed 's|// __WEBINTENTS_ROOT|$(RELEASE)|' > webintents.js
-webintents.debug.js: ./src/webintents.js ./src/debug.js ./src/json2.js
- cat ./src/webintents.js ./src/json2.js | sed 's|// __WEBINTENTS_ROOT|$(DEBUG)|' > webintents.debug.js
+webintents.debug.js: ./src/webintents.js ./src/debug.js ./src/json2.js ./src/base64.js
+ cat ./src/webintents.js ./src/json2.js ./src/base64.js | sed 's|// __WEBINTENTS_ROOT|$(DEBUG)|' > webintents.debug.js
webintents.min.js: webintents.js
uglifyJs $^ > $@
@@ -29,7 +29,7 @@ tools/chrome/extensions/share/webintents.js: webintents.js
ln -f webintents.js tools/chrome/extensions/share/webintents.js
# Manifest depends on changes to other files, so include them in the dependency chain
-server/cache.manifest: server/cache.manifest.src server/picker.html server/picker.js server/webintents.js server/intents.html server/json2.js server/webintents-server.js server/webintents.min.js server/webintents.debug.js
+server/cache.manifest: server/cache.manifest.src server/picker.html server/picker.js server/webintents.js server/intents.html server/json2.js server/webintents-server.js server/webintents.min.js server/webintents.debug.js server/base64.js
cat server/cache.manifest.src >> server/cache.manifest
echo '#' `date` >> server/cache.manifest
@@ -786,3 +786,64 @@ if (!JSON) {
};
}
}());
+/*
+ * base64.js - Base64 encoding and decoding functions
+ *
+ * See: http://developer.mozilla.org/en/docs/DOM:window.btoa
+ * http://developer.mozilla.org/en/docs/DOM:window.atob
+ *
+ * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com>
+ * Released under the MIT license
+ */
+
+if (typeof btoa == 'undefined') {
+ function btoa(str) {
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+ var encoded = [];
+ var c = 0;
+ while (c < str.length) {
+ var b0 = str.charCodeAt(c++);
+ var b1 = str.charCodeAt(c++);
+ var b2 = str.charCodeAt(c++);
+ var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0);
+ var i0 = (buf & (63 << 18)) >> 18;
+ var i1 = (buf & (63 << 12)) >> 12;
+ var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6;
+ var i3 = isNaN(b2) ? 64 : (buf & 63);
+ encoded[encoded.length] = chars.charAt(i0);
+ encoded[encoded.length] = chars.charAt(i1);
+ encoded[encoded.length] = chars.charAt(i2);
+ encoded[encoded.length] = chars.charAt(i3);
+ }
+ return encoded.join('');
+ }
+}
+
+if (typeof atob == 'undefined') {
+ function atob(str) {
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+ var invalid = {
+ strlen: (str.length % 4 != 0),
+ chars: new RegExp('[^' + chars + ']').test(str),
+ equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str)))
+ };
+ if (invalid.strlen || invalid.chars || invalid.equals)
+ throw new Error('Invalid base64 data');
+ var decoded = [];
+ var c = 0;
+ while (c < str.length) {
+ var i0 = chars.indexOf(str.charAt(c++));
+ var i1 = chars.indexOf(str.charAt(c++));
+ var i2 = chars.indexOf(str.charAt(c++));
+ var i3 = chars.indexOf(str.charAt(c++));
+ var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63);
+ var b0 = (buf & (255 << 16)) >> 16;
+ var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8;
+ var b2 = (i3 == 64) ? -1 : (buf & 255);
+ decoded[decoded.length] = String.fromCharCode(b0);
+ if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1);
+ if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2);
+ }
+ return decoded.join('');
+ }
+}
@@ -786,3 +786,64 @@ if (!JSON) {
};
}
}());
+/*
+ * base64.js - Base64 encoding and decoding functions
+ *
+ * See: http://developer.mozilla.org/en/docs/DOM:window.btoa
+ * http://developer.mozilla.org/en/docs/DOM:window.atob
+ *
+ * Copyright (c) 2007, David Lindquist <david.lindquist@gmail.com>
+ * Released under the MIT license
+ */
+
+if (typeof btoa == 'undefined') {
+ function btoa(str) {
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+ var encoded = [];
+ var c = 0;
+ while (c < str.length) {
+ var b0 = str.charCodeAt(c++);
+ var b1 = str.charCodeAt(c++);
+ var b2 = str.charCodeAt(c++);
+ var buf = (b0 << 16) + ((b1 || 0) << 8) + (b2 || 0);
+ var i0 = (buf & (63 << 18)) >> 18;
+ var i1 = (buf & (63 << 12)) >> 12;
+ var i2 = isNaN(b1) ? 64 : (buf & (63 << 6)) >> 6;
+ var i3 = isNaN(b2) ? 64 : (buf & 63);
+ encoded[encoded.length] = chars.charAt(i0);
+ encoded[encoded.length] = chars.charAt(i1);
+ encoded[encoded.length] = chars.charAt(i2);
+ encoded[encoded.length] = chars.charAt(i3);
+ }
+ return encoded.join('');
+ }
+}
+
+if (typeof atob == 'undefined') {
+ function atob(str) {
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+ var invalid = {
+ strlen: (str.length % 4 != 0),
+ chars: new RegExp('[^' + chars + ']').test(str),
+ equals: (/=/.test(str) && (/=[^=]/.test(str) || /={3}/.test(str)))
+ };
+ if (invalid.strlen || invalid.chars || invalid.equals)
+ throw new Error('Invalid base64 data');
+ var decoded = [];
+ var c = 0;
+ while (c < str.length) {
+ var i0 = chars.indexOf(str.charAt(c++));
+ var i1 = chars.indexOf(str.charAt(c++));
+ var i2 = chars.indexOf(str.charAt(c++));
+ var i3 = chars.indexOf(str.charAt(c++));
+ var buf = (i0 << 18) + (i1 << 12) + ((i2 & 63) << 6) + (i3 & 63);
+ var b0 = (buf & (255 << 16)) >> 16;
+ var b1 = (i2 == 64) ? -1 : (buf & (255 << 8)) >> 8;
+ var b2 = (i3 == 64) ? -1 : (buf & 255);
+ decoded[decoded.length] = String.fromCharCode(b0);
+ if (b1 >= 0) decoded[decoded.length] = String.fromCharCode(b1);
+ if (b2 >= 0) decoded[decoded.length] = String.fromCharCode(b2);
+ }
+ return decoded.join('');
+ }
+}
Oops, something went wrong.

0 comments on commit 1619045

Please sign in to comment.