📄 enc_functions.js
字号:
if (document.selection.type != "Control") {
var elem = document.selection.createRange().parentElement()
while (elem.tagName.toUpperCase() != "OL" && elem.tagName.toUpperCase() != "UL")
{
elem = elem.parentElement
if (elem == null)
break
}
if (elem) {
return true
}
}
} // End function
// toggle guidelines
function toggleBorders() {
var allForms = foo.document.body.getElementsByTagName("FORM");
var allInputs = foo.document.body.getElementsByTagName("INPUT");
var allTables = foo.document.body.getElementsByTagName("TABLE");
var allLinks = foo.document.body.getElementsByTagName("A");
if (document.getElementById("guidelines"))
{
if (borderShown == "no")
{
button_down(document.getElementById("guidelines"))
} else {
button_out(document.getElementById("guidelines"))
}
}
// Do forms
for (a=0; a < allForms.length; a++) {
if (borderShown == "no") {
allForms[a].runtimeStyle.border = "1px dotted #FF0000"
} else {
allForms[a].runtimeStyle.cssText = ""
}
}
// Do Objects
var allObjects = foo.document.body.getElementsByTagName("OBJECT");
for (a=0; a < allObjects.length; a++) {
if (borderShown == "no") {
allObjects[a].runtimeStyle.border = "1px dotted #0000FF"
} else {
allObjects[a].runtimeStyle.cssText = ""
}
}
// Do hidden fields
for (b=0; b < allInputs.length; b++) {
if (borderShown == "no") {
if (allInputs[b].type.toUpperCase() == "HIDDEN") {
allInputs[b].runtimeStyle.border = "0px"
allInputs[b].runtimeStyle.width = "20px"
allInputs[b].runtimeStyle.height = "20px"
allInputs[b].runtimeStyle.backgroundImage = "url(" + deveditPath1 + "/de_images/hidden.gif)"
allInputs[b].runtimeStyle.fontSize = "99px"
}
} else {
if (allInputs[b].type.toUpperCase() == "HIDDEN")
allInputs[b].runtimeStyle.cssText = ""
}
}
// Do tables
for (i=0; i < allTables.length; i++) {
if (borderShown == "no") {
allTables[i].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allTables[i].runtimeStyle.cssText = ""
}
allRows = allTables[i].rows
for (y=0; y < allRows.length; y++) {
allCellsInRow = allRows[y].cells
for (x=0; x < allCellsInRow.length; x++) {
if (borderShown == "no") {
allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allCellsInRow[x].runtimeStyle.cssText = ""
}
}
}
}
// Do anchors
for (a=0; a < allLinks.length; a++) {
if (borderShown == "no") {
if (allLinks[a].href.toUpperCase() == "") {
allLinks[a].runtimeStyle.width = "20px"
allLinks[a].runtimeStyle.height = "20px"
allLinks[a].runtimeStyle.textIndent = "20px"
allLinks[a].runtimeStyle.backgroundRepeat = "no-repeat"
allLinks[a].runtimeStyle.backgroundImage = "url(" + deveditPath1 + "/de_images/anchor.gif)"
}
} else {
allLinks[a].runtimeStyle.cssText = ""
}
}
if (borderShown == "no") {
borderShown = "yes"
} else {
borderShown = "no"
}
scrollUp()
}
// Begin spell check functions
/* word object that stores the id, word and the bookmark */
var arr, rng;
/* word object that stores the id, word and the bookmark */
function oWord(pos, wrd, bkmrk){
this.id = pos;
this.word = wrd;
this.bookmark = bkmrk;
this.getWord = getWord;
this.fixWord = fixWord;
}
function getWord(){
var r=foo.document.body.createTextRange();
r.move("word",this.id);
r.moveEnd("word",1);
if(r.text.match(/[\ \n\r]+$/)) r.moveEnd("character",-1); // strip out any trailing line feeds and spaces
r.select();
return true;
}
function fixWord(wrd, num){
var r=foo.document.body.createTextRange();
r.move("word",this.id);
r.moveEnd("word",1);
if(r.text.match(/[\ \n\r]+$/)) r.moveEnd("character",-1); // strip out any trailing line feeds and spaces
r.text = wrd;
for(i=this.id;i<arr.length;i++) arr[i].id = arr[i].id + (num - 1); // update word positioning
return true;
}
function getRange(){
var sr = null;
if(foo.document.selection.type.toLowerCase() == "text"){
sr = foo.document.selection.createRange();
} else {
sr = foo.document.body.createTextRange();
}
return sr;
}
function getWords(){
var sr = null;
if(foo.document.selection.type.toLowerCase() == "text"){
sr = foo.document.selection.createRange();
sr.expand("word");
sr.select();
};
var r=foo.document.body.createTextRange();
// get first word
r.move("word",0);
rEnd = r.expand("word");
var wordpos=0;
var idpos=0;
var wordblock="";
var aWords = new Array();
// loop until I run out of words
while(rEnd){
if(r.text.match(/[\ \n\r]+$/)) r.moveEnd("character",-1); // strip out any trailing line feeds and spaces
t=r.text; // grab the text
if((t!="." || t!="!" || t!="?") && (rEnd!=0 && t.match("[A-Za-z]"))) {
if((sr!=null)?sr.inRange(r):true){
r.collapse();
aWords[idpos] = new oWord(wordpos, t, r.getBookmark());
idpos++;
}
}
/* grab the next word */
r.move("word",1);
rEnd = r.expand("word");
wordpos++;
}
return aWords;
}
// End spell check functions
// Undo / Redo fix
var history = new Object;
history.data = []
history.position = 0
history.bookmark = []
history.max = 30
function saveHistory(incPosition) {
if (editModeOn == true)
{
if (history.data[history.data.length -1] != foo.document.documentElement.outerHTML)
{
for(i = history.data.length - 1; i >= history.position + 1; --i)
{
history.data.pop();
history.bookmark.pop();
}
history.data[history.data.length] = foo.document.documentElement.outerHTML
if (foo.document.selection.type != "Control")
{
history.bookmark[history.bookmark.length] = foo.document.selection.createRange().getBookmark()
} else {
oControl = foo.document.selection.createRange()
history.bookmark[history.bookmark.length] = oControl(0)
}
if (!incPosition)
{
history.position++
}
}
showUndoRedo()
}
}
function goHistory(value) {
// undo
if (value == -1)
{
if (history.position == history.data.length)
{
saveHistory(true)
}
if (history.position != 0)
{
foo.document.write(history.data[--history.position])
foo.document.close()
setHistoryCursor()
}
// redo
} else {
if (history.position < history.data.length -1)
{
foo.document.write(history.data[++history.position])
foo.document.close()
setHistoryCursor()
}
}
showUndoRedo()
}
function setHistoryCursor() {
toggleBorders()
toggleBorders()
initFoo();
if (history.bookmark[history.position])
{
r = foo.document.body.createTextRange()
if (history.bookmark[history.position] != "[object]")
{
if (r.moveToBookmark(history.bookmark[history.position]))
{
r.collapse(false)
doSave = 1
r.select();
doSave = 0
}
}
}
}
// End Undo / Redo Fix
function showUndoRedo() {
if (editModeOn == true)
{
var buttonUndoOn = document.getElementById("undo_on")
var buttonUndoOff = document.getElementById("undo_off")
if (history.data.length <= 1 || history.position <= 0)
{
buttonUndoOff.style.display = "inline"
buttonUndoOn.style.display = "none"
} else {
buttonUndoOff.style.display = "none"
buttonUndoOn.style.display = "inline"
}
var buttonRedoOn = document.getElementById("redo_on")
var buttonRedoOff = document.getElementById("redo_off")
if (history.position >= history.data.length-1 || history.data.length == 0)
{
buttonRedoOff.style.display = "inline"
buttonRedoOn.style.display = "none"
} else {
buttonRedoOff.style.display = "none"
buttonRedoOn.style.display = "inline"
}
} else {
var buttonUndo2On = document.getElementById("undo2_on")
var buttonUndo2Off = document.getElementById("undo2_off")
if (!foo.document.queryCommandEnabled("undo"))
{
buttonUndo2Off.style.display = "inline"
buttonUndo2On.style.display = "none"
} else {
buttonUndo2Off.style.display = "none"
buttonUndo2On.style.display = "inline"
}
var buttonRedo2On = document.getElementById("redo2_on")
var buttonRedo2Off = document.getElementById("redo2_off")
if (!foo.document.queryCommandEnabled("redo"))
{
buttonRedo2Off.style.display = "inline"
buttonRedo2On.style.display = "none"
} else {
buttonRedo2Off.style.display = "none"
buttonRedo2On.style.display = "inline"
}
}
}
var fullscreenMode = false
function toggleSize() {
if (!fullscreenMode)
{
parent.document.getElementById(controlName).runtimeStyle.position = "Absolute"
parent.document.getElementById(controlName).runtimeStyle.zIndex = "999"
parent.document.getElementById(controlName).runtimeStyle.posTop = 10
parent.document.getElementById(controlName).runtimeStyle.posLeft = 10
parent.document.getElementById(controlName).runtimeStyle.width = parent.document.body.clientWidth - 15
parent.document.getElementById(controlName).runtimeStyle.height = parent.document.body.offsetHeight - 30
parent.document.getElementById(controlName).focus()
button_down(document.getElementById("fullscreen"))
button_down(document.getElementById("fullscreen2"))
fullscreenMode = true
} else {
parent.document.getElementById(controlName).runtimeStyle.cssText = ""
parent.document.getElementById(controlName).focus()
button_out(document.getElementById("fullscreen"))
button_out(document.getElementById("fullscreen2"))
fullscreenMode = false
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -