2 function convertEntities(o) {
5 if (/&[^;]+;/.test(s)) {
6 var e = document.createElement("div");
8 return !e.firstChild ? s : e.firstChild.nodeValue;
13 if ( typeof o === 'string' ) {
15 } else if ( typeof o === 'object' ) {
17 if ( typeof o[v] === 'string' ) {
26 // The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL.
28 each : function(o, cb, s) {
36 if (typeof(o.length) != 'undefined') {
37 for (n=0, l = o.length; n<l; n++) {
38 if (cb.call(s, o[n], n, o) === false)
43 if (o.hasOwnProperty(n)) {
44 if (cb.call(s, o[n], n, o) === false) {
53 getHash : function(n) {
54 var v = this.get(n), h;
57 this.each(v.split('&'), function(v) {
66 setHash : function(n, v, e, p, d, s) {
69 this.each(v, function(v, k) {
70 o += (!o ? '' : '&') + k + '=' + v;
73 this.set(n, o, e, p, d, s);
77 var c = document.cookie, e, p = n + "=", b;
82 b = c.indexOf("; " + p);
94 e = c.indexOf(";", b);
99 return decodeURIComponent(c.substring(b + p.length, e));
102 set : function(n, v, e, p, d, s) {
103 document.cookie = n + "=" + encodeURIComponent(v) +
104 ((e) ? "; expires=" + e.toGMTString() : "") +
105 ((p) ? "; path=" + p : "") +
106 ((d) ? "; domain=" + d : "") +
107 ((s) ? "; secure" : "");
110 remove : function(n, p) {
113 d.setTime(d.getTime() - 1000);
115 this.set(n, '', d, p, d);
119 // Returns the value as string. Second arg or empty string is returned when value is not set.
120 function getUserSetting( name, def ) {
121 var o = getAllUserSettings();
123 if ( o.hasOwnProperty(name) )
126 if ( typeof def != 'undefined' )
132 // Both name and value must be only ASCII letters, numbers or underscore
133 // and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text.
134 function setUserSetting( name, value, del ) {
135 if ( 'object' !== typeof userSettings )
138 var c = 'wp-settings-' + userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date(), p,
139 n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, '');
147 d.setTime( d.getTime() + 31536000000 );
148 p = userSettings.url;
150 wpCookies.setHash(c, o, d, p);
151 wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p);
156 function deleteUserSetting( name ) {
157 return setUserSetting( name, '', 1 );
160 // Returns all settings as js object.
161 function getAllUserSettings() {
162 if ( 'object' !== typeof userSettings )
165 return wpCookies.getHash('wp-settings-' + userSettings.uid) || {};