📄 enc_functions.js
字号:
} else {
if (editModeOn == true)
{
pasteButtonOff.style.display = "inline"
pasteButtonOn.style.display = "none"
pasteDropOff.style.display = "inline"
pasteDropOn.style.display = "none"
} else {
pasteButton2Off.style.display = "inline"
pasteButton2On.style.display = "none"
}
}
}
function applyStyle(styleValue) {
if (isAllowed())
{
var done
var selectedArea = foo.document.selection.createRange()
if (styleValue != "") {
styleValue = styleValue.substring(1, styleValue.length)
}
if (foo.document.selection.type == "Control") {
applyStyleTo = selectedArea.commonParentElement()
} else {
if (foo.document.selection.createRange().htmlText == "") {
applyStyleTo = selectedArea.parentElement()
} else {
if ((selectedArea.parentElement().tagName.toUpperCase() == "SPAN") || (selectedArea.parentElement().tagName.toUpperCase() == "A")) {
applyStyleTo = selectedArea.parentElement()
if ((styleValue == "") && (selectedArea.parentElement().tagName.toUpperCase() == "SPAN")) {
applyStyleTo.removeNode(false);
done = true
}
} else {
if (styleValue != "") {
selectedArea.pasteHTML("<span class=" + styleValue + ">" + selectedArea.htmlText + "</span>")
}
done = true
}
}
}
if (done != true) {
applyStyleTo.className = styleValue
}
doToolbar()
}
}
function displayUserStyles() {
var theStyle = new Array();
var theStyleText = new Array();
var styleExists
noOfSheets = fooStyles.document.styleSheets.length
if (noOfSheets > 0) {
for (i=1;i<=noOfSheets;i++) {
noOfStyles = fooStyles.document.styleSheets(noOfSheets-1).rules.length
for (x=0;x<noOfStyles;x++){
styleValue = fooStyles.document.styleSheets(noOfSheets-1).rules(x).selectorText
// stylesheet rule contains a . (ignore any styles that dont contain a . they are NOT user styles)
if (styleValue.indexOf(".") >= 0) {
// stylesheet rule doesnt contain :
if (styleValue.indexOf(":") < 0) {
// style contains a . at beginning
if (styleValue.indexOf(".") == 0) {
styleText = styleValue.substring(1,styleValue.length)
theStyle[theStyle.length] = styleValue
theStyleText[theStyleText.length] = styleText
} else {
// style contains a . not at beginning
if (styleValue.indexOf(".") > 0) {
styleText = styleValue.substring(styleValue.indexOf(".")+1,styleValue.length)
styleValue = styleValue.substring(styleValue.indexOf("."),styleValue.length)
theStyleText[theStyleText.length] = styleText
theStyle[theStyle.length] = styleValue
}
}
// contains BOTH a . and a :
} else {
styleValue = styleValue.substring(styleValue.indexOf("."),styleValue.indexOf(":"))
for (i=0;i<theStyle.length;i++) {
if (styleValue == theStyle[i]) {
styleExists = true
}
}
if (styleExists != true) {
theStyle[theStyle.length] = styleValue
styleText = styleValue.substring(styleValue.indexOf(".")+1,styleValue.length)
theStyleText[theStyleText.length] = styleText
}
styleExists = false
}
}
} // End for
for (z=0; z <= theStyle.length-1; z++) {
newOption = document.createElement("option");
newOption.value = theStyle[z];
newOption.text = theStyleText[z];
document.getElementById("sStyles").add(newOption)
}
} // End For
} // End if
} // End function
function InsertRowAbove() {
if (isCursorInTableCell()){
var numCols = 0
allCells = selectedTR.cells
for (var i=0;i<allCells.length;i++) {
numCols = numCols + allCells[i].getAttribute('colSpan')
}
var newTR = selectedTable.insertRow(selectedTR.rowIndex)
for (i = 0; i < numCols; i++) {
newTD = newTR.insertCell()
newTD.innerHTML = " "
if (borderShown == "yes") {
newTD.runtimeStyle.border = "1px dotted #BFBFBF"
}
}
}
} // End function
function InsertRowBelow() {
if (isCursorInTableCell()){
var numCols = 0
allCells = selectedTR.cells
for (var i=0;i<allCells.length;i++) {
numCols = numCols + allCells[i].getAttribute('colSpan')
}
var newTR = selectedTable.insertRow(selectedTR.rowIndex+1)
for (i = 0; i < numCols; i++) {
newTD = newTR.insertCell()
newTD.innerHTML = " "
if (borderShown == "yes") {
newTD.runtimeStyle.border = "1px dotted #BFBFBF"
}
}
}
} // End function
function IncreaseColspan() {
if (isCursorInTableCell()) {
var colSpanTD = selectedTD.getAttribute('colSpan')
allCells = selectedTR.cells
if (selectedTD.cellIndex + 1 != selectedTR.cells.length) {
var addColspan = allCells[selectedTD.cellIndex+1].getAttribute('colSpan')
selectedTD.colSpan = colSpanTD + addColspan
selectedTR.deleteCell(selectedTD.cellIndex+1)
}
}
} // End function
function IncreaseRowspan() {
if (isCursorInTableCell()) {
var rowSpanTD = selectedTD.getAttribute('rowSpan')
allRows = selectedTable.rows
if (selectedTR.rowIndex +1 != allRows.length) {
var allCellsInNextRow = allRows[selectedTR.rowIndex+selectedTD.rowSpan].cells
var addRowSpan = allCellsInNextRow[selectedTD.cellIndex].getAttribute('rowSpan')
var moveTo = selectedTD.rowSpan
if (!addRowSpan) addRowSpan = 1;
selectedTD.rowSpan = selectedTD.rowSpan + addRowSpan
allRows[selectedTR.rowIndex + moveTo].deleteCell(selectedTD.cellIndex)
}
}
} // End function
function DecreaseColspan() {
if (isCursorInTableCell()) {
if (selectedTD.colSpan != 1) {
selectedTR.insertCell(selectedTD.cellIndex+1)
selectedTD.colSpan = selectedTD.colSpan - 1
}
}
} // End function
function DecreaseRowspan() {
if (isCursorInTableCell()) {
alert("To Do")
}
} // End function
function DeleteRow() {
if (isCursorInTableCell()) {
selectedTable.deleteRow(selectedTR.rowIndex)
}
}
function DeleteCol() {
if (isCursorInTableCell()) {
moveFromEnd = (selectedTR.cells.length-1) - (selectedTD.cellIndex)
allRows = selectedTable.rows
for (var i=0;i<allRows.length;i++) {
endOfRow = allRows[i].cells.length - 1
position = endOfRow - moveFromEnd
if (position < 0) {
position = 0
} // End If
allCellsInRow = allRows[i].cells
if (allCellsInRow[position].colSpan > 1) {
allCellsInRow[position].colSpan = allCellsInRow[position].colSpan - 1
} else {
allRows[i].deleteCell(position)
}
} // End For
} // End If
} // End Function
function InsertColAfter() {
if (isCursorInTableCell()) {
moveFromEnd = (selectedTR.cells.length-1) - (selectedTD.cellIndex)
allRows = selectedTable.rows
for (i=0;i<allRows.length;i++) {
rowCount = allRows[i].cells.length - 1
position = rowCount - moveFromEnd
if (position < 0) {
position = 0
}
newCell = allRows[i].insertCell(position+1)
newCell.innerHTML = " "
if (borderShown == "yes") {
newCell.runtimeStyle.border = "1px dotted #BFBFBF"
}
}
}
} // End Function
function InsertColBefore() {
if (isCursorInTableCell()) {
moveFromEnd = (selectedTR.cells.length-1) - (selectedTD.cellIndex)
allRows = selectedTable.rows
for (i=0;i<allRows.length;i++) {
rowCount = allRows[i].cells.length - 1
position = rowCount - moveFromEnd
if (position < 0) {
position = 0
}
newCell = allRows[i].insertCell(position)
newCell.innerHTML = " "
if (borderShown == "yes") {
newCell.runtimeStyle.border = "1px dotted #BFBFBF"
}
}
}
}
function isImageSelected() {
if (foo.document.selection.type == "Control") {
var oControlRange = foo.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == "IMG") {
selectedImage = foo.document.selection.createRange()(0);
return true;
}
}
}
function isFlashSelected() {
if (foo.document.selection.type == "Control") {
var oControlRange = foo.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == "OBJECT") {
if (oControlRange(0).outerHTML.indexOf("flash") >= -1)
selectedFlash = foo.document.selection.createRange()(0);
return true;
}
}
}
function isControlSelected() {
if (foo.document.selection.type == "Control") {
var oControlRange = foo.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() != "IMG") {
selectedImage = foo.document.selection.createRange()(0);
return true;
}
}
}
function isTableSelected() {
if (foo.document.selection.type == "Control") {
var oControlRange = foo.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == "TABLE") {
selectedTable = foo.document.selection.createRange()(0);
return true;
}
}
} // End Function
function isCursorInTableCell() {
if (document.selection.type != "Control") {
var elem = document.selection.createRange().parentElement()
while (elem.tagName.toUpperCase() != "TD" && elem.tagName.toUpperCase() != "TH")
{
elem = elem.parentElement
if (elem == null)
break
}
if (elem) {
selectedTD = elem
selectedTR = selectedTD.parentElement
selectedTBODY = selectedTR.parentElement
selectedTable = selectedTBODY.parentElement
return true
}
}
} // End function
function isCursorInForm() {
if (document.selection.type != "Control") {
var elem = document.selection.createRange().parentElement()
while (elem.tagName != "FORM")
{
elem = elem.parentElement
if (elem == null)
break
}
if (elem) {
selectedForm = elem
return true
}
}
} // End function
function isCursorInList() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -