- // ==UserScript==
- // @name tb_borer
- // @namespace http://wp.stf.iaceob.name
- // @description tba_style
- // @include http://tieba.baidu.com/*
- // @version 1.9 alpha
- // @grant none
- // @author 生物烯丙菊
- // ==/UserScript==
-
-
- String.prototype.format = function () {
- var txt = this.toString();
- for (var i = 0; i < arguments.length; i++) {
- var exp = getStringFormatPlaceHolderRegEx(i);
- txt = txt.replace(exp, (arguments[i] == null ? "" : arguments[i]));
- }
- return cleanStringFormatResult(txt);
- }
- function getStringFormatPlaceHolderRegEx(placeHolderIndex) {
- return new RegExp('({)?\\{' + placeHolderIndex + '\\}(?!})', 'gm');
- }
- function cleanStringFormatResult(txt) {
- if (txt == null) return "";
- return txt.replace(getStringFormatPlaceHolderRegEx("\\d+"), "");
- }
-
- Array.prototype.remove=function(dx) {
- if(isNaN(dx)||dx>this.length){ return false; }
- for(var i=0,n=0;i<this.length;i++) {
- if(this[i]!=this[dx]) {
- this[n++]=this[i]
- }
- }
- this.length-=1
- return true;
- }
-
-
- !(function(window, $, undefined){
- var topic = $('#thread_topic');
- var h_posts = $('#thread_list li.j_thread_list');
- var h_paging = $('#frs_list_pager');
- var me = $('#balv_mod');
- var html = '';
-
- var document = window.document;
- var history = window.history;
- var pd = window.PageData;
- var tpl = {};
-
- if (!pd) {
- return;
- }
-
- var config = {
- history: {
- title: '',
- url: ''
- },
- posts: {
- page_url: '',
- handle_url: 'http://tieba.baidu.com/f/commit/thread/add',
- forum_id: 0,
- forum_name: 0,
- tbs: '',
- floor_num: 0,
- content: '',
- title: ''
- },
- post: {
- page_url: '',
- handle_url: 'http://tieba.baidu.com/f/commit/post/add',
- forum_id: 0,
- thread_id: 0,
- forum_name: '',
- tbs: '',
- floor_num: 1,
- lzl_url: 'http://tieba.baidu.com/p/comment',
- lzl_pn: 1,
- post_id: '',
- see_lz: false
- },
- captcha: {
- url4: 'http://tieba.baidu.com/cgi-bin/genimg',
- url4_get: 'http://tieba.baidu.com/f/commit/commonapi/getVcode',
- url_check: 'http://tieba.baidu.com/f/commit/commonapi/checkVcode',
- type: 0,
- code: '',
- input: '',
- value: []
- },
- user: {
- id: 0,
- name: ''
- },
- depend: [
- {url: 'http://idc.iaceob.name/tba_style/tba_v1.7_alpha.css', type: 'css'},
- {url: 'http://idc.iaceob.name/tba_style/jquery.omniwindow.js', type: 'js'},
- {url: 'http://idc.iaceob.name/um/gbk/themes/default/css/umeditor.css', type: 'css'},
- {url: 'http://idc.iaceob.name/um/gbk/umeditor.config.js', type: 'js'},
- {url: 'http://idc.iaceob.name/um/gbk/umeditor.min.js', type: 'js'},
- {url: 'http://idc.iaceob.name/um/gbk/lang/zh-cn/zh-cn.js', type: 'js'}
- ],
- editor: null
- };
- config.user.id = pd.user.user_id;
- config.user.name = pd.user.user_name;
- window.cfg = config;
- tpl.html_header = '<header id="header" class="loop-12"></header>';
- tpl.html_container = '<div class="span container">{0}</div>';
- tpl.html_footer = '<footer id="footer" class="loop-12">Footer</footer>';
- tpl.html_footer += '<div class="ow-overlay ow-closed"></div><div class="tba-modal ow-closed">Hello, human!</div>';
- tpl.html_box_posts = '<div class="loop-4 box_posts" id="box_posts"></div>';
- tpl.html_box_post = '<div class="loop-8 post_container" id="post_container"></div>';
- // tpl.css = 'http://idc.iaceob.name/tba_style/tba_v1.6_alpha.css';
- // tpl.js_omniwindow = 'http://idc.iaceob.name/tba_style/jquery.omniwindow.js';
-
- if (location.href === 'http://tieba.baidu.com/') {
- return;
- }
-
-
- function initBorer() {
- if (!!pd.forum.id) {
- setPostsConfig($('body').text());
- var postsPage = parsePosts($('body'));
- initPage();
- initPosts(postsPage);
- return;
- }
- if (!!pd.forum.forum_id) {
- $.ajax({
- url: 'http://tieba.baidu.com/' + pd.forum.forum_name,
- dataType: 'html'
- }).done(function(data){
- config.post.page_url = window.location.href;
- setPostConfig($('body').text());
- setPostsConfig($(data).text());
- var postPage = parsePost($('body'));
- initPage();
- initPosts(parsePosts($(data)));
- initPost(postPage);
- });
- return;
- }
- };
-
- function initPage() {
- var fhtml = parseFooter();
- html = tpl.html_header;
- html += tpl.html_container.format(tpl.html_box_posts+tpl.html_box_post);
- html += tpl.html_footer;
- $('body').empty();
- $('body').html(html);
- // $('#head').html(html);
- initHeader();
- initFooter(fhtml);
- initImport();
- bindEvent();
- };
-
- function initPosts(body) {
- $('.posts_paging a').unbind('click');
- $('#post_container').empty();
- $('#box_posts').html(body);
- $('#box_posts').scrollTop(0);
- monitorHPage();
- };
-
- function initPost(body) {
- $('.post-page a').unbind('click');
- $('#post_container').html(body);
- $('#post_container').scrollTop(0);
- mointorPPage();
- };
-
- function initHeader() {
- var hhtml = '<div class="loop-2 tiebalogo"><img src="http://tb2.bdstatic.com/tb/static-common/img/search_logo_7098cbef.png"></div>';
- hhtml += '<div class="loop-8">\
- <div class="select_box">\
- <input type="text" name="query" id="query" class="keyipt">\
- <div id="search_list" style="display: none"></div>\
- </div>\
- </div>';
- $('#header').html(hhtml);
- };
-
- function initFooter(fhtml) {
- $('#footer').html(fhtml);
- };
-
- function initImport(){
- for(var i=0; i<config.depend.length; i++) {
- loadFile(config.depend[i].url, config.depend[i].type);
- }
- };
-
- function monitorHPage() {
- $('#btn_posting').bind('click', function(){
- var pshtml = '';
- pshtml += '<div class="box_modal">\
- <div class="modal_container">\
- <div class="loop-12"><textarea id="posts_editor" name="content"style="width:100%;height:360px;"></textarea></div>\
- <div class="loop-2">贴吧:</div>\
- <div class="loop-10 forum_name">' + config.posts.forum_name + '</div>\
- <div class="loop12">标题:</div>\
- <div class="loop-12"><input type="text" id="posts_title" name="title" autocomplete="off"></div>\
- </div>\
- <div class="loop-12" id="modal_other"></div>\
- <div class="loop-12 modal_result"></div>\
- <div class="loop-12"><button class="btn" id="btn_submit">提交</button></div>\
- </div>';
- $('.tba-modal').html(pshtml);
- window.UM.delEditor('posts_editor');
- var editor_posts = window.UM.getEditor('posts_editor');
- config.editor = editor_posts;
- $('.tba-modal').omniWindow().trigger('show');
- $('#btn_submit').bind('click', function(){
- var title = $('#posts_title').val();
- var content = formatEditor(editor_posts.getContent());
- executePosting(title, content);
- });
- });
- $('.posts_paging a').bind('click', function(){
- handleGetPosts(this.href);
- return false;
- });
- $('.posts_list li').bind('click', function(){
- handleGetPost($(this).data('href'));
- });
- };
-
-
- function mointorPPage() {
- $('.post-page a').bind('click', function(){
- handleGetPost(this.href);
- return false;
- });
- $('#post_replay').bind('click', function(){
- var pshtml = '';
- pshtml += '<div class="box_modal">\
- <div class="modal_container">\
- <div class="loop-12"><textarea id="post_editor" name="content"></textarea></div>\
- <div class="loop-2">贴吧:</div>\
- <div class="loop-10 forum_name">' + config.posts.forum_name + '</div>\
- </div>\
- <div class="loop-12" id="modal_other"></div>\
- <div class="loop-12 modal_result"></div>\
- <div class="loop-12"><button class="btn" id="btn_submit">提交</button></div>\
- </div>';
- $('.tba-modal').html(pshtml);
- window.UM.delEditor('post_editor');
- var editor_post = window.UM.getEditor('post_editor');
- config.editor = editor_post;
- $('.tba-modal').omniWindow().trigger('show');
- $('#btn_submit').bind('click', function(){
- var content = formatEditor(editor_post.getContent());
- executPostReplay(content);
- });
- });
- $('.btn_replay_lzl').bind('click', function(){
- if(!$(this).data('index')) {
- $('#post_replay').click();
- return;
- }
- config.post.lzl_pn = 1;
- config.post.floor_num = $(this).data('floor');
- config.post.post_id = $(this).data('pid');
- handleGetLzlReplay();
- });
- $('#see_lz').bind('click', function(){
- if (config.post.see_lz) {
- config.post.see_lz = false;
- handleGetPost(config.post.page_url.split('?')[0]);
- return;
- }
- config.post.see_lz = true;
- handleGetPost(config.post.page_url.split('?')[0] + '?see_lz=1');
- return;
- });
- };
-
- function mointorSearch(){
- $.ajax({
- url: 'http://tieba.baidu.com/suggestion',
- data: $('#query').serialize(),
- dataType: 'json',
- }).done(function(data){
- $('#search_list').html(parseSearch(data));
- });
- };
-
- function mointorLzlReplay(pid, html) {
- $('.tba-modal').html(html);
- $('.tba-modal').omniWindow().trigger('show');
- $('.lzl-page a').bind('click', function(){
- config.post.lzl_pn = this.href.split('#')[1];
- config.post.post_id = pid;
- handleGetLzlReplay();
- });
- $('.btn_lzl_replay').bind('click', function(){
- $('.box_lzl_replay').empty();
- var pid = $(this).data('spid');
- var aur = $(this).data('author');
- var lrp = '<div id="box_lzl_replay_' + pid + '" class="span box_lzl_replay">\
- <div class="loop-12 lzl_editor"><textarea id="lzl-editor-' + pid + '">' + (!aur ? '' : '@'+aur+' ') + '</textarea></div>\
- <div class="loop-12 lzl_operate">\
- <button class="btn" id="btn_handle_replay_lzl" data-pid="' + pid + '">回复</button>\
- </div>\
- <div class="lzl_replay_other"></div>\
- </div>';
- $('#box_lzl_rep-' + pid).html(lrp);
- monitorBtnLzlReplay();
- });
- };
-
- function monitorBtnLzlReplay() {
- $('#btn_handle_replay_lzl').bind('click', function(){
- var pid = $(this).data('pid');
- var content = $('#lzl-editor-' + pid).val();
- $.ajax({
- url: config.post.handle_url,
- type: 'post',
- data: {
- anonymous: 0,
- fid: config.post.forum_id,
- floor_num: config.post.floor_num,
- ie: 'utf-8',
- kw: config.post.forum_name,
- quote_id: config.post.post_id,
- repostid: config.post.post_id,
- rich_text: 1,
- // tag: 11,
- tbs: config.post.tbs,
- tid: config.post.thread_id,
- new_vcode: 1,
- content: content,
- vcode_md5: config.captcha.code,
- vcode: config.captcha.input
- },
- dataType: 'json'
- }).done(function(data){
- parseLzlReplay(data, pid);
- });
- });
- };
-
- window.handleSearchResult = function(forum){
- var url = 'http://tieba.baidu.com/' + forum;
- handleGetPosts(url);
- window.history.pushState(config.history, null, url);
- };
-
- function handleGetPosts(postsUrl) {
- // config.posts.page_url = postsUrl;
- window.history.pushState(config.history, null, postsUrl);
- $.ajax({
- url: postsUrl,
- dataType: 'html'
- }).done(function(data){
- setPostsConfig($(data).text());
- initPosts(parsePosts($(data)));
- });
- };
-
- function handleGetLzlReplay() {
- $.ajax({
- url: config.post.lzl_url,
- data: {tid: config.post.thread_id, pid: config.post.post_id, pn: config.post.lzl_pn},
- dataType: 'html'
- }).done(function(data){
- window.da = $(data);
- var lhtml = parsePostLzl($(data));
- mointorLzlReplay(config.post.post_id, lhtml);
- });
- };
-
- function handleGetPost(postUrl) {
- config.post.page_url = postUrl;
- window.history.pushState(config.history, null, postUrl);
- $.ajax({
- url: postUrl,
- dataType: 'html'
- }).done(function(data){
- initPost(parsePost($(data)));
- setPostConfig($(data).text());
- });
- };
-
-
-
- function setPostsConfig(text) {
- var tbs = text.match(/PageData.tbs([ ]*)=([ ]*)"(.*?)"/);//[3]
- var fid = text.match(/PageData.forum([ ]*)=([ ]*){(.*?)"forum_id":(\d+)/);
- var fe = text.match(/PageData.forum([ ]*)=([ ]*){(.*?)"forum_name":"(.*?)"/);
- config.posts.tbs = !tbs ? '' : tbs[3];
- config.posts.forum_id = !fid ? 0 : fid[4];
- config.posts.forum_name = !fe ? '' : decodeUnicode(fe[4]);
- config.posts.page_url = 'http://tieba.baidu.com/' + config.posts.forum_name;
- };
-
- function setPostConfig(text){
- var tbs1 = text.match(/PageData([ ]*)=([ ]*){(.*?)'tbs'(.*?):(.*?)"(.*?)"/);
- var tbs2 = text.match(/PageData([ ]*)=([ ]*){(.*?)tbs(.*?):(.*?)'(.*?)'/);
- var fid = text.match(/PageData.forum([ ]*)=([ ]*){(.*?)"forum_id":(\d+)/);
- var fe = text.match(/PageData.forum([ ]*)=([ ]*){(.*?)"forum_name":"(.*?)"/);
- var tid = text.match(/PageData.thread([ ]*)=([ ]*){(.*?)thread_id(.*?):(\d+)/);
- config.post.tbs = !tbs1 ? tbs2[6] : tbs1[6];
- config.post.forum_id = !fid ? 0 : fid[4];
- config.post.forum_name = !fe ? '' : decodeUnicode(fe[4]);
- config.post.thread_id = !tid ? 0 : tid[5];
- };
-
- function bindEvent() {
- $('#query').bind('keyup', function(event){
- $('#search_list').show();
- if (event.keyCode != 13) {
- mointorSearch();
- return;
- }
- event.cancelBubble = true;
- event.returnValue = false;
- window.handleSearchResult($(this).val());
- });
- $('#query').bind('click', function(){
- $('#search_list').show();
- mointorSearch();
- });
- $('#search_list').hover(function(){
- $(this).show();
- }, function(){
- $(this).hide();
- });
- };
-
- function parseFooter() {
- var tf = $('#footer').html();
- var fhtml = '<div class="loop-12">' + tf + '</div>';
- return fhtml;
- };
-
- function parseSearch(data) {
- var qms = data.query_match.search_data;
- if (qms.length==0) {
- return '<p>无数据';
- }
- var qhtml = '<ul>';
- for(var i=0; i<qms.length; i++) {
- qhtml += '<li onclick="handleSearchResult("' + qms[i].fname + '")">\
- <div class="sh_forum_name">' + qms[i].fname + '</div>\
- <div class="sh_forum_desc">' + qms[i].forum_desc + '</div>';
- }
- qhtml += '</ul>';
- return qhtml;
- };
-
- function parsePosts(postsDom) {
- var h_posts = postsDom.find('li.j_thread_list');
- var h_paging = postsDom.find('#frs_list_pager');
- var h_cur_page = postsDom.find('#frs_list_pager .cur');
- var h_cur_url = !h_cur_page.length ? '#?' + window.Math.random() : '/f?kw=' + config.posts.forum_name + '&pn=' + (h_cur_page.text()*50-50);
- var ho_pobj = {}, posts_html='';
- posts_html='<div class="span"><div class="loop-12 posts_list"><ul>';
- for(var i=0; i<h_posts.length; i++) {
- var hp = h_posts[i];
- var hp_rep_num = $(hp).find('.threadlist_rep_num')[0].textContent;
- var hp_title = $(hp).find('.j_th_tit')[1].textContent;
- var hp_href = $(hp).find('.j_th_tit')[1].href;
- var hp_detail = !$(hp).find('.threadlist_text')[1] ? '' : $(hp).find('.threadlist_text')[1].textContent;
- var hp_author = !$(hp).find('.j_user_card')[0] ? '' : $(hp).find('.j_user_card')[0].textContent;
- var hp_last_repuser = !$(hp).find('.j_user_card')[1] ? '' : $(hp).find('.j_user_card')[1].textContent;
- var hp_last_time = !$(hp).find('.j_reply_data')[0] ? '' : $(hp).find('.j_reply_data')[0].textContent;
- posts_html += '<li data-href="' + hp_href + '">\
- <div class="span">\
- <div class="loop-10 post_title hidefont" title="' + hp_title + '">' + hp_title + '</div>\
- <div class="loop-2 post_author hidefont" title="' + hp_author + '">' + hp_author + '</div>\
- <div class="loop-12 box_posts_detail">' + hp_detail + '</div>\
- <div class="loop-5 post_repuser hidefont">最后回复人:' + hp_last_repuser + '</div>\
- <div class="loop-5 post_lasttime">最后回复时间:' + hp_last_time + '</div></div>';
- }
- posts_html += '</ul></div>';
- posts_html += '<div class="loop-4 posts_paging">' + (!h_paging.length ? '' : h_paging.html()) + '<a href="' + h_cur_url + '">刷新</a><span id="btn_posting">发帖</span></div></div>';
- return posts_html;
- };
-
-
- function parsePost(postDom) {
- var post_title = postDom.find('.core_title_txt').html()
- var post_info = postDom.find('.l_post');
- var post_content = postDom.find('.p_content cc');
- var author_avatar = postDom.find('.p_author_face img');
- var lzlbox = postDom.find('j_lzl_c_b_a');
- var ppage = postDom.find('.pb_list_pager')[0];
- var post_html = '';
- post_html += '<div class="loop-12 post_title">' + post_title + '</div>';
- for(var i=0; i<post_info.length; i++) {
- var pi = $(post_info[i]).data('field');
- var pc = post_content[i];
- post_html += '<section data-post="' + pi.content.post_id + '" >';
- post_html += '<div class="loop-2 post_info">\
- <div class="loop-12 post_author" data-user="' + pi.author.user_id + '">\
- <div><img src="http://tb.himg.baidu.com/sys/portrait/item/' + pi.author.portrait + '"></div>\
- <span>' + pi.author.user_name + '</span>\
- </div>\
- <div class="loop-12 post_author_level">\
- <span>' + (pi.author.level_name||'*') + '</span>\
- <span>' + (pi.author.level_id||'0') + '</span>\
- </div>\
- </div>';
- post_html += '<div class="loop-10 post_article">' + pc.innerHTML + '</div>';
- post_html += '<div class="loop-10 post_msg"><div class="loop-2 btn_replay_lzl" data-pid="' + pi.content.post_id + '" data-floor="' + pi.content.post_no + '" data-index="' + i + '">楼中楼(' + pi.content.comment_num + ')</div><div class="loop-2">' + pi.content.post_no + '楼</div><div class="loop-2">' + pi.content.date + '</div></div>';
- post_html += '</section>';
- }
- post_html += '<div class="loop-4 post-page">' + ppage.innerHTML + '<span id="post_replay">回复</span><span id="see_lz">楼主模式</span></div>';
- post_html += '<div class="loop-4 post-url"><span>' + config.post.page_url + '</span></div>';
- post_html='<div class="span box_post">' +post_html+ '</div>';
- return post_html;
- };
-
- function parsePostLzl(data) {
- var lzlhtml = '<div class="box_lzl"><ul>';
- for(var i=0; i<data.length; i++) {
- var lzlinfo = $(data[i]).data('field');
- var lzltext = $(data[i]).find('.lzl_cnt span.lzl_content_main').html();
- var lzltime = $(data[i]).find('.lzl_cnt span.lzl_time').html();
- if (!lzlinfo.spid) {
- break;
- }
- lzlhtml += '<li id="lzl-'+lzlinfo.spid+'">\
- <div class="span">\
- <div class="loop-4 lzl_author">' + lzlinfo.user_name + '</div>\
- <div class="loop-8 lzl_cnt">' + lzltext + '</div>\
- <div class="loop-12 lzl_info">\
- <span>' + lzltime + '</span>\
- <span class="btn_lzl_replay" data-spid="' + lzlinfo.spid + '" data-author="' + lzlinfo.user_name + '">回复</span></div>\
- </div>\
- <div id="box_lzl_rep-' + lzlinfo.spid + '"></div>';
- }
- lzlhtml += '</ul>';
- lzlhtml += '<div class="span">\
- <div class="loop-12">\
- <span class="btn_lzl_replay" data-spid="1">回复</span></div>\
- </div>\
- </div>\
- <div id="box_lzl_rep-1"></div>';
- var lzlp = $(data[data.length-1]).find('.j_pager');
- lzlhtml += !lzlp.length ? '' : '<div class="loop-12 lzl-page">' + lzlp.html() + '</div>';
- lzlhtml += '</div>';
- return lzlhtml;
- };
-
-
- function executePosting(title, content){
- $.ajax({
- url: config.posts.handle_url,
- type: 'post',
- data: {
- content: content,
- fid: config.posts.forum_id,
- floor_num: config.posts.floor_num,
- ie: 'utf-8',
- kw: config.posts.forum_name,
- rich_text: 1,
- tbs: config.posts.tbs,
- tid: 0,
- title: title,
- vcode: config.captcha.input,
- vcode_md5: config.captcha.code
- },
- dataType: 'json'
- }).done(function(data){
- parsePosting(data);
- });
- };
-
-
- function executPostReplay(content) {
- $.ajax({
- url: config.post.handle_url,
- type: 'post',
- data: {
- kw: config.post.forum_name,
- ie: 'utf-8',
- rich_text: 1,
- floor_num: config.post.floor_num,
- fid: config.post.forum_id,
- tid: config.post.thread_id,
- content: content,
- anonymous: 0,
- tbs: config.post.tbs,
- vcode_md5: config.captcha.code,
- vcode: config.captcha.input
- },
- dataType: 'json'
- }).done(function(data){
- parsePostReplay(data);
- });
- };
-
- function parsePosting(data) {
- if (!data.no) {
- handleGetPosts(config.posts.page_url);
- $('.tba-modal').omniWindow().trigger('hide');
- return;
- }
- var vhtml = '', da = data.data;
- var captHtml = parsePostCaptcha(da);
- if (!captHtml) {
- return;
- }
- $('#modal_other').html(captHtml);
- mointorCaptcha();
- };
-
- function parsePostReplay(data) {
- if (!data.no) {
- handleGetPost(config.post.page_url);
- $('.tba-modal').omniWindow().trigger('hide');
- return;
- }
- var vhtml = '', da = data.data;
- var captHtml = parsePostCaptcha(da);
- if (!captHtml) {
- return;
- }
- $('#modal_other').html(captHtml);
- mointorCaptcha();
- };
-
- function parseLzlReplay(data, mark) {
- if (!data.no) {
- handleGetLzlReplay();
- return;
- }
- var vhtml = '', da = data.data;
- var captHtml = parsePostCaptcha(da);
- if (!captHtml) {
- return;
- }
- $('.lzl_replay_other').html(captHtml);
- mointorCaptcha();
- };
-
- function parsePostCaptcha(data) {
- config.captcha.value = [];
- var vhtml = '';
- if (!data.vcode.need_vcode) {
- return null;
- }
- config.captcha.code = data.vcode.captcha_vcode_str;
- config.captcha.type = data.vcode.captcha_code_type;
- var img = config.captcha.url4 + '?' + data.vcode.captcha_vcode_str;
- vhtml += '<div class="box_captcha">';
- vhtml += '<div class="loop-12 captcha"><img src="' + img + '"></div>';
- vhtml += '<div class="loop-12 captcha-input">\
- <input type="checkbox" class="cait cait-1" data-index="1" value="00000000">\
- <input type="checkbox" class="cait cait-2" data-index="2" value="00010000">\
- <input type="checkbox" class="cait cait-3" data-index="3" value="00020000">\
- <input type="checkbox" class="cait cait-4" data-index="4" value="00000001">\
- <input type="checkbox" class="cait cait-5" data-index="5" value="00010001">\
- <input type="checkbox" class="cait cait-6" data-index="6" value="00020001">\
- <input type="checkbox" class="cait cait-7" data-index="7" value="00000002">\
- <input type="checkbox" class="cait cait-8" data-index="8" value="00010002">\
- <input type="checkbox" class="cait cait-9" data-index="9" value="00020002">\
- </div>';
- // vhtml += '<div class="loop-12"><button type="button" id="btn_refre_captcha">换一张</button></div>';
- vhtml += '<div class="loop-12"><div class="loop-10" id="captchackr"></div><div class="loop-2" id="delcaptchar">X</div></div>';
- vhtml += '<div class="loop-12" id="post-result"></div>';
- vhtml += '</div>';
- return vhtml;
- };
-
- function mointorCaptcha() {
- $('.cait').bind('click', function(){
- if (config.captcha.value.length<4) {
- $(this).prop({disabled: true});
- config.captcha.value.push({val: $(this).val(), index: $(this).data('index')});
- $('#captchackr').append('<span id="checkcaptchar-' + $(this).data('index') + '">' + $(this).data('index') + '</span>');
- if (config.captcha.value.length==4) {
- var captVal = '';
- for(var i=0; i<config.captcha.value.length; i++) {
- captVal += config.captcha.value[i].val;
- }
- config.captcha.input = captVal;
- }
- return;
- }
- });
- $('#delcaptchar').bind('click', function(){
- for(var i=0; i<config.captcha.value.length; i++) {
- if ((i+1)==config.captcha.value.length) {
- $('#checkcaptchar-' + config.captcha.value[i].index).remove();
- $('.cait-' + config.captcha.value[i].index).prop({disabled: false, checked: false});
- config.captcha.value.remove((i+1));
- }
- }
- });
- /*
- $('#btn_refre_captcha').bind('click', function(){
- // $('#btn_post').click();
- });
- */
- };
-
- function loadFile(filename,filetype){
- if ('js' == filetype) {
- var fileref = document.createElement('script');
- fileref.setAttribute("type","text/javascript");
- fileref.setAttribute("src",filename);
- }
- if ('css' == filetype) {
- var fileref = document.createElement('link');
- fileref.setAttribute("rel","stylesheet");
- fileref.setAttribute("type","text/css");
- fileref.setAttribute("href",filename);
- }
- if(typeof fileref != "undefined"){
- document.getElementsByTagName("head")[0].appendChild(fileref);
- }
- };
-
- function encodeUnicode(str){
- return escape(str).toLocaleLowerCase().replace(/%u/gi,'\\u');
- };
-
- function decodeUnicode(str){
- return unescape(str.replace(/\\u/gi,'%u'));
- };
-
- function formatEditor(content) {
- return content.replace(/<p>|<br\/>/gi, '').replace(/<\/p>/gi, '[br]').replace(/_src=".*?"/gi, 'class="BDE_Smiley"');
- };
-
- initBorer();
- })(window, jQuery);