📄 add_info.asp
字号:
//only change the view if it is different than the current state
if (isSrcView && !this.isSrcView){
this.isSrcView = true;
this.setToolbarsVisible(false);
if (document.all) {
oRTE.body.innerText = oRTE.body.innerHTML;
} else {
var htmlSrc = oRTE.createTextNode(oRTE.body.innerHTML);
oRTE.body.innerHTML = "";
oRTE.body.appendChild(htmlSrc);
}
}else if(!isSrcView && this.isSrcView){
this.isSrcView = false;
this.setToolbarsVisible(true);
if (document.all) {
oRTE.body.innerHTML = oRTE.body.innerText;
} else {
var htmlSrc = oRTE.body.ownerDocument.createRange();
htmlSrc.selectNodeContents(oRTE.body);
oRTE.body.innerHTML = htmlSrc.toString();
}
}
}
this.toggleHTMLSrc = function(){
//alert("this.toggleHTMLSrc");
if (document.getElementById("chkSrc" + this.name).checked) {
this.setViewMode(true);
} else {
this.setViewMode(false);
}
}
//TODO would really like to be able to plug functionality in here.
//This would include the ability to launch a wizard, and then insert arbitrary text at the insertion point
this.formatText = function (command,option){
//alert("this.formatText");
//所有与文字处理有关的功能都会调用此方法,在这个方法里面可以添加相关的新功能
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if ((command == "forecolor") || (command == "backcolor")) {
this.command = command;
controlElement = document.getElementById(this.name +"_" + command);
//获得颜色选择窗口
cp = document.getElementById('cp' + this.name);
this.cpWindow.area = this;
cp.style.left = getOffsetLeft(controlElement) + "px";
cp.style.top = (getOffsetTop(controlElement) + controlElement.offsetHeight) + "px";
if (cp.style.visibility == "hidden") {
//打开颜色选择窗口
cp.style.visibility="visible";
} else {
cp.style.visibility="hidden";
}
//get current selected range
var sel = oRTE.document.selection;
if (sel != null) {
this.rng = sel.createRange();
//alert(this.rng.text);
}
} else if (command == "createlink") {
//TODO need a way to make this more flixible.
//Would especially like to be able to insert a link with both the containing text and the URL
var szURL = prompt("Enter a URL:", "");
oRTE.document.execCommand("Unlink",false,null)
oRTE.document.execCommand("CreateLink",false,szURL)
} else if (command == 'paste') {
oRTE.focus();
oRTE.document.execCommand(command);
oRTE.focus();
} else {
oRTE.focus();
oRTE.document.execCommand(command, false, option);
oRTE.focus();
}
}
this.setColor = function(color){
//选择前景色与背景色时调用
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if (document.all) {
//得到选定矩形
var sel = oRTE.document.selection;
if (sel != null) {
var newRng = sel.createRange();
newRng = this.rng;
newRng.select();
}
} else {
oRTE.focus();
}
//设置文本前景或背景颜色
oRTE.document.execCommand(this.command, false, color);
oRTE.focus();
//关闭颜色选择窗口
document.getElementById('cp' + this.name).style.visibility = "hidden";
}
this.addImage = function(imagePath){
//alert("this.addImage");
HyperTextArea.activeArea = this;
if(!imagePath){
imagePath = prompt('Enter Image URL:', 'http://');
}
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
if ((imagePath != null) && (imagePath != "")) {
oRTE.focus()
oRTE.document.execCommand('InsertImage', false, imagePath);
}
oRTE.focus()
}
//TODO should look into ways to make this cross browser and platform
this.checkspell = function(){
//alert("this.checkspell");
try {
var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
tmpis.CheckAllLinkedDocuments(document);
}
catch(exception) {
if(exception.number==-2146827859) {
if (confirm("ieSpell not detected. Click OK to go to download page."))
window.open("http://www.iespell.com/download.php","DownLoad");
} else {
alert("Error Loading ieSpell: Exception " + exception.number);
}
}
}
this.select = function(menu,cmd){
//alert("this.select");
HyperTextArea.activeArea = this;
var oRTE;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
var idx = menu.selectedIndex;
// First one is always a label
if (idx != 0) {
var selected = menu.options[idx].value;
oRTE.document.execCommand(cmd, false, selected);
menu.selectedIndex = 0;
}
oRTE.focus();
}
//用于插入表格地弹出窗口
this.insertTableDialog = function(){
w = window.open("","tableDialog","top=300,left=300,width=300,height=150");
w.area = this;
d = w.document;
d.open();
d.write(getTableDialogAsString());
d.close();
}
this.insertTable = function(rows,cols,spacing,padding,border){
rows = rows||3;
cols = cols||3;
spacing = spacing||2;
padding = padding||2;
if(border == true){
border = 1;
}
border = border||0;
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
doc = oRTE.document;
table = doc.createElement("table");
table.setAttribute("border", border);
table.setAttribute("cellpadding", padding);
table.setAttribute("cellspacing", spacing);
table.setAttribute("class", "hyperTable");
for (var i=0; i < rows; i++) {
var tr = doc.createElement("tr");
for (var j=0; j < cols; j++) {
var td = doc.createElement("td");
var content = doc.createTextNode('\u00a0');
td.appendChild(content);
tr.appendChild(td);
}
table.appendChild(tr);
}
this.insertElement(table);
}
this.insertElement = function(el){
if (document.all) {
oRTE = frames[this.name];
} else {
oRTE = document.getElementById(this.name).contentWindow;
}
doc = oRTE.document;
if (document.all) {
selection = doc.selection;
var html = el.outerHTML;
var range = selection.createRange();
try {
range.pasteHTML(html);
} catch (e) {
// catch error when range is evil for IE
}
}else{
selection = oRTE.getSelection();
var range = selection.getRangeAt(0);
selection.removeAllRanges();
range.deleteContents();
var container = range.startContainer||selection.focusNode;
var pos = range.startOffset;
afterNode = container.childNodes[pos];
try{
container.insertBefore(el, container.afterNode);
}catch (e){
//if this is a text node, then break it up into a text node, new element, text node
if(container.nodeName.toLowerCase() == "#text"){
text0 = container.data.substring(0,range.startOffset);
text1 = container.data.substring(range.startOffset,container.data.length-1);
container.data = text0;
parent = container.parentNode;
parent.insertBefore(el,container.nextSibling);
newTextNode = document.createTextNode(text1);
parent.insertBefore(newTextNode,el.nextSibling);
}else {
alert(el.nodeName.toLowerCase() + " cannot be placed here for the following reason:\n\n" + e);
}
}
}
}
this.init();
if(!this.delayRender){
this.render(this.html);
}
}
function TextFormatButton(name,label,icon,command,option){
this.name = name;
this.label = label;
this.icon = icon;
this.command = command;
this.option = option||"";
//the next two values are set by the HyperTextArea object
this.area = null;
this.resourcePath = null;
this.getRenderedText = function(){
text = '<td><div id="'+this.area.name+'_'+this.name+'">'
text = text + '<img class="btnImage" src="'+this.resourcePath+this.icon+'" width="25" height="24" alt="'+this.label+'" title="'+this.label+'" onClick="HyperTextArea.getArea(\''+ this.area.name +'\').getControl(\''+this.name+'\').execute()">';
text = text + '</div></td>';
return text;
}
this.execute = function(){
this.area.formatText(this.command,this.option);
}
}
function Button(name,icon,title,methodName){
this.name=name;
this.getRenderedText = function(){
text = '<td><div id="'+name+'">'
text = text + '<img class="btnImage" src="'+this.resourcePath+icon+'" width="25" height="24" alt="'+title+'" title="'+title+'" onClick="HyperTextArea.getArea(\''+ this.area.name +'\').'+methodName+'()">';
text = text + '</div></td>';
return text;
}
}
function Spacer(name){
this.name = name
this.getRenderedText = function(){
return '<td> </td>'
}
}
function Toolbar(name, isFirstToolbar){
this.name = name
this.isFirstToolbar = isFirstToolbar||false;
this.getRenderedText = function(){
this.area.toolbarNames[this.area.toolbarNames.length] = this.name;
text = '<table id="' + this.name + '_' + this.area.name + '" cellpadding="1" cellspacing="0"><tr>'
if(this.isFirstToolbar){
text = '</tr></table>\n' + text;
}
return text;
}
}
function Menu(name,cmd){
this.name = name;
this.cmd = cmd;
this.area = null;
this.items = new Array();
this.addItem = function(value,lable){
this.items[this.items.length] = new MenuItem(value,lable);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -