Recent cookie browsing history (Chinese escape transcoding)
Last Update:2014-06-09
Source: Internet
Author: User
[Javascript]/*** pro_id: Product id * brand_name: brand * pro_name: Product id * price: price * catalog: Model * img: Image * file_name: file name */varaddHistoryfunction (pro_id, brand_name, pro _... [javascript]/*** pro_id: Product id * brand_name: brand * pro_name: Product id * price: price * catalog: Model * img: Image * file_name: file name */var addHistory = function (pro_id, brand_name, pro_name, price, catalog, img, file_name) {stringCookie = getCookie ('History '); var stringHistor Y = ""! = StringCookie? StringCookie: "{history: []}"; var json = new JSON (stringHistory); var pro_ids = ''; jQuery. each (json ['History '], function (I, val) {pro_ids + = json ['History'] [I]. pro_id + ",";}); if (jQuery. trim (pro_id) = ''| pro_ids.indexOf (pro_id) =-1) {var e =" {pro_id: "+ pro_id +", brand_name: '"+ brand_name +"', pro_name: '"+ pro_name +"', price: '"+ price +"', catalog: '"+ catalog +"', img: '"+ img +"', file_name: '"+ file_name +"'} "; json ['h Istory ']. push (e); // Add a new record setCookie ('History ', json. toString (), 30) ;}/// display the historical records var DisplayHistory = function () {var p_ele = document. getElementById ('History '); while (p_ele.firstChild) {p_ele.removeChild (p_ele.firstChild);} var historyJSON = getCookie ('History'); var json = new JSON (historyJSON ); var displayNum = 6; for (I = json ['History ']. length-1; I> = 0; I --) {addLi (json ['History '] [I] ['Pro _ id'], json ['his Comment '] [I] ['brand _ name'], json ['History'] [I] ['Pro _ name'], json ['History '] [I] ['price'], json ['History'] [I] ['catalog '], json ['History '] [I] ['img'], json ['History '] [I] ['file _ name'], "history"); displayNum --; if (displayNum = 0) {break ;}}// Add a cookie var addLi = function (pro_id, brand_name, pro_name, price, catalog, img, file_name, pid) {var a = document. createElement ('A'); var href = '/proDetail/' + file_name;. setAttrib Ute ('href ', href);. setAttribute ("target", "_ blank"); jQuery(a).html ("" + unescape (brand_name + pro_name + catalog) + "" + unescape (price) + ""); var li = document. createElement ('lil'); li. appendChild (a); jQuery (li ). appendTo ("#" + pid);} // Add cookie var setCookie = function (c_name, value, expiredays) {var exdate = new Date () exdate. setDate (exdate. getDate () + expiredays) cookieVal = c_name + "=" + escape (value) + (expireday S = null )? "": "; Path =/; expires =" + exdate. toGMTString (); document. cookie = cookieVal;} // obtain the cookie function getCookie (c_name) {if (document. cookie. length> 0) {c_start = document. cookie. indexOf (c_name + "=") if (c_start! =-1) {c_start = c_start + c_name.length + 1 c_end = document. cookie. indexOf (";", c_start) if (c_end =-1) c_end = document. cookie. length return unescape (document. cookie. substring (c_start, c_end)} return "} // clear cookie function DeleteCookie () {setCookie ('History '," {history: []} ", 30);} json. js [javascript] var JSON = function (sJSON) {this. objType = (typeof sJSON); if (this. objType = 'string' & ''= sJSON ){ SJSON = '{history: []}';} this. self = []; (function (s, o) {for (var I in o) {o. hasOwnProperty (I) & (s [I] = o [I], s. self [I] = o [I]) };} (this, (this. objType = 'string ')? Eval ('0, '+ sJSON): sJSON);} JSON. prototype = {toString: function () {return this. getString () ;}, valueOf: function () {return this. getString () ;}, getString: function () {var sA = []; (function (o) {var oo = null; sA. push ('{'); for (var I in o) {if (o. hasOwnProperty (I) & I! = 'Prototype') {oo = o [I]; if (oo instanceof Array) {sA. push (I + ': ['); for (var B in oo) {if (oo. hasOwnProperty (B) & B! = 'Prototype') {sA. push (oo [B] + ','); if (typeof oo [B] = 'object') arguments. callee (oo [B]) ;}} sA. push ('],'); continue;} else {sA. push (I + ': \ ''+ oo +' \ ',');} if (typeof oo = 'object') arguments. callee (oo) ;}} sA. push ('},');}) (this. self); return sA. slice (0 ). join (''). replace (/\ [object \],/ig ,''). replace (/, \}/g ,'}'). replace (/, \]/g, ']'). slice (0,-1) ;}, push: function (sName, sValue) {this. self [sName] = sValue; this [sName] = sValue;} adds a cookie addHistory ("<%= uuid %> ", escape ("<% = factoryname %>"), escape ("<% = name %>"), escape ("<% = price %> "), escape ("<% = catalogname %>"), escape ("<% = img %>"), escape ("<% = file_name %> "));