214714ca9b0310176ee180bb9fdbe36571efcca5.svn-base
985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function () {
'use strict';
var inflate = require('../lib/rawinflate.js'),
deflate = require('../lib/rawdeflate.js'),
ender = require('ender');
ender.domReady(function () {
ender('#inflated').bind('keyup', function () {
var self = this, dst = ender('#deflated');
setTimeout(function(){
var arr,
str;
arr = Array.prototype.map.call(self.value, function (char) {
return char.charCodeAt(0);
});
str = deflate(arr).map(function (byte) {
return String.fromCharCode(byte);
}).join('');
dst.val(btoa(str));
},0);
});
ender('#deflated').bind('keyup', function () {
var self = this, dst = ender('#inflated');
setTimeout(function(){
var str,
arr;
arr = Array.prototype.map.call(atob(self.value), function (char) {
return char.charCodeAt(0);
});
str = inflate(arr).map(function (byte) {
return String.fromCharCode(byte);
}).join('');
dst.val(str);
}, 0);
});
});
}());