当前位置:首页 > 教育 > 正文

转帖工具(放到首页左栏随时调用)

本人制作的这个转帖工具的代码: ---------------------------------------------------------------------------------------------------------------------------------
DLLC 1234自制转帖工具

















');

str = str.replace(/\[b\]([\s\S]*?)\[\/b\]/ig, "$1").replace(/\[u\]([\s\S]*?)\[\/u\]/ig, "$1").replace(/\[i\]([\s\S]*?)\[\/i\]/ig, "$1");

str = str.replace(/\[align=center\]([\s\S]*?)\[\/align\]/ig, '
$1
');

str = str.replace(/\n/ig, "\n
");

return (str);

}



function cuturl(url){

var length = 65;

var urllink = ' ';

if(url.length > length) {

url = url.substr(0, parseInt(length * 0.5)) + ' ... ' + url.substr(url.length - parseInt(length * 0.3));

}

urllink += url + '
';

return urllink;

}



function switch_Edt(m){

if(m == Editor_Mode) return;



var ubb='', html='', obj;

if(Editor_Mode == 0){

ubb = $('UBB_Editor').value;

$('UBB_Editor').style.display = "none";

$('UBB_btn').className = "normal";

}else if(Editor_Mode == 1){

html = $('HTML_Editor').value;

$('HTML_Editor').style.display = "none";

$('HTML_btn').className = "normal";

}else{

html = $('Visual_Editor').contentWindow.document.body.innerHTML;

$('Visual_Editor').style.display = "none";

$('Visual_btn').className = "normal";

}



if(m == 0){

if(ubb=='') ubb = html2ubb(html);

$('UBB_Editor').style.display = "block";

$('UBB_btn').className = "current";

obj = $('UBB_Editor');

obj.value = ubb;

$('dupBtn').style.display = "inline";

$('enB64').style.visibility = "visible";

$('deB64').style.visibility = "visible";

$('pic_filter').style.visibility = "hidden";

}else if(m == 1){

if(html=='') html = ubb2html(ubb);

else html = html.replace(/]*?>/ig, "\n
");

$('HTML_Editor').style.display = "block";

$('HTML_btn').className = "current";

obj = $('HTML_Editor');

obj.value = html;

$('dupBtn').style.display = "none";

$('enB64').style.visibility = "hidden";

$('deB64').style.visibility = "hidden";

$('pic_filter').style.visibility = "hidden";

}else{

if(html=='') html = ubb2html(ubb);

$('Visual_Editor').style.display = "block";

$('Visual_btn').className = "current";

obj = $('Visual_Editor').contentWindow.document.body;

obj.innerHTML = html;

$('dupBtn').style.display = "none";

$('enB64').style.visibility = "hidden";

$('deB64').style.visibility = "hidden";

$('pic_filter').style.visibility = "visible";

}

Editor_Mode = m;

focusAtEnd(obj);

sum_word();

}



function focusAtEnd(obj){

obj.focus();

if(Editor_Mode==2){

var sel = obj.ownerDocument.selection.createRange();

var str = obj.innerHTML;

}else{

var sel = obj.createTextRange();

var str = obj.value;

}

var len = (str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;

sel.moveStart('character', len);

sel.collapse();

sel.select();

}



function copycode(){

var obj;

if(Editor_Mode==2){

obj = $('Visual_Editor').contentWindow.document.body;

}else{

obj = (Editor_Mode==0) ? 'UBB_Editor' : 'HTML_Editor';

obj = $(obj);

obj.select();

}

obj.createTextRange().execCommand("Copy")

}



function transData(){

var str = "";

$('rtf').contentWindow.focus();

$('rtf').contentWindow.document.body.innerHTML = '';

$('rtf').contentWindow.document.execCommand("paste");

str = $('rtf').contentWindow.document.body.innerHTML;

if(str.length == 0) {

alert("剪贴板不存在超文本数据!");

return "";

}

str = (Editor_Mode==0) ? html2ubb(filter_html(str)) : filter_html(str);

return str;

}



function trans(){

if(Editor_Mode==0){

$('UBB_Editor').value = transData();

}else if(Editor_Mode==1){

$('HTML_Editor').value = transData();

}else{

$('Visual_Editor').contentWindow.document.body.innerHTML = transData();

}

sum_word();

}



function trans2(){

if(Editor_Mode==0){

$('UBB_Editor').value += "\r\n\r\n" + transData();

}else if(Editor_Mode==1){

$('HTML_Editor').value += "\r\n
\r\n
" + transData();

}else{

$('Visual_Editor').contentWindow.document.body.innerHTML += "

" + transData();

}

sum_word();

}



function preview(){

var html;

if(Editor_Mode == 0){

html = ubb2html($("UBB_Editor").value);

}else if(Editor_Mode == 1){

html = $("HTML_Editor").value;

}else{

html = $("Visual_Editor").contentWindow.document.body.innerHTML;

}

var nWin = window.open("", "_blank");

nWin.document.write(html);

nWin.document.close();

}



function clearEdt(){

if(Editor_Mode == 0){

$("UBB_Editor").value = "";

}else if(Editor_Mode == 1){

$("HTML_Editor").value = "";

}else{

$("Visual_Editor").contentWindow.document.body.innerHTML = "";

}

$("words").innerHTML = "0";

}



function zhen(str){

strfound = str.replace(/\\/ig,"\\\\");

strfound = strfound.replace(/\[/ig,"\\[");

strfound = strfound.replace(/\]/ig,"\\]");

strfound = strfound.replace(/\{/ig,"\\{");

strfound = strfound.replace(/\}/ig,"\\}");

strfound = strfound.replace(/\|/ig,"\\|");

strfound = strfound.replace(/\//ig,"\\/");

strfound = strfound.replace(/\^/ig,"\\^");

strfound = strfound.replace(/\./ig,"\\.");

strfound = strfound.replace(/\*/ig,"\\*");

strfound = strfound.replace(/\?/ig,"\\?");

strfound = strfound.replace(/\+/ig,"\\+");

return strfound;

}



function replace_star(){

var str;

if(Editor_Mode == 0){

str = $("UBB_Editor").value;

}else if(Editor_Mode == 1){

str = $("HTML_Editor").value;

}else{

str = $("Visual_Editor").contentWindow.document.body.innerHTML;

}

var strfound = (reg.checked) ? $('find_text').value : zhen($('find_text').value) ;

var re = new RegExp(strfound, "ig");

str = str.replace(re, $("replace_text").value);

if(Editor_Mode == 0){

$("UBB_Editor").value = str;

}else if(Editor_Mode == 1){

$("HTML_Editor").value = str;

}else{

$("Visual_Editor").contentWindow.document.body.innerHTML = str;

}

sum_word();

}



function font_checker(obj){

var o = $('set').font_all;

if(! obj.checked && o.checked)

o.checked = false;

}



function pasteData(){

if(!$('x_paste').checked) return true;

if(Editor_Mode==2){

var str = transData();

$('rtf').contentWindow.document.body.innerHTML = str;

$('rtf').contentWindow.focus();

$('rtf').contentWindow.document.body.createTextRange().execCommand("Copy");

}else{

clipboardData.setData('text',transData());

}

return true;

}



function attPasteEvt(){

$('Visual_Editor').contentWindow.document.body.onpaste = pasteData;

$('Visual_Editor').onload = null;

}



function filter_Font(Obj){

Obj = Obj.checked;

$('font_color').checked = Obj;

$('font_size').checked = Obj;

$('font_face').checked = Obj;

$('font_b').checked = Obj;

$('font_i').checked = Obj;

$('font_u').checked = Obj;

}



function fltBaseUrl(){

if($('filtrate').checked)

$('base_url').style.display = 'block';

else

$('base_url').style.display = 'none';

}



function clearBaseUrl(){

$('textfield').value = '';

}



function reset(){

$('set').reset();

fltBaseUrl();

$('find_text').value = '';

$('replace_text').value = '';

$('textfield').value = '';

}



function configTip(msg){

var e;

try{

clearTimeout(Timer);

}catch(e){}

$('config_tip').innerHTML = msg;

Timer = setTimeout('$("config_tip").innerHTML=""', 1000);

}



function Simplized(){

var obj;

if(Editor_Mode==0){

obj = $('UBB_Editor');

obj.value = convJT(obj.value);

}else if(Editor_Mode==1){

obj = $('HTML_Editor');

obj.value = convJT(obj.value);

}else{

obj = $('Visual_Editor').contentWindow.document.body;

StranBody(obj, 0);

}

}



function Traditionalized(){

var obj;

if(Editor_Mode==0){

obj = $('UBB_Editor');

obj.value = convFT(obj.value);

}else if(Editor_Mode==1){

obj = $('HTML_Editor');

obj.value = convFT(obj.value);

}else{

obj = $('Visual_Editor').contentWindow.document.body;

StranBody(obj, 1);

}

}



function QQ90sized(){

var obj;

if(Editor_Mode==0){

obj = $('UBB_Editor');

obj.value = convQQ(obj.value);

}else if(Editor_Mode==1){

obj = $('HTML_Editor');

obj.value = convQQ(obj.value);

}else{

obj = $('Visual_Editor').contentWindow.document.body;

StranBody(obj, 2);

}

}



function noDuplicate(){

var o = $("UBB_Editor");

var ary = o.value.replace(/^\s*|\s*$/g, "").split("\r\n");

var re = {};

var str = "", s;

for(var i = 0, len = ary.length, j = 0; i < len; i++){

s = ary[i];

if(s == ""){

str += "\r\n";

j++;

}else{

if(!re[s]){

re[s] = true;

str += s +"\r\n";

j++;

}

}

}

str = str.substr(0, str.length-2);

o.value = str;

configTip(len + "->" + j);

sum_word();

}



function decodeBase64(){

var o = $("UBB_Editor");

o.value = base64decode(o.value);

sum_word();

}



function encodeBase64(){

var o = $("UBB_Editor");

o.value = base64encode(o.value);

sum_word();

}



function moreTool(){

$('advTool').style.display = ($('advTool').style.display=="block") ? "none" : "block";

}



function sum_word(){

var s;

if(Editor_Mode == 0){

s = $("UBB_Editor").value.length;

}else if(Editor_Mode == 1){

s = $("HTML_Editor").value.length;

}else{

s = $("Visual_Editor").contentWindow.document.body.innerHTML.length;

}

$("words").innerHTML = ""+s;

}



function init(){

$('rtf').contentWindow.document.designMode = "On";

$('Visual_Editor').contentWindow.document.designMode = "On";

$('set').reset();

}



if(window.addEventListener){

window.addEventListener('load', init, false);

}else{

window.attachEvent('onload', init);

}









DLLC1234转帖工具






字符数: 0


















































JS 压缩




输入图片的基本地址:


如果未指定基本地址, 则将自动取第一张图片的位置做基本地址. 基本地址是指除文件名外的网络路径.
如图片地址为: http://www.maxthon.com/images/logo.png , 则除去图片文件名 logo.png 后基本地址为: http://www.maxthon.com/images/



你可能想看:

有话要说...

最新文章

取消
扫码支持 支付码