editor.jsp
来自「一个用java编写的功能强大的OA系统」· JSP 代码 · 共 469 行 · 第 1/2 页
JSP
469 行
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="cn.js.fan.util.*"%>
<%
int w = 400;
int h = 200;
try {
w = ParamUtil.getInt(request, "width");
h = ParamUtil.getInt(request, "height");
}
catch (Exception e) {}
%>
<HTML xmlns:v = "urn:schemas-microsoft-com:vml">
<HEAD><TITLE>手写板 - Powerd by softpure.com</TITLE>
<!--
纯粹手写板 V1.2
提供: 纯粹空间 http://www.softpure.com
作者: 暖阳
-->
<STYLE type=text/css>
v\:* { behavior: url(#default#VML); }
*{ font-size:12px; }
body {
background-color: #E3EFF9;
margin:5px;
}
#codeTable{
background-color: #E3EFF9;
display:none;
}
body,select, input, td {
font-size: 12px;
}
hr {
width: 150px;
}
#ColorTable{
border: 2px outset;
}
.colorvalue{
width: 8px;
height: 8px;
cursor: crosshair;
}
.colorvalue div{
width:8px;
height:8px;
overflow:hidden;
font-size:8px;
padding:0px;
color:red;
}
a{
color: #333399;
}
form{
margin:0px;
padding: 0px;
}
.tool{
color: #666699;
}
.btn{
background-color: #E3EFF9;
border:solid 1px #FFF;
border-color:#FFF #888 #888 #FFF;
margin:0 1px 1px 0;
padding-top:2px;
}
.btn_on{
background-color:#EFF6FF;
border:1px solid #FFFFF;
border-color:#60A5DD #FFF #FFF #60A5DD;
color: #6633FF;
margin:0 1px 1px 0;
padding-top:3px;
}
.input{
border:1px solid #FFFFF;
border-color:#60A5DD #FFF #FFF #60A5DD;
}
</STYLE>
</HEAD>
<BODY onLoad="active_colorpicker();document.forms[0].reset();selectToolShape('shape');" oncontextmenu="var tagName=event.srcElement.tagName.toLowerCase();return (tagName=='textarea' || tagName=='input' || tagName=='img');">
<table width="100%" id="codeTable" border="0" cellspacing="3" cellpadding="0">
<tr>
<td valign="top">
图形代码 <a href="#" onClick="alert('当前长度: '+document.getElementById('value_codetext').value.length+' 字符');">[字数检查]</a> :<br />
<textarea name="value_codetext" id="value_codetext" style="width:100%; height:200px; word-break: break-all" class="input"></textarea>
<br />
<center>
<input type="button" value="复制" class="btn" onClick="e=document.getElementById('value_codetext').createTextRange();e.expand('textedit');e.execCommand('copy');alert('代码已复制到剪帖板');" >
<input type="button" value="粘贴" class="btn" onClick="e=document.getElementById('value_codetext').createTextRange();e.execCommand('paste');" >
<input type="button" value=" 代码生成图形 " class="btn" onClick="document.frames[0].location.reload();codeTableShow(0);" >
<input type="button" value=" 返回编辑界面 " class="btn" onClick="codeTableShow(0);" >
</center>
</td>
</tr>
</table>
<script language="javascript" src="createShapes.js"></script>
<SCRIPT language=JavaScript>
window.onerror = function(){ return true;}
function getQueryString(key,locString){
var reg = new RegExp("(\\?|\\&)" + key + "=([^\\&\\#]*)([\\&\\#]?)", "i").exec(locString);
return RegExp.$2;
}
try{
var name = getQueryString('name',window.location.href);
var obj = window.opener.document.getElementsByName(name)[0];
document.getElementById('value_codetext').value = ((obj.caretPos&&obj.caretPos.text)?obj.caretPos.text:'');
}catch(e){}
function dec_spcode(c,spcodeChars){ //数字=>纯粹码
var len = spcodeChars.length;
if(c<len) return '0' + spcodeChars.charAt(c);
else if(c<len*len) return spcodeChars.charAt(parseInt(c/len)) + spcodeChars.charAt(c%len);
}
function make_code(){
try{
var props = ('tagName=shape;style.left=0;style.top=0;style.width=1600;style.height=1200;coordsize=1600,1200;fillcolor;strokecolor=black;strokeweight=1.5;path').split(';');
var f = document.frames[0];
var i,j,obj;
var code = '';
var lastValues = new Array(props.length-1);
for(i=1;i<=f.teller;i++){
var shape = f.document.getElementById('nr'+i);
if(!shape) continue;
if(code) code += "|";
for(j=0;j<props.length;j++){
var prop_arr = props[j].split('=',2);
if(i==1 && prop_arr[1]) lastValues[j]=prop_arr[1];
eval("value=shape."+prop_arr[0]+";");
if(value) value +='' ; else value='';
if(typeof(value)=='undefined') value='';
if(prop_arr[0]=='fillcolor' && shape.filled==false) value='';
else if(prop_arr[0]=='strokecolor' && shape.stroked==false) value='';
else if(prop_arr[0]=='path' && value.match(/^(\s*m)(.+)(e\s*)$/)){
value = value.replace(/[^\d]+$/,'').replace(/([^\d]+)(\d+)/g, function(a,b,c){ return dec_spcode(c,spcodeChars); } );
}
else if(value==parseInt(value)+'px') value = parseInt(value);
if(value==lastValues[j]) value = '*';
else lastValues[j] = value;
code += value+(j<props.length-1&&value!='*' ? ';' : '');
}
}
code = code.replace(/(\*{4,})/g,function(a){ return '*'+a.length+'/' });
}catch(e){ }
return code;
}
function insertAtCaret(textEl, text){
if (textEl.createTextRange && textEl.caretPos){
var caretPos = textEl.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
} else if(textEl) {
textEl.value += text;
} else {
textEl.value = text;
}
}
function returnVal(){
var code=make_code();
if(code){
/*
try{
var name = getQueryString('name',window.location.href);
var obj = window.opener.document.getElementsByName(name)[0];
insertAtCaret(obj,'[whitepad]'+code+'[/whitepad]');
}catch(e){
document.getElementById('value_codetext').value = '[whitepad]'+code+'[/whitepad]';
codeTableShow(1);
alert("找不到输入框,返回失败.");
return false;
}
*/
window.opener.insertStroke('[whitepad]'+code+'[/whitepad]', <%=w%>, <%=h%>);
}
window.close();
}
function codeTableShow(s){
var c = document.getElementById('codeTable');
var e = document.getElementById('editTable');
if(s==1){
c.style.width = e.offsetWidth;
c.style.height = e.offsetHeight;
c.style.display = 'block';
e.style.display = 'none';
}else{
c.style.display = 'none';
e.style.display = '';
}
}
obj_colorpicker = '';
redo_array = new Array();
function active_colorpicker(){
var cellen = document.getElementsByTagName('td');
for(var i = 0; i < cellen.length; i++){
if(cellen[i].className == 'colorvalue'){
cellen[i].onclick = do_pickcolor;
cellen[i].onmousemove = function(){ document.getElementById('colorShow').style.backgroundColor=this.bgColor; }
}
}
}
function start_pickcolor(obj){
if(obj_colorpicker==obj){
do_pickcolor('null');
return;
}
if(obj_colorpicker != ''){ return;}
document.getElementById('ColorTableDiv').style.display='';
obj_colorpicker = obj;
}
function do_pickcolor(color){
if(obj_colorpicker == '') return;
if(color||color==='') var colorvalue = color;
else var colorvalue = this.bgColor;
var HTML = colorvalue ? '':'透明';
document.forms[0].elements[obj_colorpicker + 'value'].value = colorvalue;
document.getElementById(obj_colorpicker + '_cel').innerHTML = HTML;
document.getElementById(obj_colorpicker + '_cel').style.backgroundColor = colorvalue ? colorvalue : '#FFFFFF';
hideColorTableDiv(1);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?