checkreply.js

来自「一个用Java编写的记事本源程序」· JavaScript 代码 · 共 91 行

JS
91
字号
function reply(){
document.getElementById('replyForm').action="/postReply.do";
if(document.getElementById('replyForm').txt.value.length > 1000){
alert("评论字数太多,不能发布");
document.getElementById('replyForm').txt.focus();
return false;
}
if(document.getElementById('replyForm').txt.value.length==''){
document.getElementById('replyForm').txt.focus();
return false;
}
//document.getElementById('replyForm').remark.value=document.getElementById('replyForm').remark.value.replace(/>/g,'>');
//document.getElementById('replyForm').remark.value=document.getElementById('replyForm').remark.value.replace(/</g,'&lt;');
document.all.remark.value=UBBCode(document.all.txt.value,"html");
if(document.getElementById('replyForm').remarker.value == null)
document.getElementById('replyForm').remarker.value = '匿名';
document.getElementById('replyForm').submit();
}

function popColor()
{ 
  addUBB("[color="+document.all.select2.value+"][/color]");
}
function addUBB(str)
{
  document.all.txt.value+=str;
}
function addImg()
{
  var txt=prompt("请输入图片地址","http://");
  if(txt!==null)
  {
  addUBB("[Img]"+txt+"[/Img]");
  }
}
function addLink()
{
  var txt=prompt("请输入连接地址","http://");
  if(txt!==null)
  {
   addUBB("[URL]"+txt+"[/URL]");
  }
}
function addMove()
{
  var txt=prompt("请输入文字","文字");
  if(txt!==null)
  {
  addUBB("[Move]"+txt+"[/Move]");
  }
}
function addFly()
{
  var txt=prompt("请输入文字","文字");
  if(txt!==null)
  {
  addUBB("[Fly]"+txt+"[/Fly]");
  }
}
function setSize()
{
  var temp=document.all.select.value;
  addUBB('[size='+temp+'][/size]');

}

function img_auto_size(oldimg,maxSize,openNewWindow){
	var newimg = new Image();
	newimg.src = oldimg.src;
	if (newimg.width > 0 && newimg.height > 0) {
		if (newimg.width > maxSize){ 
			oldimg.width = maxSize;
			oldimg.height = (newimg.height * maxSize) / newimg.width;
			oldimg.onmouseover = function() {
				this.style.cursor= "hand";
			};
			oldimg.onmouseout = function() {
				this.style.cursor="";
			};
			if(openNewWindow){
				oldimg.onclick = function() {
					window.open(this.src, '_blank');
				};
			}
		} else {
			oldimg.width = newimg.width; 
			oldimg.height = newimg.height;
		}
		oldimg.alt = "Click to view in original size " + newimg.width + " x " + newimg.height;
	}
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?