function usernamecheck(string){
if((string.length<4)||(string.length>20)){return false;}
var re;
re=new RegExp("^[a-z|A-Z|0-9][a-z|A-Z|0-9|-]+$");
return re.test(string);
}
function passwordcheck(string){
var re;
re=new RegExp("^[0-9]+$");
return !re.test(string);
}
function addBookmark(title,url) {
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}
function urlcheck(string){
var re;
re=new RegExp("http://");
return re.test(string.toLowerCase());
}
function emailcheck(string){
var re;
re=new RegExp("^[\\w-_\\.]+@([a-z|0-9|-]+\\.)+[a-z]{2,5}$");
return re.test(string.toLowerCase());
}
function toclick(objid){
var obj=document.getElementByIdx_xx_xx(objid);
if(document.all){
obj.fireEvent("onclick");
}else{
var e=document.createEvent('MouseEvent');
e.initEvent('click',false,false);
obj.dispatchEvent(e);
}
}
function getCookie(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re)){
return document.cookie.match(re)[0].split("=")[1];
}else{
return "";
}
}
function setCookie(name, value){
document.cookie = name+"="+value
}
function strlen(string){
var str="";
str=string;
str=str.replace(/[^\x00-\xff]/g,"**");
return str.length;
}
function QuickPost(event){
if((event.ctrlKey && event.keyCode == 13)||(event.altKey && event.keyCode == 83)){
event.srcElement.form.submit();
}
}
function GSArrays(){
this.keys=new Array();
this.values=new Array();
this.set=function (key,value){
for(i=0;i
function SplitToArray(str){
var strs,tems;
var MyGs=new GSArrays();
strs=str.split("\n");
var arrays=new Array();
for(i=0;i
var text = "";
function getActiveText(selectedtext) {
text = (document.all) ? document.selection.createRange().text : document.getSelection();
if (selectedtext.createTextRange) {
selectedtext.caretPos = document.selection.createRange().duplicate();
}
return true;
}
function AddText(obj,NewCode)
{
if (obj.createTextRange && obj.caretPos)
{
var caretPos = obj.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? NewCode + ' ' : NewCode;
}
else
{
obj.value+=NewCode
}
setfocus(obj);
}
function setfocus(obj)
{
obj.focus();
}
function italicize(obj) {
if (document.selection && document.selection.type == "Text") {
AddTxt="[i]"+text+"[/i]";
AddText(obj,AddTxt);
} else {
txt=prompt('文字将变斜体','文字');
if (txt!=null) {
AddTxt="[i]"+txt+"[/i]";
AddText(obj,AddTxt);
}
}
}
function underline(obj) {
if (document.selection && document.selection.type == "Text") {
AddTxt="[u]"+text+"[/u]";
AddText(obj,AddTxt);
} else {
txt=prompt('下划线文字','文字');
if (txt!=null) {
AddTxt="[u]"+txt+"[/u]";
AddText(obj,AddTxt);
}
}
}
function center(obj) {
if (document.selection && document.selection.type == "Text") {
AddTxt="[align=center]"+text+"[/align]";
AddText(obj,AddTxt);
} else {
txt2=prompt('对齐样式\n输入 ’center’ 表示居中, ’left’ 表示左对齐, ’right’ 表示右对齐.',"center");
while ((txt2!="") && (txt2!="center") && (txt2!="left") && (txt2!="right") && (txt2!=null)) {
txt2=prompt('错误!\n类型只能输入 ’center’ 、 ’left’ 或者 ’right’.',"");
}
txt=prompt('要对齐的文本','文字');
if (txt!=null) {
AddTxt="[align="+txt2+"]"+txt+"[/align]";
AddText(obj,AddTxt);
}
}
}
function bold(obj) {
if (document.selection && document.selection.type == "Text") {
AddTxt="[b]"+text+"[/b]";
AddText(obj,AddTxt);
} else {
txt=prompt('文字将被变粗.','文字');
if (txt!=null) {
AddTxt="[b]"+txt+"[/b]";
AddText(obj,AddTxt);
}
}
}
function insimg(obj){
if (document.selection && document.selection.type == "Text") {
AddTxt="[img]"+text+"[/img]";
AddText(obj,AddTxt);
} else {
txt=prompt('请输入图片完整URL地址:','http://');
if (txt!=null) {
AddTxt="[img]"+txt+"[/img]";
AddText(obj,AddTxt);
}
}
}
function insurl(obj,is){
if (document.selection && document.selection.type == "Text") {
AddTxt="[url]"+text+"[/url]";
AddText(obj,AddTxt);
} else {
if(is==1){
txt=prompt('请输入本站站内URL:','http://www.guaishow.com');
}else{
txt=prompt('请输入URL地址:','http://');
}
if (txt!=null) {
AddTxt="[url]"+txt+"[/url]";
AddText(obj,AddTxt);
}
}
}
function ToolBars(areaname,isimg,insite){
document.write("");
document.write(" ");
document.write(" ");
document.write(" ");
if(isimg){
document.write(" ");
}
if(insite){
document.write(" ");
}else{
document.write(" ");
}
document.write("
");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
document.write("");
}
function InputNum(event){
//48~57 主键盘数字 96~105 小键盘数字 144 小键盘数字切换键 110 小键盘 点
if((event.keyCode>=48 && event.keyCode<=57) || (event.keyCode>=96 && event.keyCode<=105) || event.keyCode==144 || event.keyCode==110 || event.keyCode==190 || event.keyCode==8 || event.keyCode==46 || event.keyCode==39 || event.keyCode==37 || event.keyCode==13){
return true;
}else{
return false;
}
}
function CheckFloat(obj,pre){
thisfloat=parseFloat(obj.value);
if(isNaN(thisfloat)){
obj.value="0";
}else{
obj.value=Math.ceil(thisfloat*Math.pow(10,pre))/Math.pow(10,pre);
}
}
function CheckImg(ImgFile){
if(ImgFile){
if(ImgFile.lastIndexOf(".")>=0){
ext=ImgFile.substr(ImgFile.lastIndexOf(".")).toLowerCase();
exts="|.jpeg|.jpg|.gif|.png|";
if(exts.indexOf("|"+ext+"|")<0){
return false;
}else{
return true;
}
}else{
return false;
}
}else{
return true;
}
}
function CheckSize(ImgFile,MaxSize){
if(ImgFile){
var img=null;
if(img)img.removeNode(true);
img=document.createElement_x_x("img");
img.style.position="absolute";
img.style.display="none";
if(window.attachEvent){
img.attachEvent("onreadystatechange",orsc);
img.attachEvent("onerror",oe);
document.body.insertAdjacentElement("beforeend",img);
}else{
img.addEventListener("onreadystatechange",orsc,false);
img.addEventListener("onerror",oe,false);
document.body.appendChild(img)
}
img.src=ImgFile;
}
function oe(){
alert("指定图片载入失败");
}
function orsc(){
if(img.readyState!="complete"){return false;};
if(parseInt(img.fileSize)>MaxSize*1000){
alert("当前图片文件 "+img.fileSize/1000+" K\n超过最大限制"+MaxSize+"K\n\n强制提交将可能造成超时失败");
}
}
}
function ByteLength(string){
return string.replace(/[^\x00-\xff]/g,"00").length;
}
2016/4/21 20:15:36