Cookie. js
[Javascript]/**
* @ Name Cookie. js
* This should be an older cookie tool. If you want to save it with this tool class
* It's okay for unimportant things (such as status), so you don't need to think about the user name and password.
*/
/**
* Save
* @ Param {Object} name
* @ Param {Object} value
*/
JpkFrame. saveCookie = function (name, value ){
// Save for one month
Var saveDate = new Date (). getTime () + 30*24*3600*1000 );
// Console. log (saveDate. toUTCString ());
Cookies. set (name, value, saveDate );
}
/**
* Get
* @ Param {Object} name
*/
JpkFrame. getCookie = function (name ){
Return Cookies. get (name );
}
/**
* Clear
* @ Param {Object} name
*/
JpkFrame. clearCookie = function (name ){
Cookies. clear (name );
}
Var Cookies = {};
Cookies. set = function (name, value ){
Var argv = arguments;
Var argc = arguments. length;
Var expires = (argc> 2 )? Argv [2]: null;
Var path = (argc> 3 )? Argv [3]: '/';
Var domain = (argc> 4 )? Argv [4]: null;
Var secure = (argc> 5 )? Argv [5]: false;
Document. cookie = name + "=" + encodeURIComponent (value) +
(Expires = null )? "": ("; Expires =" + expires. toUTCString () +
(Path = null )? "": ("; Path =" + path) +
(Domain = null )? "": ("; Domain =" + domain) +
(Secure = true )? "; Secure ":"");
};
Cookies. get = function (name ){
Var arg = name + "= ";
Var alen = arg. length;
Var clen = document. cookie. length;
Var I = 0;
Var j = 0;
While (I <clen ){
J = I + alen;
If (document. cookie. substring (I, j) = arg)
Return Cookies. getCookieVal (j );
I = document. cookie. indexOf ("", I) + 1;
If (I = 0)
Break;
}
Return null;
};
Cookies. clear = function (name ){
If (Cookies. get (name )){
Document. cookie = name + "=" +
"; Expires = Thu, 01-Jan-70 00:00:01 GMT ";
}
};
Cookies. getCookieVal = function (offset ){
Var endstr = document. cookie. indexOf (";", offset );
If (endstr =-1 ){
Endstr = document. cookie. length;
}
Return decodeURIComponent (document. cookie. substring (offset, endstr ));
};
/**
* @ Name Cookie. js
* This should be an older cookie tool. If you want to save it with this tool class
* It's okay for unimportant things (such as status), so you don't need to think about the user name and password.
*/
/**
* Save
* @ Param {Object} name
* @ Param {Object} value
*/
JpkFrame. saveCookie = function (name, value ){
// Save for one month
Var saveDate = new Date (). getTime () + 30*24*3600*1000 );
// Console. log (saveDate. toUTCString ());
Cookies. set (name, value, saveDate );
}
/**
* Get
* @ Param {Object} name
*/
JpkFrame. getCookie = function (name ){
Return Cookies. get (name );
}
/**
* Clear
* @ Param {Object} name
*/
JpkFrame. clearCookie = function (name ){
Cookies. clear (name );
}
Var Cookies = {};
Cookies. set = function (name, value ){
Var argv = arguments;
Var argc = arguments. length;
Var expires = (argc> 2 )? Argv [2]: null;
Var path = (argc> 3 )? Argv [3]: '/';
Var domain = (argc> 4 )? Argv [4]: null;
Var secure = (argc> 5 )? Argv [5]: false;
Document. cookie = name + "=" + encodeURIComponent (value) +
(Expires = null )? "": ("; Expires =" + expires. toUTCString () +
(Path = null )? "": ("; Path =" + path) +
(Domain = null )? "": ("; Domain =" + domain) +
(Secure = true )? "; Secure ":"");
};
Cookies. get = function (name ){
Var arg = name + "= ";
Var alen = arg. length;
Var clen = document. cookie. length;
Var I = 0;
Var j = 0;
While (I <clen ){
J = I + alen;
If (document. cookie. substring (I, j) = arg)
Return Cookies. getCookieVal (j );
I = document. cookie. indexOf ("", I) + 1;
If (I = 0)
Break;
}
Return null;
};
Cookies. clear = function (name ){
If (Cookies. get (name )){
Document. cookie = name + "=" +
"; Expires = Thu, 01-Jan-70 00:00:01 GMT ";
}
};
Cookies. getCookieVal = function (offset ){
Var endstr = document. cookie. indexOf (";", offset );
If (endstr =-1 ){
Endstr = document. cookie. length;
}
Return decodeURIComponent (document. cookie. substring (offset, endstr ));
};
In onReady of Ext
[Javascript]/**
* Change the topic
* @ Param {Object} value
*/
Var changeTheme = function (value ){
If (value ){
Ext. util. CSS. swapStyleSheet ('window', 'ext/resources/css/'+ value + '.css ');
// When restoring to the default style, do not forget to add the custom Style
If (value = 'ext-all '){
Ext. util. CSS. swapStyleSheet ('window', 'jslib/css/main.css ');
}
// Save the topic
SaveThemeToCookie (value );
}
}
/**
* Save the topic name to the cookie.
* @ Param {Object} value
*/
Var saveThemeToCookie = function (value ){
JpkFrame. saveCookie ('jpkframe. theme ', value );
}
/**
* Obtain a topic from a cookie
* Parentheses indicate that the function is executed immediately.
*/
Var readThemeFromCookie = function (){
Var themeValue = JpkFrame. getCookie ('jpkframe. theme ');
If (themeValue ){
Ext. getCmp ('Theme-combo '). setValue (themeValue );
ChangeTheme (themeValue );
}
}();
From jelly village chief