📄 functions.asp
字号:
str = str.replace(/javascript:/ig, "javascript ");
str = str.replace(/jscript:/ig, "jscript ");
str = str.replace(/vbscript:/ig, "vbscript ");
str = str.replace(/\<|\>/ig, " ");
return str;
}
// Word Filter ----------------------------------------------
this.wordFilter = function(str){
if(str==null){ return false; }
if(str.length<3){ return str; }
for(var i=0;i<theCache.wordFilter.length;i++){
with(theCache.wordFilter[i]){
var ctext= isRegExp ? text :this.stringToRegExp(text);
ctext=new RegExp(ctext,"gi");
if(mode==0){
str=str.replace(ctext,replace);
}else{
if(str.search(ctext)>-1){
return false;
}
}
}
}
return str;
}
// Random String Generator ----------------------------------
this.randomStr = function(intLength, strSeed){
if(strSeed==null){strSeed = "abcdefghijklmnopqrstuvwxyz1234567890";}
var seedLength=strSeed.length;
var str="";
for(var i=0;i<intLength;){
var pos=Math.round((Math.random()*seedLength));
if(pos>=0&&pos<seedLength){
str+=strSeed.charAt(pos);
i++;
}
}
return str;
}
// The SHA1 function ----------------------------------------
this.SHA1 = function(str){
var inbird=true;
</script>
<!--#include file="sha1.asp"-->
<script language="JScript" runAt="server">
return SHA1(str);
}
// The MD5 function -----------------------------------------
this.MD5 = function(str){
var inbird=true;
</script>
<!--#include file="md5.asp"-->
<script language="JScript" runAt="server">
return MD5(str);
}
// DateTime Output function ---------------------------------
// YY: Full Year yy: Short Year
// MM: Numberic Month with 0 mm: Numberic Month
// M: Month Name m: Short Month Name
// DD: Numberic Date with 0 dd: Numberic Date
// W: Weekday Name w: Short Weekday Name
// hh: Numberic Hour with 0 HH: Numberic Hour
// h: 12 Hour Format with 0 H: 12 Hour Format
// ii: Numberic Minute with 0 II: Numberic Minute
// ss: Numberic Second with 0 SS: Numberic Second
// Z: Full TimeZone Offset z: Short TimeZone Offset
// ZZ: Full Offset with "Z" zz: Short Offset with "Z"
this.getDateTimeString = function(strFormat, objDate, bEnglishNames){
var t=new Array();
t["weekday_0"]="Sunday";
t["weekday_1"]="Monday";
t["weekday_2"]="Tuesday";
t["weekday_3"]="Wednesday";
t["weekday_4"]="Thursday";
t["weekday_5"]="Friday";
t["weekday_6"]="Saturday";
t["weekday_abbr_0"]="Sun";
t["weekday_abbr_1"]="Mon";
t["weekday_abbr_2"]="Tue";
t["weekday_abbr_3"]="Wed";
t["weekday_abbr_4"]="Thu";
t["weekday_abbr_5"]="Fri";
t["weekday_abbr_6"]="Sat";
t["month_1"]="January";
t["month_2"]="February";
t["month_3"]="March";
t["month_4"]="April";
t["month_5"]="May";
t["month_6"]="June";
t["month_7"]="July";
t["month_8"]="August";
t["month_9"]="September";
t["month_10"]="October";
t["month_11"]="November";
t["month_12"]="December";
t["month_abbr_1"]="Jan";
t["month_abbr_2"]="Feb";
t["month_abbr_3"]="Mar";
t["month_abbr_4"]="Apr";
t["month_abbr_5"]="May";
t["month_abbr_6"]="Jun";
t["month_abbr_7"]="Jul";
t["month_abbr_8"]="Aug";
t["month_abbr_9"]="Sep";
t["month_abbr_10"]="Oct";
t["month_abbr_11"]="Nov";
t["month_abbr_12"]="Dec";
if(objDate==null){
objDate=new Date();
}
if(strFormat==null||strFormat==""){
strFormat="YY-MM-DD hh:ii:ss";
}
var tYear=objDate.getFullYear();
var tMonth=objDate.getMonth()+1;
var tDate=objDate.getDate();
var tDay=objDate.getDay();
var tHour=objDate.getHours();
var tHour12= tHour>12 ? tHour-12 : tHour;
var tMinute=objDate.getMinutes();
var tSecond=objDate.getSeconds();
var tAMPM= tHour>12 ? "PM" : "AM";
var tZone=objDate.getTimezoneOffset();
if(tZone==0){
tZone="Z";
}else{
tZone = Math.abs(Math.round(tZone/60));
tZone = (objDate.getTimezoneOffset() <0 ? "+":"-") + (tZone<10 ? "0"+tZone : tZone);
}
// Year
strFormat=strFormat.replace(/([^\\]|^)YY/g, "$1"+tYear);
strFormat=strFormat.replace(/([^\\]|^)yy/g, "$1"+tYear.toString().substr(0,2));
// Month
if(tMonth<10){
strFormat=strFormat.replace(/([^\\]|^)MM/g,"$1"+"0"+tMonth);
}else{
strFormat=strFormat.replace(/([^\\]|^)MM/g,"$1"+tMonth);
}
strFormat=strFormat.replace(/([^\\]|^)mm/g,"$1"+tMonth);
// Date
if(tDate<10){
strFormat=strFormat.replace(/([^\\]|^)DD/g,"$1"+"0"+tDate);
}else{
strFormat=strFormat.replace(/([^\\]|^)DD/g,"$1"+tDate);
}
strFormat=strFormat.replace(/([^\\]|^)dd/g,"$1"+tDate);
// Hour
if(tHour<10){
strFormat=strFormat.replace(/([^\\]|^)hh/g,"$1"+"0"+tHour);
}else{
strFormat=strFormat.replace(/([^\\]|^)hh/g,"$1"+tHour);
}
strFormat=strFormat.replace(/([^\\]|^)HH/g,"$1"+tHour);
strFormat=strFormat.replace(/([^\\]|^)H/g,"$1"+tHour12);
strFormat=strFormat.replace(/([^\\]|^)h/g,"$1"+(tHour12<10 ? "0"+tHour12 : tHour12));
// Minute
if(tMinute<10){
strFormat=strFormat.replace(/([^\\]|^)ii/g,"$1"+"0"+tMinute);
}else{
strFormat=strFormat.replace(/([^\\]|^)ii/g,"$1"+tMinute);
}
strFormat=strFormat.replace(/([^\\]|^)II/g,"$1"+tMinute);
// second
if(tSecond<10){
strFormat=strFormat.replace(/([^\\]|^)ss/g,"$1"+"0"+tSecond);
}else{
strFormat=strFormat.replace(/([^\\]|^)ss/g,"$1"+tSecond);
}
strFormat=strFormat.replace(/([^\\]|^)SS/g,"$1"+tSecond);
// AM PM
strFormat=strFormat.replace(/([^\\]|^)A/g,"$1"+tAMPM);
strFormat=strFormat.replace(/([^\\]|^)a/g,"$1"+tAMPM.toLowerCase());
// Time Zone Offset
strFormat=strFormat.replace(/([^\\]|^)Z/g,"$1"+tZone+"00");
strFormat=strFormat.replace(/([^\\]|^)z/g,"$1"+tZone);
// Month & Weekday Names
if(bEnglishNames){
strFormat=strFormat.replace(/([^\w]|^)M([^\w]|$)/g,"$1"+t["month_"+tMonth]+"$2");
strFormat=strFormat.replace(/([^\w]|^)m([^\w]|$)/g,"$1"+t["month_abbr_"+tMonth]+"$2");
strFormat=strFormat.replace(/([^\w]|^)W([^\w]|$)/g,"$1"+t["weekday_"+tDay]+"$2");
strFormat=strFormat.replace(/([^\w]|^)w([^\w]|$)/g,"$1"+t["weekday_abbr_"+tDay]+"$2");
}else{
strFormat=strFormat.replace(/([^\w]|^)M([^\w]|$)/g,"$1"+lang["month_"+tMonth]+"$2");
strFormat=strFormat.replace(/([^\w]|^)m([^\w]|$)/g,"$1"+lang["month_abbr_"+tMonth]+"$2");
strFormat=strFormat.replace(/([^\w]|^)W([^\w]|$)/g,"$1"+lang["weekday_"+tDay]+"$2");
strFormat=strFormat.replace(/([^\w]|^)w([^\w]|$)/g,"$1"+lang["weekday_abbr_"+tDay]+"$2");
}
return strFormat;
}
// Parse DateTime String "2005-05-10 11:18:45" ---------------------------------
this.parseDateTime = function(strDateTime){
var theDate=new Date();
var iNum=0;
var strDate;
var strTime;
strDateTime=strDateTime.split(" ");
if(strDateTime.length==2){
strDate=strDateTime[0];
strTime=strDateTime[1];
}else if(strDateTime.length=1){
strDate=strDateTime[0];
strTime="";
}else{
return null;
}
strDate=strDate.split("-");
if(strDate.length!=3){
return null;
}else{
iNum=parseInt(strDate[0],10);
if(iNum!=NaN) theDate.setFullYear(iNum);
iNum=parseInt(strDate[1],10);
if(iNum!=NaN) theDate.setMonth(iNum-1);
iNum=parseInt(strDate[2],10);
if(iNum!=NaN) theDate.setDate(iNum);
}
strTime=strTime.split(":");
if(strTime.length==3){
iNum=parseInt(strTime[0],10);
if(iNum!=NaN) theDate.setHours(iNum);
iNum=parseInt(strTime[1],10);
if(iNum!=NaN) theDate.setMinutes(iNum);
iNum=parseInt(strTime[2],10);
if(iNum!=NaN) theDate.setSeconds(iNum);
}
return theDate;
}
// Generate Page Links -------------------------------------------------
this.generatePageLinks = function(intEntryCount, intPageSize, intCurrentPage, intShowPages, urlPrefix, urlSuffix){
var maxPage=Math.floor((intEntryCount-1)/intPageSize)+1;
var output="";
urlPrefix += urlPrefix=="?" ? "" : "&";
if(urlSuffix==null) urlSuffix="";
//intShowPages=(intShowPages%2==1)? intShowPages+1 : intShowPages; // Should be Even Number
// Calculate Page Bounds
var prevBound=intCurrentPage-Math.floor(intShowPages/2);
var nextBound=intCurrentPage+Math.floor(intShowPages/2);
if(prevBound<=0){
prevBound=1;
nextBound=intShowPages;
}
if(nextBound>maxPage){
nextBound=maxPage;
prevBound=maxPage-intShowPages;
}
if(prevBound<=0) prevBound=1;
if(maxPage==1){
output="<span class=\"pagelink-current\"> 1 </span>";
}else{
// First Page Link
if(prevBound>1) output+="<a href=\"" + urlPrefix + "page=1" + urlSuffix + "\"> << </a> | \n";
// Previous Page Link
if(intCurrentPage>1) output+="<a href=\"" + urlPrefix + "page=" + (intCurrentPage-1) + urlSuffix + "\"> < </a> | \n";
// Process Main Portion
for(var i=prevBound;i<=nextBound;i++){
if(intCurrentPage==i){
output+="<span class=\"pagelink-current\">" + i + "</span> | \n";
}else if(i<=maxPage){
output+="<a href=\"" + urlPrefix + "page=" + i + urlSuffix + "\"> " + i + " </a> | \n";
}
}
// Next Page Link
if(intCurrentPage<maxPage) output+="<a href=\"" + urlPrefix + "page=" + (intCurrentPage+1) + urlSuffix + "\"> > </a>\n";
// Last Page Link
if(nextBound<maxPage) output+=" | <a href=\"" + urlPrefix + "page=" + maxPage + urlSuffix + "\"> >> </a>\n";
}
return output;
}
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -