wtpcmd.js
来自「C#编写的在线用户统计、在线编辑器、验证码图片」· JavaScript 代码 · 共 836 行 · 第 1/2 页
JS
836 行
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("JustifyLeft");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpJustifyRightCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpJustifyRightCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("JustifyRight");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpJustifyCenterCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpJustifyCenterCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("JustifyCenter");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpCutCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpCutCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("Cut");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpCopyCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpCopyCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("Copy");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpPasteCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpPasteCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("Paste");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpUndoCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpUndoCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("Undo");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpRedoCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpRedoCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("Redo");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpInsertAnchorCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpInsertAnchorCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
// 获取选择文本
var range = m_targetDesignerPane.m_spanElement.document.selection.createRange();
if (range.text == "")
{
alert("在插入链接之前,请选取要替换的文本");
return;
}
// 获取链接地址
var anchor = prompt("链接 URL 地址", "http://");
if (anchor == null || anchor == "")
return;
// 建立链接
document.execCommand("CreateLink", false, anchor);
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpCancelAnchorCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpCancelAnchorCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("UnLink");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpInsertImageCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpInsertImageCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
// 获取选择文本
var range = m_targetDesignerPane.m_spanElement.document.selection.createRange();
// 显示提示框,获取图片地址
var imgUrl = prompt("图片 URL 地址", "http://");
if (imgUrl == null || imgUrl == "")
return;
// 插入图片
range.pasteHTML("<img src='" + imgUrl + "' />");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpInsertDateTimeCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpInsertDateTimeCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
// 获取选择文本
var range = m_targetDesignerPane.m_spanElement.document.selection.createRange();
// 获取当前日期时间
var currDateTime = new Date();
// 日期时间字符串
var currDateTimeStr = "";
currDateTimeStr += currDateTime.getFullYear();
currDateTimeStr += "/";
currDateTimeStr += currDateTime.getMonth();
currDateTimeStr += "/";
currDateTimeStr += currDateTime.getDate();
currDateTimeStr += " ";
currDateTimeStr += currDateTime.getHours();
currDateTimeStr += ":";
currDateTimeStr += currDateTime.getMinutes();
currDateTimeStr += ":";
currDateTimeStr += currDateTime.getSeconds();
// 插入图片
range.pasteHTML(currDateTimeStr);
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpInsertHRuleCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpInsertHRuleCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("InsertHorizontalRule");
}
}
}
///////////////////////////////////////////////////////////////////
//
// CWtpRemoveFormatCmd 命令类
//
// Parameters:
// tagDesignerPane, 设计器窗体
//
function CWtpRemoveFormatCmd(tagDesignerPane) {
if (tagDesignerPane == null)
throw new Error("tagDesignerPane is Null");
// 保存命令目标
this.m_targetDesignerPane = tagDesignerPane;
// 执行命令
this.execute = null;
with (this) {
// 执行命令
execute = function() {
m_targetDesignerPane.m_spanElement.focus();
m_targetDesignerPane.m_spanElement.document.execCommand("RemoveFormat");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?