?? util.js
字號:
function centerWindow(w,h){
window.moveTo((screen.width-w)/2,(screen.height-h)/2);
}/*
==================================================================
數組類型定義
==================================================================
*/
function array(size){
this.isArray=true;
this.length=size;
for(i=0;i<size;i++){
this[i]=0;
}
}
array.prototype.add=function(number){
this.length+=1;
this[this.length-1]=number;
}
array.prototype.clear=function(){
this.length=0;
}
array.prototype.toString=function(){
var ret="[";
for(i=0;i<this.length;i++){
if(i==0){
ret+=this[i];
}else{
ret+=","+this[i];
}
}
ret+="]";
return ret;
}
/*
==================================================================
LTrim(string):去除左邊的空格
==================================================================
*/
function LTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(0)) != -1)
{
var j=0, i = s.length;
while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
{
j++;
}
s = s.substring(j, i);
}
return s;
}
/*
==================================================================
RTrim(string):去除右邊的空格
==================================================================
*/
function RTrim(str)
{
var whitespace = new String(" \t\n\r");
var s = new String(str);
if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
{
var i = s.length - 1;
while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
{
i--;
}
s = s.substring(0, i+1);
}
return s;
}
/*
==================================================================
Trim(string):去除前后空格
==================================================================
*/
function Trim(str)
{
return RTrim(LTrim(str));
}
function getElement(name){
var objs=getElements(name);
if(objs.length>0){
return objs[0];
}else{
return null;
}
}
function getElements(name){
return document.getElementsByName(name);
}
function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function setLastlastVisitCookie ()
{
var rightNow = new Date();
var expdate = new Date();
expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
SetCookie ("lastVisit", rightNow.getTime(), expdate, "/");
}
function ResetCookie()
{
SetCookie("lastVisit", 0, null, "/");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -