日期:2014-05-16 浏览次数:20355 次
function singplay() {
var self = this;
this.prefix = "sing_play__fm_";
this.playIndex = -1;
this.listIndex = { PlayList: 0, MusicBox: 1 };
this.isLogin = false;
this.countMusicbox = -1;
this.cookieList = { PlayList: this.prefix + "0", MusicBox: this.prefix + "1" };
this.cookie;
this.agent;
this.init();
}
singplay.prototype.init = function () {
var self = this;
this.cookie = self.cookieList.PlayList;
};
singplay.prototype.setCurrentCookie = function (o) {
this.cookie = o;
};
查找数组中是否包含某个元素
*/
Array.prototype.include = function (val) {
return this.index(val) !== null;
}
//#endregion
//#region getCookie
/*获取cookie
*/
function getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return JSON.parse(unescape(arr[2])); return null;
}
function getcookie(name)//取cookies函数
{
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]); return null;
}
//#endregion
//#region setCookie
/*设置cookie
*/
function setCookie(name, value) {
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
//alert(getCookie(name) + "||" + name);
}
//#endregion
//#region deleteCookie
/*删除cookie
*/
function deleteCookie(name, path, domain) {
if (getcookie(name)) {
document.cookie = name + '=' +
((path) ? ';path=' + path : '') +
((domain) ? ';domain=' + domain : '') +
';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
}