📄 ftb-pro.js
字号:
/* Color picker Functions
-------------------------------------- */
FTB_FreeTextBox.prototype.FontForeColorPicker = function() {
this.LaunchColorPickerWindow('forecolor');
}
FTB_FreeTextBox.prototype.FontBackColorPicker = function() {
this.LaunchColorPickerWindow('backcolor');
}
var cname = null;
FTB_FreeTextBox.prototype.LaunchColorPickerWindow = function(commandName, startValue) {
//for(var i = 0;i < 3;i++;)
{
linkWin = window.open("","colorPickerWin","width=290,height=180");
}
if (linkWin) {
linkWin.focus();
} else {
alert(messages[6][this.language]);
return;
}
cname = commandName;
ftb = this;//WordClean
//alert(pickerWin.innerHTML);
setTimeout("LaunchColorPickerWindow1()",500)
}
function LaunchColorPickerWindow1()
{
linkWin.document.body.innerHTML = '';
linkWin.document.open();
linkWin.document.write(FTB_ColorPickerHtml);
linkWin.document.close();
launchParameters = new Object();
launchParameters['ftb'] = ftb;
launchParameters['commandName'] = cname;
linkWin.launchParameters = launchParameters;
linkWin.load();
}
FTB_FreeTextBox.prototype.InsertImage = function() {
var imageWin = window.open("","imageWin","width=500,height=310");
if (imageWin) {
imageWin.focus();
} else {
alert(messages[6][this.language]);
return;
}
//imageWin.document.body.innerHTML = '';
imageWin.document.open();
imageWin.document.write(FTB_ImagePopUpHtml);
imageWin.document.close();
launchParameters = new Object();
launchParameters['ftb'] = this;
imageWin.launchParameters = launchParameters;
imageWin.load();
}
/* Misc Pro features
--------------------------------------- */
FTB_FreeTextBox.prototype.WordClean = function() {
// 0bject based cleaning
// var body = this.designEditor.document.body;
// for (var index = 0; index < body.all.length; index++) {
// tag = body.all[index];
// //if (tag.Attribute["className"].indexOf("mso") > -1)
// tag.removeAttribute("className","",0);
// tag.removeAttribute("style","",0);
// }
// // Regex based cleaning
// var html = editor.document.body.innerHTML;
// html = html.replace(/<o:p> <\/o:p>/g, "");
// html = html.replace(/o:/g, "");
// html = html.replace(/<st1:.*?>/g, "");
// // Final clean up of empty tags
// html = html.replace(/<font>/g, "");
// html = html.replace(/<span>/g, "");
//
// this.designEditor.document.body.innerHTML = html;
var text = this.designEditor.document.body.innerHTML;
text=text.replace(/<FONT[^>]*>/gi,"");
text=text.replace(/<\/FONT>/gi,"");
text=text.replace(/<U>/gi,"");
text=text.replace(/<\/U>/gi,"");
text=text.replace(/<H[^>]*>/gi,"");
text=text.replace(/<\/H[^>]*>/gi,"");
// Change these tags.
text=text.replace(/<B[^>]*>/gi,"&bold");
text=text.replace(/<\/B[^>]*>/gi,"&cbold");
text=text.replace(/<STRONG[^>]*>/gi,"&bold");
text=text.replace(/<\/STRONG[^>]*>/gi,"&cbold");
text=text.replace(/<I[^>]*>/gi,"&ital");
text=text.replace(/<\/I[^>]*>/gi,"&cital");
text=text.replace(/<EM[^>]*>/gi,"&ital");
text=text.replace(/<\/EM[^>]*>/gi,"&cital");
text=text.replace(/<UL[^>]*>/gi,"&ultag");
text=text.replace(/<LI[^>]*>/gi,"&litag");
text=text.replace(/<OL[^>]*>/gi,"&oltag");
text=text.replace(/<\/OL>/gi,"&olctag");
text=text.replace(/<\/LI>/gi,"&lictag");
text=text.replace(/<\/UL>/gi,"&ulctag");
text=text.replace(/<P[^>]*>/gi,"¶g");
text=text.replace(/<\/P>/gi,"");
/*
text=text.replace(/?gi,'\"');
text=text.replace(/?gi,'\"');
text=text.replace(/?gi,'\"');
text=text.replace(/mailto:/gi,'\"');
text=text.replace(/?g,"Ä");
text=text.replace(/?g,"Ö");
text=text.replace(/?g,"Ü");
text=text.replace(/?g,"ä");
text=text.replace(/?g,"ö");
text=text.replace(/?g,"ü");
text=text.replace(/?gi,"ß");
*/
text=text.replace(/<[^>]>*;/gi,"");
text=text.replace(/<\/[^>]>*;/gi," ");
text=text.replace(/<o:[^>]*>/gi,"");
text=text.replace(/<\/o:[^>]*>/gi,"");
text=text.replace(/<\?xml:[^>]*>/gi,"");
text=text.replace(/<\/?st[^>]*>/gi,"");
//text=text.replace(/<[^>]*</gi,"<");
text=text.replace(/<SPAN[^>]*>/gi,"");
text=text.replace(/<SPAN[^class]*>/gi,"");
text=text.replace(/<\/SPAN>/gi,"");
//text=text.replace(/<\/A>/gi,"");
// Clear the inner parts of other tags.
text=text.replace(/style=[^>]*"/g,' ');
text=text.replace(/style=[^>]*'/g," ");
text=text.replace(/style=[^>]*>/g,">");
text=text.replace(/lang=[^>]*>/g,">");
text=text.replace(/name=[^>]* /g,"");
text=text.replace(/name=[^>]*>/g,">");
text=text.replace(/<A[^>]*>/g,"");
//text=text.replace(/<p[^>]*>/gi,"<p>");
// Put the tags back
text=text.replace(/&bold/g,"<B>");
text=text.replace(/&cbold/g,"</B>");
text=text.replace(/&ital/g,"<EM>");
text=text.replace(/&cital/g,"</EM>");
text=text.replace(/&ultag/g,"<UL>");
text=text.replace(/&litag/g,"<LI>");
text=text.replace(/&oltag/g,"<OL>");
text=text.replace(/&olctag/g,"<\/OL>");
text=text.replace(/&lictag/g,"<\/LI>");
text=text.replace(/&ulctag/g,"<\/UL>");
text=text.replace(/¶g/g,"<BR>");
this.designEditor.document.body.innerHTML = text;
}
FTB_FreeTextBox.prototype.CreateLink = function() {
// impliment pro feature of PopUp window
linkWin = window.open("","linkWin","width=350,height=155");
if (linkWin) {
linkWin.focus();
} else {
alert(messages[6][this.language]);
return;
}
ftb = this;
setTimeout("CreateLink1()",500)
}
function CreateLink1()
{
linkWin.document.body.innerHTML = '';
linkWin.document.open();
linkWin.document.write(FTB_LinkPopUpHtml);
linkWin.document.close();
launchParameters = new Object();
launchParameters['ftb'] = ftb;
linkWin.launchParameters = launchParameters;
linkWin.load();
}
/* PopUpScripts
---------------------------------------- */
var FTB_ImagePopUpHtml = new String("\
<html><body> \
<head>\
<title>Image Editor</title>\
<style type='text/css'>\
html, body { \
background-color: #ECE9D8; \
color: #000000; \
font: 11px Tahoma,Verdana,sans-serif; \
padding: 0px; \
} \
body { margin: 5px; } \
form { margin: 0px; padding: 0px;} \
table { \
font: 11px Tahoma,Verdana,sans-serif; \
} \
form p { \
margin-top: 5px; \
margin-bottom: 5px; \
} \
h3 { margin: 0; margin-top: 4px; margin-bottom: 5px; font-size: 12px; border-bottom: 2px solid #90A8F0; color: #90A8F0;} \
.fl { width: 9em; float: left; padding: 2px 5px; text-align: right; } \
.fr { width: 7em; float: left; padding: 2px 5px; text-align: right; } \
fieldset { padding: 0px 10px 5px 5px; } \
button { width: 75px; } \
select, input, button { font: 11px Tahoma,Verdana,sans-serif; } \
.space { padding: 2px; } \
.title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; \
border-bottom: 1px solid black; letter-spacing: 2px; \
} \
.f_title { text-align:right; }\
.footer { border-top:2px solid #90A8F0; padding-top: 3px; margin-top: 4px; text-align:right; }\</style>\
<script type='text/javascript'>\
function updateImage() {\
ftb = window.launchParameters['ftb'];\
img = ftb.GetNearest('img');\
src = document.getElementById('image_src');\
if (src.value == '') {\
alert('You must enter an image url');\
return false;\
}\
if (!img) {\
ftb.ExecuteCommand('insertimage',null,src.value);\
img = ftb.GetNearest('a');\
}\
updateImageProperties(img);\
}\
function updateImageProperties(img) {\
if (img) {\
src = document.getElementById('image_src');\
alt = document.getElementById('image_alt');\
align = document.getElementById('image_align');\
border = document.getElementById('image_border');\
hspace = document.getElementById('image_hspace');\
vspace = document.getElementById('image_vspace');\
width = document.getElementById('image_width');\
height = document.getElementById('image_height');\
img.src = src.value;\
img.alt = alt.value;\
img.align = align.value;\
img.border = border.value;\
img.hspace = hspace.value;\
img.vspace = vspace.value;\
img.width = width.value;\
img.height = height.value;\
}\
}\
function updatePreview() {\
src = document.getElementById('image_src');\
alt = document.getElementById('image_alt');\
align = document.getElementById('image_align');\
border = document.getElementById('image_border');\
hspace = document.getElementById('image_hspace');\
vspace = document.getElementById('image_vspace');\
preview = document.getElementById('preview');\
width = document.getElementById('image_width');\
height = document.getElementById('image_height');\
\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -