- set : function(name, value){
- var me = this;
- me.state[name] = value;
- me.fireEvent("statechange", me, name, value);
- },
-
-<span id='Ext-state.Provider-method-decodeValue'> /**
-</span> * Decodes a string previously encoded with {@link #encodeValue}.
- * @param {String} value The value to decode
- * @return {Mixed} The decoded value
- */
- decodeValue : function(value){
-
- // a -> Array
- // n -> Number
- // d -> Date
- // b -> Boolean
- // s -> String
- // o -> Object
- // -> Empty (null)
-
- var me = this,
- re = /^(a|n|d|b|s|o|e)\:(.*)$/,
- matches = re.exec(unescape(value)),
- all,
- type,
- value,
- keyValue;
-
- if(!matches || !matches[1]){
- return; // non state
- }
-
- type = matches[1];
- value = matches[2];
- switch (type) {
- case 'e':
- return null;
- case 'n':
- return parseFloat(value);
- case 'd':
- return new Date(Date.parse(value));
- case 'b':
- return (value == '1');
- case 'a':
- all = [];
- if(value != ''){
- Ext.each(value.split('^'), function(val){
- all.push(me.decodeValue(val));
- }, me);
- }
- return all;
- case 'o':
- all = {};
- if(value != ''){
- Ext.each(value.split('^'), function(val){
- keyValue = val.split('=');
- all[keyValue[0]] = me.decodeValue(keyValue[1]);
- }, me);
- }
- return all;
- default:
- return value;
- }
- },
-
-<span id='Ext-state.Provider-method-encodeValue'> /**
-</span> * Encodes a value including type information. Decode with {@link #decodeValue}.
- * @param {Mixed} value The value to encode
- * @return {String} The encoded value