?? editor.js
字號:
var IWE_ColorHex_A = new Array("00","33","66","99","CC","FF");
var IWE_ColorHex_B = new Array("FF0000","00FF00","0000FF","FFFF00","00FFFF","FF00FF");
var IWE_ColorObject = null;
var IWE_Design_Mode = true;
var IWE_Range = null;
var IWE_Height = 240;
// 獲取文件名
function getfullfilename(filename){
var idotindex = filename.lastIndexOf("/");
var fullfilename = "";
if (idotindex>=0){
fullfilename = filename.substring(idotindex + 1);
}
return fullfilename;
}
// 鼠標指向色彩控件
function over_IWE_Color(){
if ((event.srcElement.isColor) && (IWE_ColorObject!=event.srcElement)) {
if (IWE_ColorObject!=null){ IWE_ColorObject.style.backgroundColor = IWE_ColorObject._background }
event.srcElement._background = event.srcElement.style.backgroundColor;
$("IWE_DisColor").style.backgroundColor = event.srcElement.style.backgroundColor;
$("IWE_HexColor").value = event.srcElement.style.backgroundColor;
event.srcElement.style.backgroundColor = "#ffffff";
IWE_ColorObject = event.srcElement;
}
}
// 鼠標移開色彩控件
function out_IWE_Color(){
if (IWE_ColorObject!=null)
{
IWE_ColorObject.style.backgroundColor = IWE_ColorObject._background;
}
}
// 顯示 Editor 面板
function show_IWE_Panel(iParent, iSelf){
var ofP = getobjectxy($(iParent));
IWE_Frame.focus();
IWE_Range = IWE_Frame.document.selection.createRange();
$(iSelf).style.display = "";
$(iSelf).style.top = (ofP.y + $(iParent).offsetHeight) + "px";
$(iSelf).style.left = (ofP.x) + "px";
$(iSelf).setActive();
}
// 隱藏 Editor 面板
function hide_IWE_Panel(iParent, iSelf){
var _source = event.srcElement;
var _sourcePt = getobjectxy(_source);
var _selfPt = getobjectxy($(iSelf));
var _x = (_sourcePt.x + event.offsetX);
var _y = (_sourcePt.y + event.offsetY);
if (_x<_selfPt.x || _x>(_selfPt.x + $(iSelf).offsetWidth))
{
$(iSelf).style.display = "none";
}
if (_y<_selfPt.y || _y>(_selfPt.y + $(iSelf).offsetHeight))
{
$(iSelf).style.display = "none";
}
}
// 去除 HTML 中的危險代碼,例如 script, object, iframe, frameset 等
function IWE_Filter(strhtml){
var result;
var re = /<script(.|\n)+?<\/script>/gi;
result = strhtml.replace(re,"");
re = /<object(.|\n)+?<\/object>/gi;
result = result.replace(re,"");
re = /<iframe(.|\n)+?<\/iframe>/gi;
result = result.replace(re,"");
re = /<frameset(.|\n)+?<\/frameset>/gi;
result = result.replace(re,"");
re = /<frame(.|\n)+?<\/frame>/gi;
result = result.replace(re,"");
re = /<((frame)|(input)|(select)|(option)|(textarea)|(button))(.|\n)+?>/gi;
return result.replace(re,"");
}
// 顯示插入多媒體面板
function show_IWE_Media_Panel(){
IWE_Frame.focus();
IWE_Range = IWE_Frame.document.selection.createRange();
var _medias = window.showModalDialog(getlocal() + 'web/personal/topic/getMedia.aspx','','dialogWidth:640px;dialogHeight:480px;');
if (_medias!=null && trim(_medias)){
IWE_Frame.focus();
if (IWE_Range!=null){
IWE_Range.select();
IWE_Range.pasteHTML(_medias);
}
}
}
// 選擇網絡多媒體
function IWE_Media_Get_Medias(){
$("bhttp").disabled = true;
$("bfiles").disabled = false;
$("bsearch").disabled = true;
$("ls_name").innerHTML = "網絡多媒體";
$("div_list").innerHTML = "<table class=\"table_form\"><tr><td><label for=\"thttp\">URL 地址:</label><input type=\"text\" id=\"thttp\" name=\"thttp\" value=\"http://\" size=\"56\" class=\"text\"></td></tr></table>";
}
// 選擇本地多媒體
function IWE_Media_Get_Files(){
$("bhttp").disabled = false;
$("bfiles").disabled = true;
$("bsearch").disabled = false;
$("ls_name").innerHTML = "我的多媒體庫";
this.success = function(t){
$("div_list").innerHTML = t;
}
this.error = function(){
$("div_list").innerHTML = "<div class='cls_error'>查詢多媒體失敗</div>";
}
$("div_list").innerHTML = "<div class='cls_progress'>正在查詢多媒體,請等待...</div>";
var theajax = new ajax(false, this.success, this.error);
theajax.get(getlocal() + "web/Service/Ajax_Action.aspx?Command=Editor_Medias&searchkey="+escape($("searchkey").value)+"&pageid="+$("_pageid").value, true);
}
// 選擇多媒體
function IWE_Select_Medias(){
var _local = getlocal();
if ($("bfiles").disabled){
var _medias = "";
if (typeof(document.Form1.Media.length)=="undefined")
{
if (document.Form1.Media.checked){
_medias = "<EMBED src=\"" + _local + "web/file/file," + document.Form1.Media.value + ".aspx\" autostart=\"false\" loop=\"true\" /> ";
}
}else{
for(i=0;i<document.Form1.Media.length;i++){
if (document.Form1.Media[i].checked){
_medias += "<EMBED src=\"" + _local + "web/file/file," + document.Form1.Media[i].value + ".aspx\" autostart=\"false\" loop=\"true\" /> ";
}
}
}
window.returnValue = _medias;
}else{
if (isurl($("thttp").value)){
window.returnValue = "<EMBED src=\"" + $("thttp").value + "\" autostart=\"false\" loop=\"true\" /> ";
}else{
window.returnValue = "";
}
}
window.close();
}
// 顯示插入圖片面板
function show_IWE_Image_Panel(){
IWE_Frame.focus();
IWE_Range = IWE_Frame.document.selection.createRange();
var _images = window.showModalDialog(getlocal() + 'web/personal/topic/getImage.aspx','','dialogWidth:640px;dialogHeight:480px;');
if (_images!=null && trim(_images)){
IWE_Frame.focus();
if (IWE_Range!=null){
IWE_Range.select();
IWE_Range.pasteHTML(_images);
}
}
}
// 選擇網絡圖片
function IWE_Image_Get_Images(){
$("bhttp").disabled = true;
$("bfiles").disabled = false;
$("bsearch").disabled = true;
$("ls_name").innerHTML = "網絡圖片";
$("div_list").innerHTML = "<table class=\"table_form\"><tr><td><label for=\"thttp\">URL 地址:</label><input type=\"text\" id=\"thttp\" name=\"thttp\" value=\"http://\" size=\"56\" class=\"text\"></td></tr></table>";
}
// 選擇本地圖片
function IWE_Image_Get_Files(){
$("bhttp").disabled = false;
$("bfiles").disabled = true;
$("bsearch").disabled = false;
$("ls_name").innerHTML = "我的圖片庫";
this.success = function(t){
$("div_list").innerHTML = t;
}
this.error = function(){
$("div_list").innerHTML = "<div class='cls_error'>查詢圖片失敗</div>";
}
$("div_list").innerHTML = "<div class='cls_progress'>正在查詢圖片,請等待...</div>";
var theajax = new ajax(false, this.success, this.error);
theajax.get(getlocal() + "web/Service/Ajax_Action.aspx?Command=Editor_Images&searchkey="+escape($("searchkey").value)+"&pageid="+$("_pageid").value, true);
}
// 選擇圖片
function IWE_Select_Images(){
if ($("bfiles").disabled){
var _images = "";
if (typeof(document.Form1.Image.length)=="undefined")
{
if (document.Form1.Image.checked){
_images = "<img src=\""+document.Form1.Image.title+"\" onload=\"javascript:previewimage(this, 560);\"> ";
}
}else{
for(i=0;i<document.Form1.Image.length;i++){
if (document.Form1.Image[i].checked){
_images += "<img src=\""+document.Form1.Image[i].title+"\" onload=\"javascript:previewimage(this, 560);\"> ";
}
}
}
window.returnValue = _images;
}else{
if (isurl($("thttp").value)){
window.returnValue = "<img src=\""+$("thttp").value+"\" onload=\"javascript:previewimage(this, 560);\"> ";
}else{
window.returnValue = "";
}
}
window.close();
}
// 顯示插入超鏈接面板
function show_IWE_Link_Panel(){
IWE_Frame.focus();
IWE_Range = IWE_Frame.document.selection.createRange();
var _links = window.showModalDialog(getlocal() + 'web/personal/topic/getLink.aspx','','dialogWidth:640px;dialogHeight:480px;');
if (_links!=null && trim(_links)){
IWE_Frame.focus();
if (_links.indexOf("a href")>=0){
if (IWE_Range!=null){
IWE_Range.select();
IWE_Range.pasteHTML(_links);
}
}else{
IWE_Frame.document.execCommand('CreateLink',false,_links);
}
}
}
// 選擇網絡鏈接
function IWE_Link_Get_Links(){
$("bhttp").disabled = true;
$("bfiles").disabled = false;
$("btopics").disabled = false;
$("bsearch").disabled = true;
$("ls_name").innerHTML = "網絡鏈接";
$("div_list").innerHTML = "<table class=\"table_form\"><tr><td><label for=\"thttp\">URL 地址:</label><input type=\"text\" id=\"thttp\" name=\"thttp\" value=\"http://\" size=\"56\" class=\"text\"></td></tr></table>";
}
// 選擇本地文件
function IWE_Link_Get_Files(){
$("bhttp").disabled = false;
$("bfiles").disabled = true;
$("btopics").disabled = false;
$("bsearch").disabled = false;
$("ls_name").innerHTML = "我的文件夾";
this.success = function(t){
$("div_list").innerHTML = t;
}
this.error = function(){
$("div_list").innerHTML = "<div class='cls_error'>查詢文件失敗</div>";
}
$("div_list").innerHTML = "<div class='cls_progress'>正在查詢文件,請等待...</div>";
var theajax = new ajax(false, this.success, this.error);
theajax.get(getlocal() + "web/Service/Ajax_Action.aspx?Command=Editor_Files&searchkey="+escape($("searchkey").value)+"&pageid="+$("_pageid").value, true);
}
// 選擇我的主題
function IWE_Link_Get_Topics(){
$("bhttp").disabled = false;
$("bfiles").disabled = false;
$("btopics").disabled = true;
$("bsearch").disabled = false;
$("ls_name").innerHTML = "我的主題";
this.success = function(t){
$("div_list").innerHTML = t;
}
this.error = function(){
$("div_list").innerHTML = "<div class='cls_error'>查詢主題失敗</div>";
}
$("div_list").innerHTML = "<div class='cls_progress'>正在查詢主題,請等待...</div>";
var theajax = new ajax(false, this.success, this.error);
theajax.get(getlocal() + "web/Service/Ajax_Action.aspx?Command=Editor_Topics&searchkey="+escape($("searchkey").value)+"&pageid="+$("_pageid").value, true);
}
// 查詢主題/文件
function IWE_Link_Get_Search(){
if ($("bfiles").disabled){
IWE_Link_Get_Files();
}
if ($("btopics").disabled){
IWE_Link_Get_Topics();
}
}
// 選擇超級鏈接
function IWE_Select_Links(){
var _local = getlocal();
if ($("bfiles").disabled){
var _files = "";
if (typeof(document.Form1.Link.length)=="undefined")
{
if (document.Form1.Link.checked){
_files = "<a href=\"" + _local + "web/file/file," + document.Form1.Link.value + ".aspx\" target=\"_blank\">"+document.Form1.Link.title+"</a> ";
}
}else{
for(i=0;i<document.Form1.Link.length;i++){
if (document.Form1.Link[i].checked){
_files += "<a href=\"" + _local + "web/file/file," + document.Form1.Link[i].value + ".aspx\" target=\"_blank\">"+document.Form1.Link[i].title+"</a> ";
}
}
}
window.returnValue = _files;
}else{
if ($("btopics").disabled){
var _topics = "";
if (typeof(document.Form1.Link.length)=="undefined")
{
if (document.Form1.Link.checked){
_topics = "<a href=\"" + getlocal() + "web/topic/topic," + document.Form1.Link.value + ".aspx\" target=\"_blank\">"+document.Form1.Link.title+"</a> ";
}
}else{
for(i=0;i<document.Form1.Link.length;i++){
if (document.Form1.Link[i].checked){
_topics += "<a href=\"" + getlocal() + "web/topic/topic," + document.Form1.Link[i].value + ".aspx\" target=\"_blank\">"+document.Form1.Link[i].title+"</a> ";
}
}
}
window.returnValue = _topics;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -