Asp.net源码专业站
首页->新知实践->Afritxia在线用户统计、在线编辑器、验证码图片>>Net.AfritXia.Web/Resources/JavaScript/WtpCmd.js>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Afritxia在线用户统计、在线编辑器、验证码图片
当前文件:文件类型 AfritxiaWebTest/Net.AfritXia.Web/Resources/JavaScript/WtpCmd.js[21K,2009-6-12 11:31:33]打开代码结构图
普通视图
		            
1/* 2 * WtpCmd.js @Microsoft Visual Studio 2008 <.NET Framework 2.0 (or Higher)> 3 * AfritXia 4 * 2008/3/16 5 * 6 * Copyright(c) http://www.AfritXia.NET/ 7 * 8 */ 9 10/////////////////////////////////////////////////////////////////// 11// 12// CWtpSetFontNameCmd 命令类 13// 14// Parameters: 15// selectID, 下拉框标记 ID 16// tagDesignerPane, 设计器窗体 17// 18 19function CWtpSetFontNameCmd(selectID, tagDesignerPane) { 20 if (tagDesignerPane == null) 21 throw new Error("tagDesignerPane is Null"); 22 23 // 保存命令目标 24 this.m_targetDesignerPane = tagDesignerPane; 25 // 执行命令 26 this.execute = null; 27 28 with (this) { 29 // 执行命令 30 execute = function() { 31 // 获取 <select> 标记 32 var selectTag = document.getElementById(selectID); 33 34 if (selectTag == null) 35 return; 36 37 m_targetDesignerPane.m_spanElement.focus(); 38 m_targetDesignerPane.m_spanElement.document.execCommand("FontName", false, selectTag.value); 39 } 40 } 41} 42 43/////////////////////////////////////////////////////////////////// 44// 45// CWtpSetFontSizeCmd 命令类 46// 47// Parameters: 48// selectID, 下拉框标记 ID 49// tagDesignerPane, 设计器窗体 50// 51 52function CWtpSetFontSizeCmd(selectID, tagDesignerPane) { 53 if (tagDesignerPane == null) 54 throw new Error("tagDesignerPane is Null"); 55 56 // 保存命令目标 57 this.m_targetDesignerPane = tagDesignerPane; 58 // 执行命令 59 this.execute = null; 60 61 with (this) { 62 // 执行命令 63 execute = function() { 64 // 获取 <select> 标记 65 var selectTag = document.getElementById(selectID); 66 67 if (selectTag == null) 68 return; 69 70 m_targetDesignerPane.m_spanElement.focus(); 71 m_targetDesignerPane.m_spanElement.document.execCommand("FontSize", false, selectTag.value); 72 } 73 } 74} 75 76/////////////////////////////////////////////////////////////////// 77// 78// CWtpSetForeColorCmd 命令类 79// 80// Parameters: 81// selectID, 下拉框标记 ID 82// tagDesignerPane, 设计器窗体 83// 84 85function CWtpSetForeColorCmd(selectID, tagDesignerPane) { 86 if (tagDesignerPane == null) 87 throw new Error("tagDesignerPane is Null"); 88 89 // 保存命令目标 90 this.m_targetDesignerPane = tagDesignerPane; 91 // 执行命令 92 this.execute = null; 93 94 with (this) { 95 // 执行命令 96 execute = function() { 97 // 获取 <select> 标记 98 var selectTag = document.getElementById(selectID); 99 100 if (selectTag == null) 101 return; 102 103 m_targetDesignerPane.m_spanElement.focus(); 104 m_targetDesignerPane.m_spanElement.document.execCommand("ForeColor", false, selectTag.value); 105 } 106 } 107} 108 109/////////////////////////////////////////////////////////////////// 110// 111// CWtpSetBackColorCmd 命令类 112// 113// Parameters: 114// selectID, 下拉框标记 ID 115// tagDesignerPane, 设计器窗体 116// 117 118function CWtpSetBackColorCmd(selectID, tagDesignerPane) { 119 if (tagDesignerPane == null) 120 throw new Error("tagDesignerPane is Null"); 121 122 // 保存命令目标 123 this.m_targetDesignerPane = tagDesignerPane; 124 // 执行命令 125 this.execute = null; 126 127 with (this) { 128 // 执行命令 129 execute = function() { 130 // 获取 <select> 标记 131 var selectTag = document.getElementById(selectID); 132 133 if (selectTag == null) 134 return; 135 136 m_targetDesignerPane.m_spanElement.focus(); 137 m_targetDesignerPane.m_spanElement.document.execCommand("BackColor", false, selectTag.value); 138 } 139 } 140} 141 142/////////////////////////////////////////////////////////////////// 143// 144// CWtpBoldCmd 命令类 145// 146// Parameters: 147// tagDesignerPane, 设计器窗体 148// 149 150function CWtpBoldCmd(tagDesignerPane) { 151 if (tagDesignerPane == null) 152 throw new Error("tagDesignerPane is Null"); 153 154 // 保存命令目标 155 this.m_targetDesignerPane = tagDesignerPane; 156 // 执行命令 157 this.execute = null; 158 159 with (this) { 160 // 执行命令 161 execute = function() { 162 m_targetDesignerPane.m_spanElement.focus(); 163 m_targetDesignerPane.m_spanElement.document.execCommand("Bold"); 164 } 165 } 166} 167 168/////////////////////////////////////////////////////////////////// 169// 170// CWtpItalicCmd 命令类 171// 172// Parameters: 173// tagDesignerPane, 设计器窗体 174// 175 176function CWtpItalicCmd(tagDesignerPane) { 177 if (tagDesignerPane == null) 178 throw new Error("tagDesignerPane is Null"); 179 180 // 保存命令目标 181 this.m_targetDesignerPane = tagDesignerPane; 182 // 执行命令 183 this.execute = null; 184 185 with (this) { 186 // 执行命令 187 execute = function() { 188 m_targetDesignerPane.m_spanElement.focus(); 189 m_targetDesignerPane.m_spanElement.document.execCommand("Italic"); 190 } 191 } 192} 193 194/////////////////////////////////////////////////////////////////// 195// 196// CWtpUnderLineCmd 命令类 197// 198// Parameters: 199// tagDesignerPane, 设计器窗体 200// 201 202function CWtpUnderLineCmd(tagDesignerPane) { 203 if (tagDesignerPane == null) 204 throw new Error("tagDesignerPane is Null"); 205 206 // 保存命令目标 207 this.m_targetDesignerPane = tagDesignerPane; 208 // 执行命令 209 this.execute = null; 210 211 with (this) { 212 // 执行命令 213 execute = function() { 214 m_targetDesignerPane.m_spanElement.focus(); 215 m_targetDesignerPane.m_spanElement.document.execCommand("UnderLine"); 216 } 217 } 218} 219 220/////////////////////////////////////////////////////////////////// 221// 222// CWtpStrikeThroughCmd 命令类 223// 224// Parameters: 225// tagDesignerPane, 设计器窗体 226// 227 228function CWtpStrikeThroughCmd(tagDesignerPane) { 229 if (tagDesignerPane == null) 230 throw new Error("tagDesignerPane is Null"); 231 232 // 保存命令目标 233 this.m_targetDesignerPane = tagDesignerPane; 234 // 执行命令 235 this.execute = null; 236 237 with (this) { 238 // 执行命令 239 execute = function() { 240 m_targetDesignerPane.m_spanElement.focus(); 241 m_targetDesignerPane.m_spanElement.document.execCommand("StrikeThrough"); 242 } 243 } 244} 245 246/////////////////////////////////////////////////////////////////// 247// 248// CWtpSuperScriptCmd 命令类 249// 250// Parameters: 251// tagDesignerPane, 设计器窗体 252// 253 254function CWtpSuperScriptCmd(tagDesignerPane) { 255 if (tagDesignerPane == null) 256 throw new Error("tagDesignerPane is Null"); 257 258 // 保存命令目标 259 this.m_targetDesignerPane = tagDesignerPane; 260 // 执行命令 261 this.execute = null; 262 263 with (this) { 264 // 执行命令 265 execute = function() { 266 // 事先清除格式 267 (new CWtpRemoveFormatCmd(tagDesignerPane)).execute(); 268 269 m_targetDesignerPane.m_spanElement.focus(); 270 m_targetDesignerPane.m_spanElement.document.execCommand("SuperScript"); 271 } 272 } 273} 274 275/////////////////////////////////////////////////////////////////// 276// 277// CWtpSubScriptCmd 命令类 278// 279// Parameters: 280// tagDesignerPane, 设计器窗体 281// 282 283function CWtpSubScriptCmd(tagDesignerPane) { 284 if (tagDesignerPane == null) 285 throw new Error("tagDesignerPane is Null"); 286 287 // 保存命令目标 288 this.m_targetDesignerPane = tagDesignerPane; 289 // 执行命令 290 this.execute = null; 291 292 with (this) { 293 // 执行命令 294 execute = function() { 295 // 事先清除格式 296 (new CWtpRemoveFormatCmd(tagDesignerPane)).execute(); 297 298 m_targetDesignerPane.m_spanElement.focus(); 299 m_targetDesignerPane.m_spanElement.document.execCommand("SubScript"); 300 } 301 } 302} 303 304/////////////////////////////////////////////////////////////////// 305// 306// CWtpBulletedListCmd 命令类 307// 308// Parameters: 309// tagDesignerPane, 设计器窗体 310// 311 312function CWtpBulletedListCmd(tagDesignerPane) { 313 if (tagDesignerPane == null) 314 throw new Error("tagDesignerPane is Null"); 315 316 // 保存命令目标 317 this.m_targetDesignerPane = tagDesignerPane; 318 // 执行命令 319 this.execute = null; 320 321 with (this) { 322 // 执行命令 323 execute = function() { 324 m_targetDesignerPane.m_spanElement.focus(); 325 m_targetDesignerPane.m_spanElement.document.execCommand("InsertUnorderedList", false); 326 } 327 } 328} 329 330/////////////////////////////////////////////////////////////////// 331// 332// CWtpNumberedListCmd 命令类 333// 334// Parameters: 335// tagDesignerPane, 设计器窗体 336// 337 338function CWtpNumberedListCmd(tagDesignerPane) { 339 if (tagDesignerPane == null) 340 throw new Error("tagDesignerPane is Null"); 341 342 // 保存命令目标 343 this.m_targetDesignerPane = tagDesignerPane; 344 // 执行命令 345 this.execute = null; 346 347 with (this) { 348 // 执行命令 349 execute = function() { 350 m_targetDesignerPane.m_spanElement.focus(); 351 m_targetDesignerPane.m_spanElement.document.execCommand("InsertOrderedList", false); 352 } 353 } 354} 355 356/////////////////////////////////////////////////////////////////// 357// 358// CWtpIndentCmd 命令类 359// 360// Parameters: 361// tagDesignerPane, 设计器窗体 362// 363 364function CWtpIndentCmd(tagDesignerPane) { 365 366 if (tagDesignerPane == null) 367 throw new Error("tagDesignerPane is Null"); 368 369 // 保存命令目标 370 this.m_targetDesignerPane = tagDesignerPane; 371 // 执行命令 372 this.execute = null; 373 374 with (this) { 375 // 执行命令 376 execute = function() { 377 m_targetDesignerPane.m_spanElement.focus(); 378 m_targetDesignerPane.m_spanElement.document.execCommand("Indent"); 379 } 380 } 381} 382 383/////////////////////////////////////////////////////////////////// 384// 385// CWtpOutdentCmd 命令类 386// 387// Parameters: 388// tagDesignerPane, 设计器窗体 389// 390 391function CWtpOutdentCmd(tagDesignerPane) { 392 393 if (tagDesignerPane == null) 394 throw new Error("tagDesignerPane is Null"); 395 396 // 保存命令目标 397 this.m_targetDesignerPane = tagDesignerPane; 398 // 执行命令 399 this.execute = null; 400 401 with (this) { 402 // 执行命令 403 execute = function() { 404 m_targetDesignerPane.m_spanElement.focus(); 405 m_targetDesignerPane.m_spanElement.document.execCommand("Outdent"); 406 } 407 } 408} 409 410/////////////////////////////////////////////////////////////////// 411// 412// CWtpJustifyLeftCmd 命令类 413// 414// Parameters: 415// tagDesignerPane, 设计器窗体 416// 417 418function CWtpJustifyLeftCmd(tagDesignerPane) { 419 420 if (tagDesignerPane == null) 421 throw new Error("tagDesignerPane is Null"); 422 423 // 保存命令目标 424 this.m_targetDesignerPane = tagDesignerPane; 425 // 执行命令 426 this.execute = null; 427 428 with (this) { 429 // 执行命令 430 execute = function() { 431 m_targetDesignerPane.m_spanElement.focus(); 432 m_targetDesignerPane.m_spanElement.document.execCommand("JustifyLeft"); 433 } 434 } 435} 436 437/////////////////////////////////////////////////////////////////// 438// 439// CWtpJustifyRightCmd 命令类 440// 441// Parameters: 442// tagDesignerPane, 设计器窗体 443// 444 445function CWtpJustifyRightCmd(tagDesignerPane) { 446 447 if (tagDesignerPane == null) 448 throw new Error("tagDesignerPane is Null"); 449 450 // 保存命令目标 451 this.m_targetDesignerPane = tagDesignerPane; 452 // 执行命令 453 this.execute = null; 454 455 with (this) { 456 // 执行命令 457 execute = function() { 458 m_targetDesignerPane.m_spanElement.focus(); 459 m_targetDesignerPane.m_spanElement.document.execCommand("JustifyRight"); 460 } 461 } 462} 463 464/////////////////////////////////////////////////////////////////// 465// 466// CWtpJustifyCenterCmd 命令类 467// 468// Parameters: 469// tagDesignerPane, 设计器窗体 470// 471 472function CWtpJustifyCenterCmd(tagDesignerPane) { 473 474 if (tagDesignerPane == null) 475 throw new Error("tagDesignerPane is Null"); 476 477 // 保存命令目标 478 this.m_targetDesignerPane = tagDesignerPane; 479 // 执行命令 480 this.execute = null; 481 482 with (this) { 483 // 执行命令 484 execute = function() { 485 m_targetDesignerPane.m_spanElement.focus(); 486 m_targetDesignerPane.m_spanElement.document.execCommand("JustifyCenter"); 487 } 488 } 489} 490 491/////////////////////////////////////////////////////////////////// 492// 493// CWtpCutCmd 命令类 494// 495// Parameters: 496// tagDesignerPane, 设计器窗体 497// 498 499function CWtpCutCmd(tagDesignerPane) { 500 501 if (tagDesignerPane == null) 502 throw new Error("tagDesignerPane is Null"); 503 504 // 保存命令目标 505 this.m_targetDesignerPane = tagDesignerPane; 506 // 执行命令 507 this.execute = null; 508 509 with (this) { 510 // 执行命令 511 execute = function() { 512 m_targetDesignerPane.m_spanElement.focus(); 513 m_targetDesignerPane.m_spanElement.document.execCommand("Cut"); 514 } 515 } 516} 517 518/////////////////////////////////////////////////////////////////// 519// 520// CWtpCopyCmd 命令类 521// 522// Parameters: 523// tagDesignerPane, 设计器窗体 524// 525 526function CWtpCopyCmd(tagDesignerPane) { 527 528 if (tagDesignerPane == null) 529 throw new Error("tagDesignerPane is Null"); 530 531 // 保存命令目标 532 this.m_targetDesignerPane = tagDesignerPane; 533 // 执行命令 534 this.execute = null; 535 536 with (this) { 537 // 执行命令 538 execute = function() { 539 m_targetDesignerPane.m_spanElement.focus(); 540 m_targetDesignerPane.m_spanElement.document.execCommand("Copy"); 541 } 542 } 543} 544 545/////////////////////////////////////////////////////////////////// 546// 547// CWtpPasteCmd 命令类 548// 549// Parameters: 550// tagDesignerPane, 设计器窗体 551// 552 553function CWtpPasteCmd(tagDesignerPane) { 554 555 if (tagDesignerPane == null) 556 throw new Error("tagDesignerPane is Null"); 557 558 // 保存命令目标 559 this.m_targetDesignerPane = tagDesignerPane; 560 // 执行命令 561 this.execute = null; 562 563 with (this) { 564 // 执行命令 565 execute = function() { 566 m_targetDesignerPane.m_spanElement.focus(); 567 m_targetDesignerPane.m_spanElement.document.execCommand("Paste"); 568 } 569 } 570} 571 572/////////////////////////////////////////////////////////////////// 573// 574// CWtpUndoCmd 命令类 575// 576// Parameters: 577// tagDesignerPane, 设计器窗体 578// 579 580function CWtpUndoCmd(tagDesignerPane) { 581 582 if (tagDesignerPane == null) 583 throw new Error("tagDesignerPane is Null"); 584 585 // 保存命令目标 586 this.m_targetDesignerPane = tagDesignerPane; 587 // 执行命令 588 this.execute = null; 589 590 with (this) { 591 // 执行命令 592 execute = function() { 593 m_targetDesignerPane.m_spanElement.focus(); 594 m_targetDesignerPane.m_spanElement.document.execCommand("Undo"); 595 } 596 } 597} 598 599/////////////////////////////////////////////////////////////////// 600// 601// CWtpRedoCmd 命令类 602// 603// Parameters: 604// tagDesignerPane, 设计器窗体 605// 606 607function CWtpRedoCmd(tagDesignerPane) { 608 609 if (tagDesignerPane == null) 610 throw new Error("tagDesignerPane is Null"); 611 612 // 保存命令目标 613 this.m_targetDesignerPane = tagDesignerPane; 614 // 执行命令 615 this.execute = null; 616 617 with (this) { 618 // 执行命令 619 execute = function() { 620 m_targetDesignerPane.m_spanElement.focus(); 621 m_targetDesignerPane.m_spanElement.document.execCommand("Redo"); 622 } 623 } 624} 625 626/////////////////////////////////////////////////////////////////// 627// 628// CWtpInsertAnchorCmd 命令类 629// 630// Parameters: 631// tagDesignerPane, 设计器窗体 632// 633 634function CWtpInsertAnchorCmd(tagDesignerPane) { 635 636 if (tagDesignerPane == null) 637 throw new Error("tagDesignerPane is Null"); 638 639 // 保存命令目标 640 this.m_targetDesignerPane = tagDesignerPane; 641 // 执行命令 642 this.execute = null; 643 644 with (this) { 645 // 执行命令 646 execute = function() { 647 m_targetDesignerPane.m_spanElement.focus(); 648 649 // 获取选择文本 650 var range = m_targetDesignerPane.m_spanElement.document.selection.createRange(); 651 652 if (range.text == "") 653 { 654 alert("在插入链接之前,请选取要替换的文本"); 655 return; 656 } 657 658 // 获取链接地址 659 var anchor = prompt("链接 URL 地址", "http://"); 660 661 if (anchor == null || anchor == "") 662 return; 663 664 // 建立链接 665 document.execCommand("CreateLink", false, anchor); 666 } 667 } 668} 669 670/////////////////////////////////////////////////////////////////// 671// 672// CWtpCancelAnchorCmd 命令类 673// 674// Parameters: 675// tagDesignerPane, 设计器窗体 676// 677 678function CWtpCancelAnchorCmd(tagDesignerPane) { 679 680 if (tagDesignerPane == null) 681 throw new Error("tagDesignerPane is Null"); 682 683 // 保存命令目标 684 this.m_targetDesignerPane = tagDesignerPane; 685 // 执行命令 686 this.execute = null; 687 688 with (this) { 689 // 执行命令 690 execute = function() { 691 m_targetDesignerPane.m_spanElement.focus(); 692 m_targetDesignerPane.m_spanElement.document.execCommand("UnLink"); 693 } 694 } 695} 696 697/////////////////////////////////////////////////////////////////// 698// 699// CWtpInsertImageCmd 命令类 700// 701// Parameters: 702// tagDesignerPane, 设计器窗体 703// 704 705function CWtpInsertImageCmd(tagDesignerPane) { 706 707 if (tagDesignerPane == null) 708 throw new Error("tagDesignerPane is Null"); 709 710 // 保存命令目标 711 this.m_targetDesignerPane = tagDesignerPane; 712 // 执行命令 713 this.execute = null; 714 715 with (this) { 716 // 执行命令 717 execute = function() { 718 m_targetDesignerPane.m_spanElement.focus(); 719 720 // 获取选择文本 721 var range = m_targetDesignerPane.m_spanElement.document.selection.createRange(); 722 723 // 显示提示框,获取图片地址 724 var imgUrl = prompt("图片 URL 地址", "http://"); 725 726 if (imgUrl == null || imgUrl == "") 727 return; 728 729 // 插入图片 730 range.pasteHTML("<img src='" + imgUrl + "' />"); 731 } 732 } 733} 734 735/////////////////////////////////////////////////////////////////// 736// 737// CWtpInsertDateTimeCmd 命令类 738// 739// Parameters: 740// tagDesignerPane, 设计器窗体 741// 742 743function CWtpInsertDateTimeCmd(tagDesignerPane) { 744 745 if (tagDesignerPane == null) 746 throw new Error("tagDesignerPane is Null"); 747 748 // 保存命令目标 749 this.m_targetDesignerPane = tagDesignerPane; 750 // 执行命令 751 this.execute = null; 752 753 with (this) { 754 // 执行命令 755 execute = function() { 756 m_targetDesignerPane.m_spanElement.focus(); 757 758 // 获取选择文本 759 var range = m_targetDesignerPane.m_spanElement.document.selection.createRange(); 760 761 // 获取当前日期时间 762 var currDateTime = new Date(); 763 // 日期时间字符串 764 var currDateTimeStr = ""; 765 766 currDateTimeStr += currDateTime.getFullYear(); 767 currDateTimeStr += "/"; 768 currDateTimeStr += currDateTime.getMonth(); 769 currDateTimeStr += "/"; 770 currDateTimeStr += currDateTime.getDate(); 771 currDateTimeStr += " "; 772 currDateTimeStr += currDateTime.getHours(); 773 currDateTimeStr += ":"; 774 currDateTimeStr += currDateTime.getMinutes(); 775 currDateTimeStr += ":"; 776 currDateTimeStr += currDateTime.getSeconds(); 777 778 // 插入图片 779 range.pasteHTML(currDateTimeStr); 780 } 781 } 782} 783 784/////////////////////////////////////////////////////////////////// 785// 786// CWtpInsertHRuleCmd 命令类 787// 788// Parameters: 789// tagDesignerPane, 设计器窗体 790// 791 792function CWtpInsertHRuleCmd(tagDesignerPane) { 793 794 if (tagDesignerPane == null) 795 throw new Error("tagDesignerPane is Null"); 796 797 // 保存命令目标 798 this.m_targetDesignerPane = tagDesignerPane; 799 // 执行命令 800 this.execute = null; 801 802 with (this) { 803 // 执行命令 804 execute = function() { 805 m_targetDesignerPane.m_spanElement.focus(); 806 m_targetDesignerPane.m_spanElement.document.execCommand("InsertHorizontalRule"); 807 } 808 } 809} 810 811/////////////////////////////////////////////////////////////////// 812// 813// CWtpRemoveFormatCmd 命令类 814// 815// Parameters: 816// tagDesignerPane, 设计器窗体 817// 818 819function CWtpRemoveFormatCmd(tagDesignerPane) { 820 821 if (tagDesignerPane == null) 822 throw new Error("tagDesignerPane is Null"); 823 824 // 保存命令目标 825 this.m_targetDesignerPane = tagDesignerPane; 826 // 执行命令 827 this.execute = null; 828 829 with (this) { 830 // 执行命令 831 execute = function() { 832 m_targetDesignerPane.m_spanElement.focus(); 833 m_targetDesignerPane.m_spanElement.document.execCommand("RemoveFormat"); 834 } 835 } 836}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Afritxia在线用户统计、在线编辑器、验证码图片
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146