>8)&0xFF)};var writePixels=function writePixels(){var myencoder=new LZWEncoder(width,height,indexedPixels,colorDepth);myencoder.encode(out)};var stream=exports.stream=function stream(){return out};var setProperties=exports.setProperties=function setProperties(has_start,is_first){started=has_start;firstFrame=is_first};return exports};
// Lap
(function() {
var contain = {
id: 'LapContain',
title: '\u0028\u0E51\u2022\u0300\u3142\u2022\u0301\u0029\u0648\u2727',
width: 263,
height: 426,
left: function() {
return (document.documentElement.clientWidth / 2 - this.width / 2).toFixed(1) + 'px'
},
top: function() {
return (document.documentElement.clientHeight / 2 - this.height / 2).toFixed(1) + 'px'
}
};
var face = {};
var imageList = {};
var getImage = function(u, c) {
var x = createElement('IFRAME', {style:'display:none'});
x.onload = function() {
var t = setInterval(function() {
if (!imageList[u]) {
return
};
var i = new Image();
i.onload = function() {
c(this)
};
i.src = URL.createObjectURL(imageList[u]);
x.parentNode.removeChild(x), clearInterval(t)
}, 1);
};
x.src = u;
document.documentElement.appendChild(x)
};
var postImage = function(b, c) {
var t = new XMLHttpRequest();
t.open('GET', 'http://tieba.baidu.com/dc/common/imgtbs', true);
t.onreadystatechange = function() {
t.readyState == 4 && (function(tbs) {
var f = new FormData(), x = new XMLHttpRequest();
f.append('file', b);
x.open('POST', 'http://upload.tieba.baidu.com/upload/pic?tbs=' + tbs, true);
x.onreadystatechange = function() {
x.readyState == 4 && (function(i) {
c(i.pic_water.replace('/tieba/', '/forum/'), i.fullpic_width, i.fullpic_height)
})(JSON.parse(x.responseText).info)
};
x.withCredentials = true;
x.send(f)
})(JSON.parse(t.responseText).data.tbs)
};
t.send()
};
var madeImage = function(l, x, y, m, c) {
var t = this, u = arguments, a = 'image/jpeg', b = t.getContext('2d'), k = lapList[l].layer, f = function(i) {
y == 0 && (x == 1 && (m = new GIFEncoder(), a = 'image/gif', m.setRepeat(lapList[l].repeat || 0), m.setDelay(lapList[l].delay || 84), m.start(), !1) || x > 0 && m.addFrame(b));
b.save();
k[x][y].r && b.rotate(k[x][y].r);
b.drawImage(i, k[x][y].x || 0, k[x][y].y || 0, k[x][y].w || t.width, k[x][y].h || t.height);
b.restore();
y = y < k[x].length - 1 ? y + 1 : (++x, 0);
x < (!m ? 1 : k.length) ? madeImage.apply(t, u) : (c && c(toBlob((typeof(m) == 'object' ? (m.addFrame(b), m.finish(), m.stream().bin) : Array.prototype.map.call(atob(t.toDataURL(a).replace('data:' + a + ';base64,', '')), function(x) {return x.charCodeAt(0) & 0xff})), a)))
}
x == 0 && y == 0 && (t.height = lapList[l].height, t.width = lapList[l].width);
getImage(k[x][y].src == '[FACE]' ? face.src : k[x][y].src, f)
};
var toBlob = function(s, f) {
return new Blob([new Uint8Array(s).buffer], {type: f})
};
var createElement = function(e, s) {
e = document.createElement(e), s = s || {};
for (var i in s) {
e.setAttribute(i, s[i])
};
return e
};
var removeContain = function(e) {
var d = document.getElementById(contain.id);
return d && (e && (e.preventDefault(), e.stopPropagation()) || d.parentNode.removeChild(d), !0)
};
var createContain = function(e) {
var i, j, t, d, o;
removeContain();
d = createElement('DIV', {id: contain.id, class: 'dialogJ dialogJfix dialogJshadow ui-draggable', style: 'z-index:60001;width:' + contain.width + 'px;left:' + contain.left() + ';top:' + contain.top()});
d.innerHTML = '';
document.body.appendChild(d);
o = e.target.parentNode, face.src = o.querySelector('.p_author_face>IMG').src + '?t=' + (new Date()).getTime();
o = JSON.parse(o.parentNode.parentNode.parentNode.parentNode.getAttribute('data-field'));
face.floor = o.content.post_no, face.name = o.author.user_name;
i = document.querySelector('#' + contain.id + ' .dialogJbody');
for (j in lapList) {
t = createElement('CANVAS');
i.appendChild(createElement('DIV', {class: 'lapContent', data: j, style: 'cursor:pointer'})).appendChild(t);
madeImage.call(t, j, 0, 0, 0)
}
};
var createButton = function() {
var f = document.querySelectorAll('.icon_relative');
for (var i = f.length - 1; i > -1; i--) {
var j = f[i].appendChild(createElement('DIV', {class: 'LAP_BUTTON', style: 'position:absolute;right:0;bottom:0;background-color:#eee;padding:0 3px 0 3px;border-radius:2px;box-shadow:0 0 1px #333'}));
j.addEventListener('click', createContain, false);
j.textContent = '\u8214'
}
};
if (location.hostname != 'tieba.baidu.com') {
var Img = new Image();
Img.onload = function() {
var c = document.createElement('canvas');
c.width = this.width, c.height = this.height;
c.getContext('2d').drawImage(this, 0, 0);
window.parent.postMessage(location.href + '!IMAGE_DATA!' + c.toDataURL(), '*')
};
Img.src = location.href;
return
};
window.addEventListener('message', function(e) {
if (e.data.indexOf('!IMAGE_DATA!') == -1) {
return
};
e = e.data.split('!IMAGE_DATA!');
imageList[e[0]] = toBlob(Array.prototype.map.call(atob(e[1].replace('data:image/png;base64,', '')), function(x) {return x.charCodeAt(0) & 0xff}), 'image/png')
}, false);
window.addEventListener('resize', function() {
var d = document.getElementById(contain.id);
d && (d.style.left = contain.left(), d.style.top = contain.top())
}, false);
document.addEventListener('click', function(e) {
e.target.className.indexOf('dialogJclose') != -1 && removeContain(e);
e.target.parentNode.className.indexOf('lapContent') != -1 && removeContain(e) && (function() {
var i = e.target.parentNode.getAttribute('data');
window.scrollTo(0, 0xffffff);
madeImage.call(createElement('CANVAS'), i, 0, 0, 1, function(b) {
postImage(b, function(u, w, h) {
var r = function(t) {
return t.replace('[FLOOR]', face.floor).replace('[NAME]', face.name)
};
document.getElementById('ueditor_replace').innerHTML += (lapList[i].text ? '' + r(lapList[i].text) + '
' : '') + '
' + (lapList[i].afterText ? '' + r(lapList[i].afterText) + '
' : '')
})
})
})()
}, false);
(function() {
var f = function() {
!document.querySelector('.LAP_BUTTON') && createButton()
};
(new MutationObserver(f)).observe(document, {childList: true, subtree: true});
f()
})()
})();