?? utility.v1193312278.js
字號:
/*utility.js
* based on mootools v1.0
* wirtten by easy.lv
* some useful extention
*/
/*
* Responsebility : count the num you have inputed or the num you can input now in one input area
*
* count_container_id: your input area id
* showtype: 1:show the num now;2: show the num left to the maxnum
* maxunm:if your showtype=2,this is the max num you can input into the input area
* fill_container_id:the area you want to show the text about the num or the num left
*/
var Count_input_num = function(count_container_id,showtype,maxnum,fill_container_id,ChineseWordsLength,baseon)
{
if(typeof count_container_id == 'string'){
this.ccid = $(count_container_id);
}else{
this.ccid = count_container_id;
}
if(typeof fill_container_id == 'string'){
this.fcid = $(fill_container_id);
}else{
this.fcid = fill_container_id;
}
this.showtype = showtype;
this.maxnum = maxnum;
if(ChineseWordsLength=='')
{
ChineseWordsLength = 2;
}
this.ChineseWordsLength = ChineseWordsLength;
this.ccid.maxlength = this.maxnum;
this.count();
if(baseon = 'prototype')
{
this.ccid.onkeyup = this.count.bindAsEventListener(this);
}else
{
this.ccid.onkeyup = this.count.bindWithEvent(this);
}
};
Count_input_num.prototype.count = function()
{
var replaceword = '';
for(var i=0;i<this.ChineseWordsLength;i++)
{
replaceword = replaceword + '*';
}
this.num = this.ccid.value.replace(/[^\x00-\x80]/ig,replaceword).length;
if(this.showtype == 2)
{
this.left = this.maxnum - this.num;
}
this.showresult();
};
Count_input_num.prototype.showresult = function()
{
if(this.fcid=='')
{
return;
}
if(this.showtype == 1)
{
var str = '現在已經輸入'+this.num+'字符';
if(this.ChineseWordsLength>1) str+='(1個漢字等于'+this.ChineseWordsLength+'個字符)';
this.fcid.innerHTML = str;
}
if(this.showtype == 2)
{
if(this.left<0)
{
this.fcid.style.color = "#D50000";
var str = '還可以輸入'+this.left+'字符';
if(this.ChineseWordsLength>1) str+='(1個漢字等于'+this.ChineseWordsLength+'個字符)';
str += ',超過最大長度';
this.fcid.innerHTML = str;
}else
{
this.fcid.style.color = "#999999";
var str = '還可以輸入'+this.left+'字符';
if(this.ChineseWordsLength>1) str+='(1個漢字等于'+this.ChineseWordsLength+'個字符)';
this.fcid.innerHTML = str;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -