<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
<html>
<head>
<title>EasyRT V1.0</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta http-equiv="author" content="dh20156"/>
<link type="text/css" rel="stylesheet" href="skin/easyrt.css"/>
</head>
<body>
<div id="easyrt"></div>
<button onclick='oeasyrt.setValue("<p>hello,world!</p>");'>set value</button>
<button onclick='alert(oeasyrt.getValue());'>get value</button>
<script type="text/javascript">
var easyRT = function(dbox,iw,ih,tbname){
this.box = dbox;
this.toolbar = null;
this.editor = null;
this.textbox = null;
this.popup = null;
this.width = iw||'100%';
this.height = ih||200;
this.textboxname = tbname||null;
this.imgurl = 'skin/';
this.btnlist = ['bold','italic','underline','|','forecolor','backcolor','face','|','url','img','|','justify','list','|','outdent','indent','|','clear','|','source'];
};
easyRT.prototype = {
setValue:function(svalue){this.editor.document.body.innerHTML=svalue;this.textbox.value=svalue;},
getValue:function(){var svalue=this.editor.document.body.innerHTML;this.textbox.value=svalue;return svalue;},
init:function(svalue){
var oBox = this;
//stop event
var stopEvent = function(e){
e = e||window.event;
if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble = true;}
if(e.preventDefault){e.preventDefault();}else{e.returnValue = false;}
};
//editor class
var oEditor = function(){
var od = this.document;
if(od){
od.designMode = 'on';
od.open();
od.write('<html><head><style>html,body{margin:5px;font:12px/1.231 arial;cursor:text;}</style></head><body id="easyrt_body"></body></html>');
od.close();
}
if(document.attachEvent){
this.document.attachEvent("onmousedown",function(){oBox.popup.hide();});
this.document.body.attachEvent("onblur",function(){oBox.getValue();});
}else{
this.document.addEventListener("mousedown",function(){oBox.popup.hide();},false);
this.document.addEventListener("blur",function(){oBox.getValue();},false);
}
};
//toolbar class
var oToolbar = function(){
this.cmdBtn = null;
this.insertBtn = function(){};
this.onmousedown = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
if(dtarg.tagName=='A'){
if(this.cmdBtn){this.cmdBtn.style.cssText='';}
this.cmdBtn = dtarg;
dtarg.style.cssText = 'position:relative;top:1px;left:1px;';
stopEvent(e);
}
};
this.onmouseup = function(){if(this.cmdBtn){this.cmdBtn.style.cssText='';}};
this.onclick = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
if(dtarg.tagName=='A'){
var scmd = dtarg.getAttribute('href').replace(/.*\//g,'');
if(oBox.toollist[scmd]){oBox.toollist[scmd].cmd();}
}
stopEvent(e);
};
};
//popup class
var oPopup = function(){
this.show = function(ileft,itop,sc){
this.innerHTML = sc;
this.style.left = ileft+'px';
this.style.top = itop+'px';
this.style.visibility = 'visible';
};
this.hide = function(){this.innerHTML='';this.style.visibility = 'hidden';};
};
//execCommand
var exec = function(cmd,svalue){
var od = oBox.editor.document;
if(cmd=='hilitecolor'){
try{
od.execCommand(cmd,false,svalue);
}catch(exp){
od.execCommand('backcolor',false,svalue);
}
}else{
od.execCommand(cmd,false,svalue);
}
};
//color pad
var colorPad = function(){
var getRGB = function(aRGB){
var srgb = '';
for(var s=0;s<aRGB.length;s++){
var stmp = aRGB[s].toString(16);
stmp = (stmp.length<2)?'0'+stmp:stmp;
srgb = srgb+''+stmp;
}
return srgb;
};
var dct = [],rgb = [0,0,0];
for(var i=0;i<6;i++){
var atmpI = [];
for(var r=0;r<6;r++){
for(var c=0;c<6;c++){
var srgb = getRGB(rgb);
atmpI.push('<a href="#" style="color:#'+srgb+';background:#'+srgb+';" title="#'+srgb+'"> </a>');
rgb[1] += 51;
if(rgb[1]>255){rgb[1]=0}
}
rgb[2] += 51;
if(rgb[2]>255){rgb[2]=0}
}
dct.push('<div>'+atmpI.join('')+'</div>');
rgb[0] += 51;
if(rgb[0]>255){rgb[0]=0}
}
return '<div class="colorpad">'+dct.slice(0).join('')+'<a href="#" title="#000000" class="normalcolor">#000000</a></div>';
}();
//face
var ssrc = oBox.imgurl+'face/';
var adetail = ['高興','難過','眨眼','咧嘴傻笑','眨眨眼睫毛','困擾','迷戀','害羞','伸舌頭','親親','驚訝','生氣','沾沾自喜','有型','擔心','抹汗','嚎啕大哭','開懷大笑','嚴肅','古古惑惑','天使','晕','唉...','快睡著了','憧憬','生病了','這是秘密','不跟你說!','別賴我!','嘻嘻','不耐煩了','流口水','嗯..我想想看!','是這樣喔?','不想看','掌聲鼓勵!'];
var sface = new Array(adetail.length+1).join(0).replace(/0/g,function(){var inb=arguments[1],snb=inb+1;return '<a href="#" alt="'+snb+'" title="'+adetail[inb]+'" style="background:url('+ssrc+snb+'.gif) center center no-repeat;">&bsp;</a>'});
sface = '<div class="facepad">'+sface+'</div>';
//popup click function
var fooExec = function(ileft,itop,shtml){
oBox.popup.show(ileft,itop,shtml);
oBox.popup.onclick = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
if(dtarg.tagName=='A'){
var scmd = dtarg.getAttribute('href').replace(/.*\//g,'');
exec(scmd);
oBox.popup.hide();
}
stopEvent(e);
};
};
//fore color back color pick
var fooColor = function(scmd,scolor,ileft,itop,shtml){
oBox.popup.show(ileft,itop,shtml);
var dcolors = oBox.popup.getElementsByTagName('a');
var dcolor = dcolors[dcolors.length-1];
oBox.popup.onmouseover = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
if(dtarg.tagName=='A'){
var srbg = dtarg.getAttribute('title');
dcolor.innerHTML = srbg;
}
};
oBox.popup.onmouseout = function(){dcolor.innerHTML = scolor;dcolor.setAttribute('title',scolor);};
oBox.popup.onclick = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
if(dtarg.tagName=='A'){
var srbg = dtarg.getAttribute('title');
exec(scmd,srbg);
oBox.popup.hide();
}
stopEvent(e);
};
};
//insert html
var editor_paste = function(shtml){
if(document.selection){
var w = oBox.editor;
w.focus();
var range = w.document.selection.createRange();
if(range.pasteHTML){
range.pasteHTML(shtml);
}else{
try{pasteIM(shtml)}catch(exp){}
}
}else{
pasteIM(shtml);
}
}
var pasteIM = function(shtml){
var w = oBox.editor;
w.focus();
var ol,i,nl=[],r=w.document.createRange();
if(shtml==""){return;}
w.document.execCommand("insertimage",false,"http://easyrt/");
ol=w.document.getElementsByTagName("img");
for(var i=0;i<ol.length;i++){nl.push(ol[i]);}
for(i=0;i<nl.length;i++){
if(nl[i].src=="http://easyrt/"){
r.setStartBefore(nl[i]);
nl[i].parentNode.insertBefore(r.createContextualFragment(shtml),nl[i]);
nl[i].parentNode.removeChild(nl[i]);
}
}
};
//get current style
var getCurrentStyle = function(oEl,oSt){
if(oEl.currentStyle){
switch(oSt){
case 'width':
return oEl.offsetWidth;break;
case 'height':
return oEl.offsetHeight;break;
default:
return oEl.offsetWidth;break;
}
return oBox.box.currentStyle[oSt];
}else{
return window.getComputedStyle(oEl,null).getPropertyValue(oSt);
}
};
//the cmd list which need show in popup
var special = function(scmd){
switch(scmd){
case 'forecolor':
fooColor('forecolor','#000000',108,32,colorPad);
break;
case 'backcolor':
fooColor('hilitecolor','#ffffff',138,32,colorPad);
break;
case 'face':
oBox.popup.show(168,32,sface);
oBox.popup.onclick = function(e){
e = e||window.event;
var dtarg = e.srcElement||e.target;
没有合适的资源?快使用搜索试试~ 我知道了~
easyrt 简单的网页编辑器
共39个文件
gif:36个
png:1个
css:1个
4星 · 超过85%的资源 需积分: 9 141 下载量 116 浏览量
2009-02-01
19:01:41
上传
评论
收藏 54KB RAR 举报
温馨提示
easyrt 简单的网页编辑器,easyrt 简单的网页编辑器
资源推荐
资源详情
资源评论
收起资源包目录
easyrt 简单的网页编辑器.rar (39个子文件)
easyRT
skin
face
13.gif 809B
5.gif 1KB
27.gif 3KB
31.gif 2KB
2.gif 1001B
20.gif 821B
1.gif 1KB
8.gif 2KB
3.gif 1001B
12.gif 5KB
6.gif 3KB
11.gif 2KB
17.gif 2KB
23.gif 1KB
18.gif 646B
28.gif 1014B
9.gif 845B
7.gif 2KB
30.gif 4KB
29.gif 10KB
14.gif 1017B
4.gif 536B
22.gif 613B
35.gif 3KB
21.gif 8KB
36.gif 1KB
16.gif 4KB
26.gif 2KB
25.gif 1KB
32.gif 595B
15.gif 1KB
24.gif 1KB
10.gif 1KB
33.gif 987B
19.gif 613B
34.gif 1KB
easyrt.css 3KB
ico_toolbar.png 2KB
easyrt.html 13KB
共 39 条
- 1
kittyjie
- 粉丝: 237
- 资源: 1614
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页