📄 commoncheck.js
字号:
tmp = tmp.replace(/ /g, " ");
tmp = tmp.replace(/</g, "<");
tmp = tmp.replace(/>/g, ">");
//tmp = tmp.replace(/\'/g, "'");
tmp = tmp.replace(/\r\n/g, "</p><p>");
return tmp;
}
String.prototype.IsCn = function()
{
var ch,temp,isCN,isTrue;
isTrue = true;
for(var i=0;i<this.length;i++)
{
ch = this.substring(i,i+1);
temp = escape(ch);
isCN = (temp.length == 6)? true:false;
if(!isCN)
{
isTrue = false;
break;
}
}
return isTrue;
}
String.prototype.isCom_sep_char = function()
{
var myReg = /^[-()_+*]*$/;
if(myReg.test(this)) return true;
return false;
}
String.prototype.IsReg1 = function()
{
var s,i;
for(i=0;i<this.length;i++){
s=this.charAt(i);
if(s.IsNumber() || s.IsEn() || s.IsCn()) continue;
return false;
}
return i?true:false;
}
String.prototype.IsReg12 = function()
{
var s,i;
for(i=0;i<this.length;i++){
s=this.charAt(i);
if(s.IsNumber() || s.IsEn() || s.IsCn() || s.isCom_sep_char()) continue;
return false;
}
return i?true:false;
}
String.prototype.Trim = function()
{
var tmp = this.replace(/(^\s*)|(\s*$)/g, "");
return tmp.replace(/(^\2005-9-28*)|(\ *$)/g,"");
}
String.prototype.Left = function(n)
{
return strLeft(this,n);
}
String.prototype.Right = function(n)
{
return strRight(this,n);
}
String.prototype.Len = function()
{
var len=0;
for (var i=0;i<this.length;i++){
if (this.charCodeAt(i)>255) len+=2;
else len++;
}
return len;
}
String.prototype.Text = function()
{
var elm = document.createElement("DIV");
elm.innerHTML = this;
return elm.innerText;
}
String.prototype.Html = function()
{
var elm = document.createElement("DIV");
elm.innerText = this;
return elm.innerHTML;
}
String.prototype.Escape = function()
{
return escape(this);
}
String.prototype.UnEscape = function()
{
return unescape(this);
}
String.prototype.toInt = function()
{
return parseInt(this);
}
String.prototype.toFloat = function()
{
return parseFloat(this);
}
String.prototype.toHex = function(){
if(!this.IsNumber()) return "";
var x=parseInt(this);
var out = "";
var remainder;
while (x > 0){
remainder = x % 16;
if (remainder < 10){
out = remainder + out;
} else if (remainder == 10){
out = "a" + out;
} else if (remainder == 11){
out = "b" + out;
} else if (remainder == 12){
out = "c" + out;
} else if (remainder == 13){
out = "d" + out;
} else if (remainder == 14){
out = "e" + out;
} else if (remainder == 15){
out = "f" + out;
}
x = Math.floor(x / 16);
}
return out;
}
String.prototype.toDate = function()
{
ActRs.Clear();
this.IsDate();
return new Date(ActRs[0],ActRs[1]-1,ActRs[2]);
}
String.prototype.Hexto = function()
{
var myReg = /^[0-9a-fA-F]+$/;
if(!myReg.test(this)) return "0";
ActRd=parseInt(this,16);
return ""+ActRd;
}
String.prototype.Octto = function()
{
var myReg = /^[0-7]+$/;
if(!myReg.test(this)) return "0";
ActRd=parseInt(this,8);
return ""+ActRd;
}
String.prototype.Binto = function()
{
var myReg = /^[0-1]+$/;
if(!myReg.test(this)) return "0";
ActRd=parseInt(this,2);
return ""+ActRd;
}
String.prototype.Repeat = function(n){
if (typeof(n) != "number") return "";
var out = this;
for (var i = 1; i < n; i++) out += this;
return out;
}
String.prototype.Reverse = function(){
var out = "";
for (var i = this.length; i >= 0; i--){
out += this.charAt(i);
}
return out;
}
String.prototype.Comp = function(str,m)
{
return Compstr(this,str,m);
}
String.prototype.addDate = function(mode,d)
{
return addDate(mode,d,this);
}
String.prototype.Count = function(){
var out = new Array(256);
for (var i = 0; i < this.length; i++){
if (out[this.charCodeAt(i)] == undefined){
out[this.charCodeAt(i)] = 1;
} else {
out[this.charCodeAt(i)]++;
}
}
return out;
}
function cutStr(str,strlen){
var temp_i=0;
var temp=0;
var temp_str="";
for(temp_i=0;temp_i<str.length;temp_i++){
if(Math.abs(str.charCodeAt(temp_i))>255)
temp+=2;
else
temp+=1;
if(temp>strlen) {
temp_str=str.substr(0,temp_i)+"...";
break;
}
else{
temp_str=str;
}
}
return temp_str;
}
/**
*返回查询字符串 已经用encodeURI转码过
*输入 form对象
*输出 用encodeURI转码过查询字符串,最前边是没有&号的,如:str1=aaa&str2=bbb
*/
String.prototype.myEncode = function()
{
return this.replace(/\&/g, "%26").replace(/\?/g,"%3F").replace(/\#/g,"%23").replace(/\+/g,"%2B");
}
/**
*返回查询字符串 已经用encodeURI转码过
*输入 form对象
*输出 用encodeURI转码过查询字符串,最前边是没有&号的,如:str1=aaa&str2=bbb
*/
function generateQueryString(aform)
{
var qstr = "";
if (aform != null)
{
for (var i = 0 ; i < aform.length ; i++ )
{
//qstr += aform[i].name + "=" + escape(aform[i].value) + "&";
//qstr += aform[i].name + "=" + encodeURI(aform[i].value) + "&";
if (aform[i].type == "text" || aform[i].type == "textarea")
{
qstr += aform[i].name + "=" + aform[i].value.myEncode() + "&";
}
else if (aform[i].type == "radio")
{
if (aform[i].checked)
{
qstr += aform[i].name + "=" + aform[i].value.myEncode() + "&";
}
}
else if (aform[i].type == "checkbox")
{
if (aform[i].checked)
{
qstr += aform[i].name + "=" + aform[i].value.myEncode() + "&";
}
}
else if (aform[i].type == "button")
{
}
else {
qstr += aform[i].name + "=" + aform[i].value.myEncode() + "&";
}
}
if (qstr.length > 0 )
{
qstr = qstr.substring(0,qstr.length - 1);
}
}
return qstr;
}
//Cookie
function setCookie(name, value, path, domain) {
var curCookie = name + "=" + escape(value) +
"; expires=Thu, 6 Jan 2033 08:05:36 UTC" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "");
document.cookie = curCookie;
}
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return "";
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -